git-remote: exit with non-zero status after detecting errors.
Some subcommands of "git-remote" detected and issued error messages but did not signal that to the calling process with exit status. Signed-off-by: Jari Aalto <jari.aalto@cante.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jari Aalto committed
Sep 29, 2007 at 23:29 UTC
f4bb20cc99fe18ba0e7dd421f1d95a05c1cbbc93
1 file changed
+10
-4
git-remote.perl
+10
-4
@@ -218,7 +218,7 @@ sub prune_remote {
218
my ($name, $ls_remote) = @_;
219
if (!exists $remote->{$name}) {
220
print STDERR "No such remote $name\n";
221
- return;
221
+ return 1;
222
}
223
my $info = $remote->{$name};
224
update_ls_remote($ls_remote, $info);
@@ -229,13 +229,14 @@ sub prune_remote {
229
my @v = $git->command(qw(rev-parse --verify), "$prefix/$to_prune");
230
$git->command(qw(update-ref -d), "$prefix/$to_prune", $v[0]);
231
}
232
+ return 0;
233
}
234
235
sub show_remote {
236
my ($name, $ls_remote) = @_;
237
if (!exists $remote->{$name}) {
238
print STDERR "No such remote $name\n";
238
- return;
239
+ return 1;
240
}
241
my $info = $remote->{$name};
242
update_ls_remote($ls_remote, $info);
@@ -265,6 +266,7 @@ sub show_remote {
266
print " Local branch(es) pushed with 'git push'\n";
267
print " @pushed\n";
268
}
269
+ return 0;
270
}
271
272
sub add_remote {
@@ -351,9 +353,11 @@ elsif ($ARGV[0] eq 'show') {
353
print STDERR "Usage: git remote show <remote>\n";
354
exit(1);
355
}
356
+ my $status = 0;
357
for (; $i < @ARGV; $i++) {
355
- show_remote($ARGV[$i], $ls_remote);
358
+ $status |= show_remote($ARGV[$i], $ls_remote);
359
}
360
+ exit($status);
361
}
362
elsif ($ARGV[0] eq 'update') {
363
if (@ARGV <= 1) {
@@ -379,9 +383,11 @@ elsif ($ARGV[0] eq 'prune') {
383
print STDERR "Usage: git remote prune <remote>\n";
384
exit(1);
385
}
386
+ my $status = 0;
387
for (; $i < @ARGV; $i++) {
383
- prune_remote($ARGV[$i], $ls_remote);
388
+ $status |= prune_remote($ARGV[$i], $ls_remote);
389
}
390
+ exit($status);
391
}
392
elsif ($ARGV[0] eq 'add') {
393
my %opts = ();