difftool: don't assume that default sh is sane
authorCharles Bailey <cbailey32@bloomberg.net>
Sat, 11 Oct 2014 08:39:38 +0000 (01:39 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Oct 2014 21:12:20 +0000 (14:12 -0700)
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>
git-difftool.perl
git-mergetool.sh
index 18ca61e8d0493bde9c21ed337043bc72fa5c73a7..598fcc23b930832a8cd3cfcff0c0d0c84ecd32bc 100755 (executable)
@@ -47,13 +47,9 @@ sub find_worktree
 
 sub print_tool_help
 {
-       my $cmd = 'TOOL_MODE=diff';
-       $cmd .= ' && . "$(git --exec-path)/git-mergetool--lib"';
-       $cmd .= ' && show_tool_help';
-
        # See the comment at the bottom of file_diff() for the reason behind
        # using system() followed by exit() instead of exec().
-       my $rc = system('sh', '-c', $cmd);
+       my $rc = system(qw(git mergetool --tool-help=diff));
        exit($rc | ($rc >> 8));
 }
 
index 8098d2dc076a0ff6044e5c4cadbb39a4a32483c5..821253e3688ca3fdc9091334984b5125a15abc33 100755 (executable)
@@ -326,6 +326,10 @@ prompt=$(git config --bool mergetool.prompt || echo true)
 while test $# != 0
 do
        case "$1" in
+       --tool-help=*)
+               TOOL_MODE=${1#--tool-help=}
+               show_tool_help
+               ;;
        --tool-help)
                show_tool_help
                ;;