git-difftool: use git-mergetool--lib for "--tool-help"
The "--tool-help" option to git-difftool currently displays incorrect output since it uses the names of the files in "$GIT_EXEC_PATH/mergetools/" rather than the list of command names in git-mergetool--lib. Fix this by simply delegating the "--tool-help" argument to the show_tool_help function in git-mergetool--lib. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
John Keeping committed
Jan 25, 2013 at 01:43 UTC
abaf175cdf85ab0eb8bedd7d84ea8b42b6b3dd01
1 file changed
+7
-48
git-difftool.perl
+7
-48
@@ -59,57 +59,16 @@ sub find_worktree
59
return $worktree;
60
}
61
62
-sub filter_tool_scripts
63
-{
64
- my ($tools) = @_;
65
- if (-d $_) {
66
- if ($_ ne ".") {
67
- # Ignore files in subdirectories
68
- $File::Find::prune = 1;
69
- }
70
- } else {
71
- if ((-f $_) && ($_ ne "defaults")) {
72
- push(@$tools, $_);
73
- }
74
- }
75
-}
76
-
62
sub print_tool_help
63
{
79
- my ($cmd, @found, @notfound, @tools);
80
- my $gitpath = Git::exec_path();
81
-
82
- find(sub { filter_tool_scripts(\@tools) }, "$gitpath/mergetools");
83
-
84
- foreach my $tool (@tools) {
85
- $cmd = "TOOL_MODE=diff";
86
- $cmd .= ' && . "$(git --exec-path)/git-mergetool--lib"';
87
- $cmd .= " && get_merge_tool_path $tool >/dev/null 2>&1";
88
- $cmd .= " && can_diff >/dev/null 2>&1";
89
- if (system('sh', '-c', $cmd) == 0) {
90
- push(@found, $tool);
91
- } else {
92
- push(@notfound, $tool);
93
- }
94
- }
95
-
96
- print << 'EOF';
97
-'git difftool --tool=<tool>' may be set to one of the following:
98
-EOF
99
- print "\t$_\n" for (sort(@found));
64
+ my $cmd = 'TOOL_MODE=diff';
65
+ $cmd .= ' && . "$(git --exec-path)/git-mergetool--lib"';
66
+ $cmd .= ' && show_tool_help';
67
101
- print << 'EOF';
102
-
103
-The following tools are valid, but not currently available:
104
-EOF
105
- print "\t$_\n" for (sort(@notfound));
106
-
107
- print << 'EOF';
108
-
109
-NOTE: Some of the tools listed above only work in a windowed
110
-environment. If run in a terminal-only session, they will fail.
111
-EOF
112
- exit(0);
68
+ # See the comment at the bottom of file_diff() for the reason behind
69
+ # using system() followed by exit() instead of exec().
70
+ my $rc = system('sh', '-c', $cmd);
71
+ exit($rc | ($rc >> 8));
72
}
73
74
sub exit_cleanup