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

[PATCH v2] branch: change the error messages to be more meaningful

From
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Date
Aug 21, 2017, 13:36 UTC
Message-ID
<20170821133608.5652-1-kaarticsivaraam91196@gmail.com>
In-Reply-To
<20170730115908.13841-1-kaarticsivaraam91196@gmail.com>

The error messages shown when the branch command is misused by supplying it wrong number of parameters wasn't meaningful. That's because it used the the phrase "too many branches" assuming all parameters to be "valid" branch names. It's not always the case as exemplified below,

        $ git branch
          foo
        * master
        $ git branch -m foo foo old
        fatal: too many branches for a rename operation

Change the messages to be more general thus making no assumptions about the "parameters".

Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
---
 Changes in v2:
    - changed the wordings of the error message
 builtin/branch.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index a3bd2262b..62981d358 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -707,12 +707,12 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 		else if (argc == 2)
 			rename_branch(argv[0], argv[1], rename > 1);
 		else
-			die(_("too many branches for a rename operation"));
+			die(_("too many arguments for a rename operation"));
 	} else if (new_upstream) {
 		struct branch *branch = branch_get(argv[0]);
 
 		if (argc > 1)
-			die(_("too many branches to set new upstream"));
+			die(_("too many arguments to set new upstream"));
 
 		if (!branch) {
 			if (!argc || !strcmp(argv[0], "HEAD"))
@@ -735,7 +735,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 		struct strbuf buf = STRBUF_INIT;
 
 		if (argc > 1)
-			die(_("too many branches to unset upstream"));
+			die(_("too many arguments to unset upstream"));
 
 		if (!branch) {
 			if (!argc || !strcmp(argv[0], "HEAD"))
-- 
2.14.0.rc1.434.g6eded367a
Previous: Kaartic SivaraamNext: Kaartic Sivaraam
Message 5 of 12 in “branch: change the error messages to be more meaningful”
  1. branch: change the error messages to be more meaningfulKaartic Sivaraam, Jul 25, 2017
  2. branch: change the error messages to be more meaningfulKaartic Sivaraam, Jul 25, 2017
  3. Kaartic SivaraamJul 25, 2017
  4. branch: change the error messages to be more meaningfulKaartic Sivaraam, Jul 30, 2017
  5. branch: change the error messages to be more meaningfulKaartic Sivaraam, Aug 21, 2017
  6. Kaartic SivaraamOct 2, 2017
  7. Junio C HamanoOct 3, 2017
  8. Kaartic SivaraamOct 3, 2017
  9. Junio C HamanoOct 4, 2017
  10. Kaartic SivaraamOct 4, 2017
  11. Junio C HamanoOct 5, 2017
  12. Kaartic SivaraamOct 5, 2017

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.