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@xxxxxxxxx> --- Updates since v1: * Uses a more readable quoting style as suggested by J6t. * We no longer use a subshell. git-difftool--helper.sh | 3 +-- t/t7800-difftool.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh index d806eae..a1c5c09 100755 --- a/git-difftool--helper.sh +++ b/git-difftool--helper.sh @@ -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 diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index 69e1c34..a183f1d 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -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 -- 1.6.6.6.g627fb.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html