Skip to content

Commit

Permalink
Fix _forgit_diff failing when two commits were passed as arguments. T…
Browse files Browse the repository at this point in the history
…his was introduced in 3770443
  • Loading branch information
sandr01d committed Jan 1, 2024
1 parent 4b9575c commit 18acef7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bin/git-forgit
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ _forgit_diff_view() {
local diff_context=$2
local commits=()
if [ $# -gt 2 ]; then
local commits=("${*:3}")
IFS=" " read -r -a commits <<< "${*:3}"
fi
echo "$input_line" | _forgit_get_files_from_diff_line | xargs -0 \
"$FORGIT" exec_diff "${commits[@]}" -U"$diff_context" -- | $_forgit_diff_pager
Expand All @@ -267,7 +267,7 @@ _forgit_edit_diffed_file() {
# git diff viewer
_forgit_diff() {
_forgit_inside_work_tree || return 1
local files opts commits repo preview_cmd enter_cmd
local files opts commits repo preview_cmd enter_cmd escaped_commits
[[ $# -ne 0 ]] && {
if git rev-parse "$1" -- &>/dev/null ; then
if [[ $# -gt 1 ]] && git rev-parse "$2" -- &>/dev/null; then
Expand All @@ -284,7 +284,9 @@ _forgit_diff() {
# In order to support passing stashes as arguments to _forgit_diff, we have to
# prevent fzf from interpreting this substring by escaping the opening bracket.
# The string is evaluated a few subsequent times, so we need multiple escapes.
escaped_commits=${commits//\{/\\\\\{}
for commit in "${commits[@]}"; do
escaped_commits+="'${commit//\{/\\\\\{}' "
done
preview_cmd="cd '$repo' && $FORGIT diff_view {} $_forgit_preview_context $escaped_commits"
enter_cmd="cd '$repo' && $FORGIT diff_view {} $_forgit_fullscreen_context $escaped_commits"
opts="
Expand Down

0 comments on commit 18acef7

Please sign in to comment.