@matheusbsbs / matheus-bagliano / commits / 9f3d54d193
Fork 0

difftool: Use eval to expand '--extcmd' expressions

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>

David Aguilar committed Jan 15, 2010 at 14:03 UTC 9f3d54d193d9edcf443c9dd62789af5e8e47635c
2 files changed +14 -2
git-difftool--helper.sh
+1 -2
@@ -48,11 +48,10 @@ launch_merge_tool () {
48 fi
49
50 if use_ext_cmd; then
51 - $GIT_DIFFTOOL_EXTCMD "$LOCAL" "$REMOTE"
51 + eval $GIT_DIFFTOOL_EXTCMD '"$LOCAL"' '"$REMOTE"'
52 else
53 run_merge_tool "$merge_tool"
54 fi
55 -
55 }
56
57 if ! use_ext_cmd; then
t/t7800-difftool.sh
+13
@@ -235,8 +235,21 @@ test_expect_success 'difftool --extcmd cat' '
235 test_expect_success 'difftool -x cat' '
236 diff=$(git difftool --no-prompt -x cat branch) &&
237 test "$diff" = branch"$LF"master
238 +'
239 +
240 +test_expect_success 'difftool --extcmd echo arg1' '
241 + diff=$(git difftool --no-prompt --extcmd sh\ -c\ \"echo\ \$1\" branch)
242 + test "$diff" = file
243 +'
244
245 +test_expect_success 'difftool --extcmd cat arg1' '
246 + diff=$(git difftool --no-prompt --extcmd sh\ -c\ \"cat\ \$1\" branch)
247 + test "$diff" = master
248 +'
249
250 +test_expect_success 'difftool --extcmd cat arg2' '
251 + diff=$(git difftool --no-prompt --extcmd sh\ -c\ \"cat\ \$2\" branch)
252 + test "$diff" = branch
253 '
254
255 test_done