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

[PATCH] branch: die explicitly why when calling "git branch [-a|-r] branchname".

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
Dec 30, 2009, 14:45 UTC
Message-ID
<1262184331-9102-1-git-send-email-Matthieu.Moy@imag.fr>
The -a and -r options used to be silently ignored in such a command.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 builtin-branch.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/builtin-branch.c b/builtin-branch.c
index c87e63b..8aef2bb 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -638,10 +638,13 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 		rename_branch(head, argv[0], rename > 1);
 	else if (rename && (argc == 2))
 		rename_branch(argv[0], argv[1], rename > 1);
-	else if (argc <= 2)
+	else if (argc <= 2) {
+		if (kinds != REF_LOCAL_BRANCH) {
+			die("-a and -r options to 'git branch' do not make sense with a branch name");
+		}
 		create_branch(head, argv[0], (argc == 2) ? argv[1] : head,
 			      force_create, reflog, track);
-	else
+	} else
 		usage_with_options(builtin_branch_usage, options);
 
 	return 0;
-- 
1.6.6.71.gcc720.dirty
Next: Junio C Hamano
Message 1 of 2 in “branch: die explicitly why when calling "git branch [-a|-r] branchname".”
  1. branch: die explicitly why when calling "git branch [-a|-r] branchname".Matthieu Moy, Dec 30, 2009
  2. Junio C HamanoDec 31, 2009

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.