Skip to content

Commit

Permalink
difftool: Use eval to expand '--extcmd' expressions
Browse files Browse the repository at this point in the history
It was not possible to pass quoted commands to '--extcmd'.
By using 'eval' we ensure that expressions with spaces and
quotes are supported.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
David Aguilar authored and Junio C Hamano committed Jan 15, 2010
1 parent f47f1e2 commit 9f3d54d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 1 addition & 2 deletions git-difftool--helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ launch_merge_tool () {
fi

if use_ext_cmd; then
$GIT_DIFFTOOL_EXTCMD "$LOCAL" "$REMOTE"
eval $GIT_DIFFTOOL_EXTCMD '"$LOCAL"' '"$REMOTE"'
else
run_merge_tool "$merge_tool"
fi

}

if ! use_ext_cmd; then
Expand Down
13 changes: 13 additions & 0 deletions t/t7800-difftool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,21 @@ test_expect_success 'difftool --extcmd cat' '
test_expect_success 'difftool -x cat' '
diff=$(git difftool --no-prompt -x cat branch) &&
test "$diff" = branch"$LF"master
'

test_expect_success 'difftool --extcmd echo arg1' '
diff=$(git difftool --no-prompt --extcmd sh\ -c\ \"echo\ \$1\" branch)
test "$diff" = file
'

test_expect_success 'difftool --extcmd cat arg1' '
diff=$(git difftool --no-prompt --extcmd sh\ -c\ \"cat\ \$1\" branch)
test "$diff" = master
'

test_expect_success 'difftool --extcmd cat arg2' '
diff=$(git difftool --no-prompt --extcmd sh\ -c\ \"cat\ \$2\" branch)
test "$diff" = branch
'

test_done

0 comments on commit 9f3d54d

Please sign in to comment.