difftool: don't assume that default sh is sane

git-difftool used to create a command list script containing $( ... ) and explicitly calls "sh -c" with this list. Instead, allow mergetool --tool-help to take a mode parameter and call mergetool directly to invoke the show_tool_help function. This mode parameter is intented for use solely by difftool. Signed-off-by: Charles Bailey <cbailey32@bloomberg.net> Helped-by: John Keeping <john@keeping.me.uk> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Charles Bailey committed Oct 11, 2014 at 01:39 UTC 4fb4b02d98310f4f859f7d52f57f36d49198be5c
2 files changed +5 -5
git-difftool.perl
+1 -5
@@ -47,13 +47,9 @@ sub find_worktree
47
48 sub print_tool_help
49 {
50 - my $cmd = 'TOOL_MODE=diff';
51 - $cmd .= ' && . "$(git --exec-path)/git-mergetool--lib"';
52 - $cmd .= ' && show_tool_help';
53 -
50 # See the comment at the bottom of file_diff() for the reason behind
51 # using system() followed by exit() instead of exec().
56 - my $rc = system('sh', '-c', $cmd);
52 + my $rc = system(qw(git mergetool --tool-help=diff));
53 exit($rc | ($rc >> 8));
54 }
55
git-mergetool.sh
+4
@@ -326,6 +326,10 @@ prompt=$(git config --bool mergetool.prompt || echo true)
326 while test $# != 0
327 do
328 case "$1" in
329 + --tool-help=*)
330 + TOOL_MODE=${1#--tool-help=}
331 + show_tool_help
332 + ;;
333 --tool-help)
334 show_tool_help
335 ;;