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

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

From
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Date
Jul 25, 2017, 14:39 UTC
Message-ID
<0102015d7a301def-0d802f3e-6052-4e32-b331-c42c3160012b-000000@eu-west-1.amazonses.com>

The error messages shown when the branch command is misused by supplying it wrong number of parameters wasn't meaningful as it used the the phrase, "too many branches" which is not meaningful in the following case,

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

It's not meaningful as the implementation assumed all parameters to be branch names. It's not always the case as exemplified above.

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

Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
---
 builtin/branch.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index a3bd2262b3367..59fedf085d3db 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 parameters 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 parameters 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 parameters to unset upstream"));
 
 		if (!branch) {
 			if (!argc || !strcmp(argv[0], "HEAD"))

--
https://github.com/git/git/pull/387
Next: Kaartic Sivaraam
Message 1 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.