Skip to content

Commit 7a5e68b

Browse files
authored
Fix: allow filtering by files in fixup, squash and reword (#448)
This reverts commit 3f694f6 and adds the same filtering option to reword.
1 parent d08c9e5 commit 7a5e68b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

bin/git-forgit

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -755,32 +755,34 @@ _forgit_file_preview() {
755755
_forgit_fixup() {
756756
_forgit_inside_work_tree || return 1
757757
git diff --cached --quiet && echo 'Nothing to fixup: there are no staged changes.' && return 1
758-
_forgit_edit_commit --fixup "$FORGIT_FIXUP_FZF_OPTS" "$FORGIT_FIXUP_GIT_OPTS"
758+
_forgit_edit_commit --fixup "$FORGIT_FIXUP_FZF_OPTS" "$FORGIT_FIXUP_GIT_OPTS" "$@"
759759
}
760760

761761
_forgit_squash() {
762762
_forgit_inside_work_tree || return 1
763763
git diff --cached --quiet && echo 'Nothing to squash: there are no staged changes.' && return 1
764-
_forgit_edit_commit --squash "$FORGIT_SQUASH_FZF_OPTS" "$FORGIT_SQUASH_GIT_OPTS"
764+
_forgit_edit_commit --squash "$FORGIT_SQUASH_FZF_OPTS" "$FORGIT_SQUASH_GIT_OPTS" "$@"
765765
}
766766

767767
_forgit_edit_commit() {
768-
local action fzf_opts opts graph target_commit prev_commit
768+
local action fzf_opts opts graph quoted_files target_commit prev_commit
769769
action=$1
770770
fzf_opts=$2
771771
graph=()
772772
[[ $_forgit_log_graph_enable == true ]] && graph=(--graph)
773773
git_opts=()
774774
_forgit_parse_array git_opts "$3"
775+
shift 3
776+
quoted_files=$(_forgit_quote_files "$@")
775777
opts="
776778
$FORGIT_FZF_DEFAULT_OPTS
777779
+s +m --tiebreak=index
778780
--bind=\"ctrl-y:execute-silent($FORGIT yank_sha {})\"
779-
--preview=\"$FORGIT file_preview {}\"
781+
--preview=\"$FORGIT file_preview {} $quoted_files\"
780782
$fzf_opts
781783
"
782784
target_commit=$(
783-
git log "${graph[@]}" --color=always --format="$_forgit_log_format" |
785+
git log "${graph[@]}" --color=always --format="$_forgit_log_format" "$@" |
784786
_forgit_emojify |
785787
FZF_DEFAULT_OPTS="$opts" fzf |
786788
_forgit_extract_sha)
@@ -800,15 +802,16 @@ _forgit_reword() {
800802
[[ $_forgit_log_graph_enable == true ]] && graph=(--graph)
801803
git_opts=()
802804
_forgit_parse_array _forgit_reword_git_opts "$FORGIT_REWORD_GIT_OPTS"
805+
quoted_files=$(_forgit_quote_files "$@")
803806
opts="
804807
$FORGIT_FZF_DEFAULT_OPTS
805808
+s +m --tiebreak=index
806809
--bind=\"ctrl-y:execute-silent($FORGIT yank_sha {})\"
807-
--preview=\"$FORGIT file_preview {}\"
810+
--preview=\"$FORGIT file_preview {} $quoted_files\"
808811
$FORGIT_REWORD_FZF_OPTS
809812
"
810813
target_commit=$(
811-
git log "${graph[@]}" --color=always --format="$_forgit_log_format" |
814+
git log "${graph[@]}" --color=always --format="$_forgit_log_format" "$@" |
812815
_forgit_emojify |
813816
FZF_DEFAULT_OPTS="$opts" fzf |
814817
_forgit_extract_sha)

0 commit comments

Comments
 (0)