git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] prune, rm, show remote: exit with error code 1 on failure

From
Jari Aalto <jari.aalto@cante.net>
Date
Sep 30, 2007, 06:18 UTC
Message-ID
<641soeuv.fsf@blue.sea.net>
In-Reply-To
<ps01nxvd.fsf@blue.sea.net>
- (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
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 4 in “BUG: git remote show origin => error code 1”
  1. Jari AaltoSep 29, 2007
  2. Junio C HamanoSep 29, 2007
  3. prune, rm, show remote: exit with error code 1 on failureJari Aalto, Sep 30, 2007
  4. Junio C HamanoSep 30, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.