git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* BUG: git remote show origin => error code 1
@ 2007-09-29 18:13 Jari Aalto
  2007-09-29 22:28 ` Junio C Hamano
  2007-09-30  6:18 ` [PATCH] prune, rm, show remote: exit with error code 1 on failure Jari Aalto
  0 siblings, 2 replies; 4+ messages in thread
From: Jari Aalto @ 2007-09-29 18:13 UTC (permalink / raw)
  To: git


Consider this:

    $ git remote show origin
    No such remote origin

    $ echo $?
    0

Perhaps the code should return non-zero in this case, so that shell
scripts could use construct:

    git remote show origin; || <another action>

Jari

-- 
Welcome to FOSS revolution: we fix and modify until it shines

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: BUG: git remote show origin => error code 1
  2007-09-29 18:13 BUG: git remote show origin => error code 1 Jari Aalto
@ 2007-09-29 22:28 ` Junio C Hamano
  2007-09-30  6:18 ` [PATCH] prune, rm, show remote: exit with error code 1 on failure Jari Aalto
  1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2007-09-29 22:28 UTC (permalink / raw)
  To: Jari Aalto; +Cc: git

Jari Aalto <jari.aalto@cante.net> writes:

> Consider this:
> ...
> Jari
>
> -- 
> Welcome to FOSS revolution: we fix and modify until it shines

Patches are welcome ;-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] prune, rm, show remote: exit with error code 1 on failure
  2007-09-29 18:13 BUG: git remote show origin => error code 1 Jari Aalto
  2007-09-29 22:28 ` Junio C Hamano
@ 2007-09-30  6:18 ` Jari Aalto
  2007-09-30  9:54   ` Junio C Hamano
  1 sibling, 1 reply; 4+ messages in thread
From: Jari Aalto @ 2007-09-30  6:18 UTC (permalink / raw)
  To: git

- (rm_remote): Return error code 1 on failure.
- (show_remote): Return error code 1 on failure.
- (prune_remote): Return error code 1 on failure.
- (@ARGV eq show):
  exit in case of 'No such remote'.
- (@ARGV eq prune):
- exitin case of 'No such remote'.
- (@ARGV eq rm):
- exit in case of 'No such remote'.

Signed-off-by: Jari Aalto <jari.aalto AT cante.net>
---
 git-remote.perl |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/git-remote.perl b/git-remote.perl
index b7c1e01..84a9b5c 100755
--- a/git-remote.perl
+++ b/git-remote.perl
@@ -218,7 +218,7 @@ sub prune_remote {
 	my ($name, $ls_remote) = @_;
 	if (!exists $remote->{$name}) {
 		print STDERR "No such remote $name\n";
-		return;
+		return 1;
 	}
 	my $info = $remote->{$name};
 	update_ls_remote($ls_remote, $info);
@@ -235,7 +235,7 @@ sub show_remote {
 	my ($name, $ls_remote) = @_;
 	if (!exists $remote->{$name}) {
 		print STDERR "No such remote $name\n";
-		return;
+		return 1;
 	}
 	my $info = $remote->{$name};
 	update_ls_remote($ls_remote, $info);
@@ -320,7 +320,7 @@ sub rm_remote {
 	my ($name) = @_;
 	if (!exists $remote->{$name}) {
 		print STDERR "No such remote $name\n";
-		return;
+		return 1;
 	}
 
 	$git->command('config', '--remove-section', "remote.$name");
@@ -381,9 +381,12 @@ elsif ($ARGV[0] eq 'show') {
 		print STDERR "Usage: git remote show <remote>\n";
 		exit(1);
 	}
+	my $status = 0;
 	for (; $i < @ARGV; $i++) {
-		show_remote($ARGV[$i], $ls_remote);
+		my $ret = show_remote($ARGV[$i], $ls_remote);
+		$status = $ret if $ret;
 	}
+	exit($status);
 }
 elsif ($ARGV[0] eq 'update') {
 	if (@ARGV <= 1) {
@@ -409,9 +412,12 @@ elsif ($ARGV[0] eq 'prune') {
 		print STDERR "Usage: git remote prune <remote>\n";
 		exit(1);
 	}
+	my $status = 0;
 	for (; $i < @ARGV; $i++) {
-		prune_remote($ARGV[$i], $ls_remote);
+		my $ret = prune_remote($ARGV[$i], $ls_remote);
+                $status = $ret if $ret;
 	}
+        exit($status);
 }
 elsif ($ARGV[0] eq 'add') {
 	my %opts = ();
@@ -455,7 +461,8 @@ elsif ($ARGV[0] eq 'rm') {
 		print STDERR "Usage: git remote rm <remote>\n";
 		exit(1);
 	}
-	rm_remote($ARGV[1]);
+	my $status = rm_remote($ARGV[1]);
+        exit($status) if $status;
 }
 else {
 	print STDERR "Usage: git remote\n";
-- 
1.5.3.2.81.g17ed

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] prune, rm, show remote: exit with error code 1 on failure
  2007-09-30  6:18 ` [PATCH] prune, rm, show remote: exit with error code 1 on failure Jari Aalto
@ 2007-09-30  9:54   ` Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2007-09-30  9:54 UTC (permalink / raw)
  To: Jari Aalto; +Cc: git

Thanks.

Because this is a bugfix patch, we would want the fix applied to
'maint' to become part of 1.5.3.4, but your patch contained the
fix for "remote rm" that is not (and will not be) part of 'maint'.

I split the patch into two, applied the bits without "rm" part
to 'maint', merged the result into 'master' and applied the fix
for "rm" on 'master'.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-09-30  9:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-29 18:13 BUG: git remote show origin => error code 1 Jari Aalto
2007-09-29 22:28 ` Junio C Hamano
2007-09-30  6:18 ` [PATCH] prune, rm, show remote: exit with error code 1 on failure Jari Aalto
2007-09-30  9:54   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).