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

12 messages from 2017-07-25 to 2017-10-05. Participants: Kaartic Sivaraam, Junio C Hamano.
Thread: https://gitlist.dev/t/46467

## Kaartic Sivaraam, 2017-07-25 14:39

Subject: [PATCH] branch: change the error messages to be more meaningful
Message-ID: <0102015d7a301def-0d802f3e-6052-4e32-b331-c42c3160012b-000000@eu-west-1.amazonses.com>
URL: https://gitlist.dev/e/0102015d7a301def-0d802f3e-6052-4e32-b331-c42c3160012b-000000%40eu-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

```

## Kaartic Sivaraam, 2017-07-25 18:28

Subject: [PATCH] branch: change the error messages to be more meaningful
Message-ID: <0102015d7b021c6c-8741d523-c7d7-4be5-923a-cd4a925842a0-000000@eu-west-1.amazonses.com>
URL: https://gitlist.dev/e/0102015d7b021c6c-8741d523-c7d7-4be5-923a-cd4a925842a0-000000%40eu-west-1.amazonses.com
In-Reply-To: <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.
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>
---
 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/389

```

## Kaartic Sivaraam, 2017-07-25 18:31

Subject: Re: [PATCH] branch: change the error messages to be more meaningful
Message-ID: <1501007517.11979.4.camel@gmail.com>
URL: https://gitlist.dev/e/1501007517.11979.4.camel%40gmail.com
In-Reply-To: <0102015d7b021c6c-8741d523-c7d7-4be5-923a-cd4a925842a0-000000@eu-west-1.amazonses.com>

```
The second patch differs from the first one only in the commit message.

-- 
Kaartic

```

## Kaartic Sivaraam, 2017-07-30 11:59

Subject: [PATCH] branch: change the error messages to be more meaningful
Message-ID: <20170730115908.13841-1-kaarticsivaraam91196@gmail.com>
URL: https://gitlist.dev/e/20170730115908.13841-1-kaarticsivaraam91196%40gmail.com
In-Reply-To: <0102015d7b021c6c-8741d523-c7d7-4be5-923a-cd4a925842a0-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.
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>
---
 Sending this patch to the correct thread. I apologise if this
 seems reduntant. I'm having hard time keeping up with the patch-flow
 without 'send-email'!

 builtin/branch.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index a3bd2262b..59fedf085 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"))
-- 
2.14.0.rc1.434.g6eded367a


```

## Kaartic Sivaraam, 2017-08-21 13:36

Subject: [PATCH v2] branch: change the error messages to be more meaningful
Message-ID: <20170821133608.5652-1-kaarticsivaraam91196@gmail.com>
URL: https://gitlist.dev/e/20170821133608.5652-1-kaarticsivaraam91196%40gmail.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


```

## Kaartic Sivaraam, 2017-10-02 17:19

Subject: Re: [PATCH v2] branch: change the error messages to be more meaningful
Message-ID: <1506964786.3504.3.camel@gmail.com>
URL: https://gitlist.dev/e/1506964786.3504.3.camel%40gmail.com
In-Reply-To: <20170821133608.5652-1-kaarticsivaraam91196@gmail.com>

```
On Mon, 2017-08-21 at 19:06 +0530, Kaartic Sivaraam wrote:
> 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"))


I was recently searching to find the patches have gone missing in to
the void for no obvious reason and found this. Should I consider this
to be "Dropped" in terms of the "What's cooking" emails? or has this
just not received the required attention?

---
Kaartic

```

## Junio C Hamano, 2017-10-03 00:21

Subject: Re: [PATCH v2] branch: change the error messages to be more meaningful
Message-ID: <xmqqbmlpm67l.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqbmlpm67l.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <1506964786.3504.3.camel@gmail.com>

```
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> writes:

> I was recently searching to find the patches have gone missing in to
> the void for no obvious reason and found this. Should I consider this
> to be "Dropped" in terms of the "What's cooking" emails? or has this
> just not received the required attention?

I do not even recall what the patches did and if I thought what they
wanted to do made sense, so I wouldn't be surprised if I did not
pick them up, after seeing nobody's commenting on it.


```

## Kaartic Sivaraam, 2017-10-03 19:14

Subject: Re: [PATCH v2] branch: change the error messages to be more meaningful
Message-ID: <1507058081.7360.5.camel@gmail.com>
URL: https://gitlist.dev/e/1507058081.7360.5.camel%40gmail.com
In-Reply-To: <xmqqbmlpm67l.fsf@gitster.mtv.corp.google.com>

```
On Tue, 2017-10-03 at 09:21 +0900, Junio C Hamano wrote:
> Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> writes:
> 
> I do not even recall what the patches did and if I thought what they
> wanted to do made sense, 


I thought you did or may be I misinterpreted the following statement,


On Thursday 17 August 2017 12:58 AM, Junio C Hamano wrote:
> I do not find the s/branch/parameter/ too bad (although I would have
> said "arguments" instead).
>

I interpreted the "not .. too bad" as a "it makes little sense". So,
pinged the thread.

---
Kaartic

```

## Junio C Hamano, 2017-10-04 04:11

Subject: Re: [PATCH v2] branch: change the error messages to be more meaningful
Message-ID: <xmqqwp4beemb.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqwp4beemb.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <1507058081.7360.5.camel@gmail.com>

```
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> writes:

> I interpreted the "not .. too bad" as a "it makes little sense". So,
> pinged the thread.

Thanks.  I think what the patch does (sort of) makes sense.  

It is a bit dissapointing that we do not need to touch tests, as it
indicates that the logic to diagnose extra arguments as an error has
no coverage.

```

## Kaartic Sivaraam, 2017-10-04 12:46

Subject: Re: [PATCH v2] branch: change the error messages to be more meaningful
Message-ID: <1507121174.2245.3.camel@gmail.com>
URL: https://gitlist.dev/e/1507121174.2245.3.camel%40gmail.com
In-Reply-To: <xmqqwp4beemb.fsf@gitster.mtv.corp.google.com>

```
On Wed, 2017-10-04 at 13:11 +0900, Junio C Hamano wrote:
> 
> It is a bit dissapointing that we do not need to touch tests, as it
> indicates that the logic to diagnose extra arguments as an error has
> no coverage.

Even if there were tests I don't think they would have needed any
updation as most of the tests (at least those that I came across) that
check for failure seem not to be checking for what error message gets
printed. They seem to test only if the command fails (using
test_must_fail in most cases, I guess).

Moreover, as a consequence of my assumption that the tests don't check
for the error messages themselves; I haven't even thought of checking
whether the tests or the travis-ci build succeeded as a consequence of
my patches that touch "only" the error messages!

---
Kaartic

```

## Junio C Hamano, 2017-10-05 01:13

Subject: Re: [PATCH v2] branch: change the error messages to be more meaningful
Message-ID: <xmqqmv569z25.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqmv569z25.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <1507121174.2245.3.camel@gmail.com>

```
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> writes:

> Moreover, as a consequence of my assumption that the tests don't check
> for the error messages themselves; I haven't even thought of checking
> whether the tests or the travis-ci build succeeded as a consequence of
> my patches that touch "only" the error messages!

That's a bad thing, right?

```

## Kaartic Sivaraam, 2017-10-05 12:13

Subject: Re: [PATCH v2] branch: change the error messages to be more meaningful
Message-ID: <1507205634.2364.2.camel@gmail.com>
URL: https://gitlist.dev/e/1507205634.2364.2.camel%40gmail.com
In-Reply-To: <xmqqmv569z25.fsf@gitster.mtv.corp.google.com>

```
On Thu, 2017-10-05 at 10:13 +0900, Junio C Hamano wrote:
> Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> writes:
> 
> > Moreover, as a consequence of my assumption that the tests don't check
> > for the error messages themselves; I haven't even thought of checking
> > whether the tests or the travis-ci build succeeded as a consequence of
> > my patches that touch "only" the error messages!
> 
> That's a bad thing, right?

Might be, but my assumption seems to held at least until now for the
two or three patches that I have sent that touch "only" the error
messages (I haven't received emails from anyone shouting at me that the
build fails as a consequence of one such patches).

The build status for this patch can be found at [1]. Supporting my
assumption, it passed too.

That said, you don't have to worry a lot about this. I'll come over my
laziness and check if the travis-ci build passes for such patches in
the future :-)

[1]: https://travis-ci.org/sivaraam/git/builds/276222235

---
Kaartic


```
