mirror of
https://github.com/git/git.git
synced 2024-10-29 05:17:52 +01:00
difftool: exit(0) when usage is printed
Prior to this commit, the script exited with an error whenever the usage string was printed, regardless of the reason it was done. In cases where usage was printed due to a user request (e.g. '-h' option), the script should exit without error (exit 0). This commit adds an argument to the usage function that allows the exit code to be specified when the function is called. Signed-off-by: Tim Henigan <tim.henigan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
850896042a
commit
283607694c
1 changed files with 5 additions and 4 deletions
|
@ -20,6 +20,7 @@
|
|||
|
||||
sub usage
|
||||
{
|
||||
my $exitcode = shift;
|
||||
print << 'USAGE';
|
||||
usage: git difftool [-t|--tool=<tool>]
|
||||
[-x|--extcmd=<cmd>]
|
||||
|
@ -27,7 +28,7 @@ sub usage
|
|||
[--prompt] [-y|--no-prompt]
|
||||
['git diff' options]
|
||||
USAGE
|
||||
exit 1;
|
||||
exit($exitcode);
|
||||
}
|
||||
|
||||
sub setup_environment
|
||||
|
@ -58,14 +59,14 @@ sub exe
|
|||
'x|extcmd:s' => \$extcmd);
|
||||
|
||||
if (defined($help)) {
|
||||
usage();
|
||||
usage(0);
|
||||
}
|
||||
if (defined($difftool_cmd)) {
|
||||
if (length($difftool_cmd) > 0) {
|
||||
$ENV{GIT_DIFF_TOOL} = $difftool_cmd;
|
||||
} else {
|
||||
print "No <tool> given for --tool=<tool>\n";
|
||||
usage();
|
||||
usage(1);
|
||||
}
|
||||
}
|
||||
if (defined($extcmd)) {
|
||||
|
@ -73,7 +74,7 @@ sub exe
|
|||
$ENV{GIT_DIFFTOOL_EXTCMD} = $extcmd;
|
||||
} else {
|
||||
print "No <cmd> given for --extcmd=<cmd>\n";
|
||||
usage();
|
||||
usage(1);
|
||||
}
|
||||
}
|
||||
if ($gui) {
|
||||
|
|
Loading…
Reference in a new issue