All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] branch: fix funny-sounding error message
@ 2015-05-02  3:12 Alex Henrie
  2015-05-03 23:54 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Alex Henrie @ 2015-05-02  3:12 UTC (permalink / raw)
  To: gitster, pclouds, git; +Cc: Alex Henrie

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
---
 builtin/branch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index 1d15037..c0b4bae 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -972,7 +972,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 
 		if (!branch) {
 			if (!argc || !strcmp(argv[0], "HEAD"))
-				die(_("could not set upstream of HEAD to %s when "
+				die(_("could not set upstream of HEAD to %s because "
 				      "it does not point to any branch."),
 				    new_upstream);
 			die(_("no such branch '%s'"), argv[0]);
-- 
2.3.7

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] branch: fix funny-sounding error message
  2015-05-02  3:12 [PATCH] branch: fix funny-sounding error message Alex Henrie
@ 2015-05-03 23:54 ` Junio C Hamano
  2015-05-05 19:42   ` Alex Henrie
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2015-05-03 23:54 UTC (permalink / raw)
  To: Alex Henrie; +Cc: pclouds, git

Alex Henrie <alexhenrie24@gmail.com> writes:

> Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
> ---
>  builtin/branch.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/branch.c b/builtin/branch.c
> index 1d15037..c0b4bae 100644
> --- a/builtin/branch.c
> +++ b/builtin/branch.c
> @@ -972,7 +972,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
>  
>  		if (!branch) {
>  			if (!argc || !strcmp(argv[0], "HEAD"))
> -				die(_("could not set upstream of HEAD to %s when "
> +				die(_("could not set upstream of HEAD to %s because "
>  				      "it does not point to any branch."),
>  				    new_upstream);
>  			die(_("no such branch '%s'"), argv[0]);

Thanks.

To me neither sounds so funny, but both sound somewhat awkward,
primarily because it is unclear in the first reading what "it" in
"it does not point at any branch" refers to.

Perhaps if you explain in the log message to illustrate why you
found it funny (and the update text is not), it might help, e.g.

    "git branch", ran with <this and that options>, when the current
    branch is <in what state>, dies with

    	fatal: could not set upstream of HEAD to frotz when it does not
    	point to any branch.

    which is funny <because of such and such reasons>.  Saying "because"
    makes it <better beause of such and such reasons>.

I suspect that this message is about a nonsense attempt to set an
upstream for a detached HEAD perhaps?  Then

    fatal: cannot set upstream for a detached HEAD

may be shorter and more directly points at the root cause of the
error?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] branch: fix funny-sounding error message
  2015-05-03 23:54 ` Junio C Hamano
@ 2015-05-05 19:42   ` Alex Henrie
  2015-05-05 21:58     ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Alex Henrie @ 2015-05-05 19:42 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: pclouds, Git mailing list

2015-05-03 17:54 GMT-06:00 Junio C Hamano <gitster@pobox.com>:
> Alex Henrie <alexhenrie24@gmail.com> writes:
>
>> Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
>> ---
>>  builtin/branch.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/builtin/branch.c b/builtin/branch.c
>> index 1d15037..c0b4bae 100644
>> --- a/builtin/branch.c
>> +++ b/builtin/branch.c
>> @@ -972,7 +972,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
>>
>>               if (!branch) {
>>                       if (!argc || !strcmp(argv[0], "HEAD"))
>> -                             die(_("could not set upstream of HEAD to %s when "
>> +                             die(_("could not set upstream of HEAD to %s because "
>>                                     "it does not point to any branch."),
>>                                   new_upstream);
>>                       die(_("no such branch '%s'"), argv[0]);
>
> Thanks.
>
> To me neither sounds so funny, but both sound somewhat awkward,
> primarily because it is unclear in the first reading what "it" in
> "it does not point at any branch" refers to.
>
> Perhaps if you explain in the log message to illustrate why you
> found it funny (and the update text is not), it might help, e.g.
>
>     "git branch", ran with <this and that options>, when the current
>     branch is <in what state>, dies with
>
>         fatal: could not set upstream of HEAD to frotz when it does not
>         point to any branch.
>
>     which is funny <because of such and such reasons>.  Saying "because"
>     makes it <better beause of such and such reasons>.
>
> I suspect that this message is about a nonsense attempt to set an
> upstream for a detached HEAD perhaps?  Then
>
>     fatal: cannot set upstream for a detached HEAD
>
> may be shorter and more directly points at the root cause of the
> error?

I don't really understand what this code is doing. It just sounds
funny to use "when" to join a phrase in the past tense with a phrase
in the present tense.

This error message can be triggered by running `git branch
--set-upstream-to=origin/master` from a detached head. But if running
from a detached head is the only way to trigger the error message, why
does the code use strcmp instead of if (detached) { ... } as other
code in that function does?

Also, I missed the complementary error message "could not unset
upstream of HEAD when it does not point to any branch." We should
either change the "when" to a "because" in the second message too or
rewrite both of these messages entirely.

-Alex

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] branch: fix funny-sounding error message
  2015-05-05 19:42   ` Alex Henrie
@ 2015-05-05 21:58     ` Junio C Hamano
  2015-05-05 23:06       ` Jeff King
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2015-05-05 21:58 UTC (permalink / raw)
  To: Alex Henrie; +Cc: pclouds, Git mailing list

Alex Henrie <alexhenrie24@gmail.com> writes:

> 2015-05-03 17:54 GMT-06:00 Junio C Hamano <gitster@pobox.com>:
>> Alex Henrie <alexhenrie24@gmail.com> writes:
>>
>>> Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
>>> ---
>>>  builtin/branch.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/builtin/branch.c b/builtin/branch.c
>>> index 1d15037..c0b4bae 100644
>>> --- a/builtin/branch.c
>>> +++ b/builtin/branch.c
>>> @@ -972,7 +972,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
>>>
>>>               if (!branch) {
>>>                       if (!argc || !strcmp(argv[0], "HEAD"))
>>> -                             die(_("could not set upstream of HEAD to %s when "
>>> +                             die(_("could not set upstream of HEAD to %s because "
>>>                                     "it does not point to any branch."),
>>>                                   new_upstream);
>>>                       die(_("no such branch '%s'"), argv[0]);
>>
>> Thanks.
>>
>> To me neither sounds so funny, but both sound somewhat awkward,
>> primarily because it is unclear in the first reading what "it" in
>> "it does not point at any branch" refers to.
>>
>> Perhaps if you explain in the log message to illustrate why you
>> found it funny (and the update text is not), it might help, e.g.
>>
>>     "git branch", ran with <this and that options>, when the current
>>     branch is <in what state>, dies with
>>
>>         fatal: could not set upstream of HEAD to frotz when it does not
>>         point to any branch.
>>
>>     which is funny <because of such and such reasons>.  Saying "because"
>>     makes it <better beause of such and such reasons>.
>>
>> I suspect that this message is about a nonsense attempt to set an
>> upstream for a detached HEAD perhaps?  Then
>>
>>     fatal: cannot set upstream for a detached HEAD
>>
>> may be shorter and more directly points at the root cause of the
>> error?
>
> I don't really understand what this code is doing.

To be honest, I didn't know what was going on at the first glance,
either.  AND I felt that it is unfair to say "when" was funny,
without understanding what it is trying to say---perhaps it may be
implying that upstream of HEAD could be set to "%s" when "it" does
point at some branch, or something, even though, as I said, "it" is
unclear without really knowing the context.

I think this "branch is NULL" condition is when an earlier call to
branch_get() returned a NULL, and _one_ way to make that happen is
to detach the HEAD.  There may be others, but I didn't check.

> This error message can be triggered by running `git branch
> --set-upstream-to=origin/master` from a detached head. But if running
> from a detached head is the only way to trigger the error message, why
> does the code use strcmp instead of if (detached) { ... } as other
> code in that function does?

The 'detached' merely is "Is the _current_ HEAD detached?", not "Is
the branch the user asked us to do something about the detached
HEAD?", I think.

If you are getting a NULL out of branch_get() but the user did
"branch -u foo thisbranch", then that is an indication that we
shouldn't be saying that "nono, detached HEAD will never have its
own upstream", because that is not what the user asked us to do.  So
"no argument (implying, we defaulted to HEAD) or the argument is
spelled HEAD" I think is the right thing to check.

And the other error message "no such branch" hints (again, I didn't
follow the codepath) that we may get a NULL in branch if you did
"git branch -u foo no-such-branch".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] branch: fix funny-sounding error message
  2015-05-05 21:58     ` Junio C Hamano
@ 2015-05-05 23:06       ` Jeff King
  0 siblings, 0 replies; 6+ messages in thread
From: Jeff King @ 2015-05-05 23:06 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Alex Henrie, pclouds, Git mailing list

On Tue, May 05, 2015 at 02:58:24PM -0700, Junio C Hamano wrote:

> I think this "branch is NULL" condition is when an earlier call to
> branch_get() returned a NULL, and _one_ way to make that happen is
> to detach the HEAD.  There may be others, but I didn't check.

FWIW, since I have just been looking through the branch code,
branch_get() should only return NULL when:

  1. We passed NULL or "HEAD" to it (i.e., we asked for the current branch). If
     you ask for a branch by name, you will always get a non-NULL return,
     even if that branch does not exist.

  2. There is no current branch (i.e., a detached HEAD).

I think the "no such branch" error message here:

               if (!branch) {
                        if (!argc || !strcmp(argv[0], "HEAD"))
                                die(_("could not unset upstream of HEAD when "
                                      "it does not point to any branch."));
			die(_("no such branch '%s'"), argv[0]);
	       }

cannot actually be triggered (and I double-checked that the test suite
does not trigger it by replacing it with "exit(141)", which should cause
even test_must_fail to complain).

-Peff

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] branch: fix funny-sounding error message
@ 2015-04-02 21:27 Alex Henrie
  0 siblings, 0 replies; 6+ messages in thread
From: Alex Henrie @ 2015-04-02 21:27 UTC (permalink / raw)
  To: gitster, pclouds, git; +Cc: Alex Henrie

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
---
 builtin/branch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index 1d15037..c0b4bae 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -972,7 +972,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 
 		if (!branch) {
 			if (!argc || !strcmp(argv[0], "HEAD"))
-				die(_("could not set upstream of HEAD to %s when "
+				die(_("could not set upstream of HEAD to %s because "
 				      "it does not point to any branch."),
 				    new_upstream);
 			die(_("no such branch '%s'"), argv[0]);
-- 
2.3.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-05-05 23:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-02  3:12 [PATCH] branch: fix funny-sounding error message Alex Henrie
2015-05-03 23:54 ` Junio C Hamano
2015-05-05 19:42   ` Alex Henrie
2015-05-05 21:58     ` Junio C Hamano
2015-05-05 23:06       ` Jeff King
  -- strict thread matches above, loose matches on Subject: below --
2015-04-02 21:27 Alex Henrie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.