Skip to contentSkip to conversation

remote: in case of error don't show success message.

PATCH In review Christian Schlack via GitGitGadget 2 participants 2 messages Sep 17, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remote: in case of error don't show success message.

From: Christian Schlack <[email protected]>

Suppress the message 'origin/HEAD set to master' in case of an error.

  $ git remote set-head origin -a
  error: Not a valid ref: refs/remotes/origin/master
  origin/HEAD set to master

---
remote: in case of error don't show success message.

Expected behaviour

$ git remote set-head origin -a
error: Not a valid ref: refs/remotes/origin/master

Actual behaviour

$ git remote set-head origin -a
error: Not a valid ref: refs/remotes/origin/master origin/HEAD set to master

I believe ... set to master should not be shown in case of an error. That's why I added an else to the if-condition.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-848%2Fcschlack%2Fremote-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-848/cschlack/remote-v1
Pull-Request: https://github.com/git/git/pull/848

 builtin/remote.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
builtin/remote.c +1 -1
index 542f56e387..64b4b551eb 100644
@@ -1356,7 +1356,7 @@ static int set_head(int argc, const char **argv)
 			result |= error(_("Not a valid ref: %s"), buf2.buf);
 		else if (create_symref(buf.buf, buf2.buf, "remote set-head"))
 			result |= error(_("Could not setup %s"), buf.buf);
-		if (opt_a)
+		else if (opt_a)
 			printf("%s/HEAD set to %s\n", argv[0], head_name);
 		free(head_name);
 	}

base-commit: 54e85e7af1ac9e9a92888060d6811ae767fea1bc

Signature · 1 line
gitgitgadget
#1 lore raw

"Christian Schlack via GitGitGadget" <[email protected]>

Quoted 6 lines · writes:
builtin/remote.c +0 -0
index 542f56e387..64b4b551eb 100644

builtin/remote.c static int set_head(int argc, const char **argv) · line 1362

Quoted 8 lines
builtin/remote.c +1 -1
@@ -1356,7 +1356,7 @@ static int set_head(int argc, const char **argv)
 			result |= error(_("Not a valid ref: %s"), buf2.buf);
 		else if (create_symref(buf.buf, buf2.buf, "remote set-head"))
 			result |= error(_("Could not setup %s"), buf.buf);
-		if (opt_a)
+		else if (opt_a)
 			printf("%s/HEAD set to %s\n", argv[0], head_name);
 		free(head_name);
 	}

Quite straight-forward and looks obviously good.

Thanks, will queue.