git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] push: change needlessly ambiguous example in error
@ 2018-11-13 20:39 Ævar Arnfjörð Bjarmason
  2018-11-13 21:37 ` Matthieu Moy
  0 siblings, 1 reply; 6+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-11-13 20:39 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Matthieu Moy,
	Ævar Arnfjörð Bjarmason

Change an example push added in b55e677522 ("push: introduce new
push.default mode "simple"", 2012-04-24) to always mean the same thing
whether the current setting happens to be "simple" or not.

This error is only emitted under "simple", but message is explaining
to the user that they can get two sorts of different behaviors by
these two invocations.

Let's use "git push <remote> HEAD" which always means push the current
branch name to that remote, instead of "git push <remote>
<current-branch-name>" which will do that under "simple", but is not
guaranteed to do under "upstream".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/push.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/push.c b/builtin/push.c
index d09a42062c..8bb8a0849b 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -173,10 +173,10 @@ static NORETURN int die_push_simple(struct branch *branch, struct remote *remote
 	      "\n"
 	      "To push to the branch of the same name on the remote, use\n"
 	      "\n"
-	      "    git push %s %s\n"
+	      "    git push %s HEAD\n"
 	      "%s"),
 	    remote->name, short_upstream,
-	    remote->name, branch->name, advice_maybe);
+	    remote->name, advice_maybe);
 }
 
 static const char message_detached_head_die[] =
-- 
2.19.1.1182.g4ecb1133ce


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

* Re: [PATCH] push: change needlessly ambiguous example in error
  2018-11-13 20:39 [PATCH] push: change needlessly ambiguous example in error Ævar Arnfjörð Bjarmason
@ 2018-11-13 21:37 ` Matthieu Moy
  2018-11-13 21:55   ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 6+ messages in thread
From: Matthieu Moy @ 2018-11-13 21:37 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: Git Mailing List, Junio C Hamano

Ævar Arnfjörð Bjarmason" <avarab@gmail.com> wrote:

> Let's use "git push <remote> HEAD" which always means push the current
> branch name to that remote, instead of "git push <remote>
> <current-branch-name>" which will do that under "simple", but is not
> guaranteed to do under "upstream".

Probably a good idea indeed.

One potential objection though: I think many people know

  git push origin master

(not that they necessarily understand it, but I've seen many people talking
or asking questions about what "origin master" is)

This "git push origin HEAD" is IMHO less common. It may confuse users.
Or users may learn it and be happy thanks to your message. I don't know.

-- 
Matthieu Moy
https://matthieu-moy.fr/

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

* Re: [PATCH] push: change needlessly ambiguous example in error
  2018-11-13 21:37 ` Matthieu Moy
@ 2018-11-13 21:55   ` Ævar Arnfjörð Bjarmason
  2018-11-14  4:32     ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-11-13 21:55 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Git Mailing List, Junio C Hamano


On Tue, Nov 13 2018, Matthieu Moy wrote:

> Ævar Arnfjörð Bjarmason" <avarab@gmail.com> wrote:
>
>> Let's use "git push <remote> HEAD" which always means push the current
>> branch name to that remote, instead of "git push <remote>
>> <current-branch-name>" which will do that under "simple", but is not
>> guaranteed to do under "upstream".
>
> Probably a good idea indeed.
>
> One potential objection though: I think many people know
>
>   git push origin master
>
> (not that they necessarily understand it, but I've seen many people talking
> or asking questions about what "origin master" is)
>
> This "git push origin HEAD" is IMHO less common. It may confuse users.
> Or users may learn it and be happy thanks to your message. I don't know.

I was hoping for the latter. I'm slightly embarrassed to say that for
the entire time I've been using git I've been doing:

    # on branch 'topic'
    git push origin topic:topic

Where 'topic' is a tracking branch of 'origin/master' (I use
push.default=upstream). I only recently discovered that I could push to
'HEAD" to do the same thing. So one ulterior motive is to make that more
prominent.

I was going to add a hint on such invocations saying "you can just use
HEAD", but have not found the relevant code yet after some brief
searching...

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

* Re: [PATCH] push: change needlessly ambiguous example in error
  2018-11-13 21:55   ` Ævar Arnfjörð Bjarmason
@ 2018-11-14  4:32     ` Junio C Hamano
  2018-11-14  6:36       ` Matthieu Moy
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2018-11-14  4:32 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: Matthieu Moy, Git Mailing List

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

>> This "git push origin HEAD" is IMHO less common. It may confuse users.
>> Or users may learn it and be happy thanks to your message. I don't know.
>
> I was hoping for the latter. I'm slightly embarrassed to say that for
> the entire time I've been using git I've been doing:
>
>     # on branch 'topic'
>     git push origin topic:topic
>
> Where 'topic' is a tracking branch of 'origin/master' (I use
> push.default=upstream). I only recently discovered that I could push to
> 'HEAD" to do the same thing. So one ulterior motive is to make that more
> prominent.

Personally I do not think you should feel embarrassed at all.  I
didn't know it myself, and I do not recall designing such a
behaviour, so I would not be surprised if it is merely what the code
right now happens to do.  FWIW, I would have expected that a "git
push origin HEAD" when HEAD is a symref to a branch 'x' would behave
as if "git push origin x" were given, going through the usual
simple/upstream/matching etc. dance.

Do we consider the current behaviour useful?  Is it documented
already and widely known?  If the answers are yes/no, of course we
should document it, but if they are no/no, it may not be a bad idea
to deprecate it and replace it with a saner version (i.e. deref HEAD
to branch name and behave the same way as pushing that branch) over
time.



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

* Re: [PATCH] push: change needlessly ambiguous example in error
  2018-11-14  4:32     ` Junio C Hamano
@ 2018-11-14  6:36       ` Matthieu Moy
  2018-11-14  8:16         ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Matthieu Moy @ 2018-11-14  6:36 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Ævar Arnfjörð Bjarmason, Git Mailing List

"Junio C Hamano" <gitster@pobox.com> wrote:

> > Where 'topic' is a tracking branch of 'origin/master' (I use
> > push.default=upstream). I only recently discovered that I could push to
> > 'HEAD" to do the same thing. So one ulterior motive is to make that more
> > prominent.
[...]
> Do we consider the current behaviour useful? Is it documented

Yes, since 1750783 (Documentation: more git push examples, 2009-01-26).

It may be an accident that the doc says "to the same name on the
remote." since it predates the introduction of push.default, but it
does say so and it's the actual behavior.

> already and widely known?

https://stackoverflow.com/questions/14031970/git-push-current-branch-shortcut

458 votes for the answer suggesting it.

-- 
Matthieu Moy
https://matthieu-moy.fr/

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

* Re: [PATCH] push: change needlessly ambiguous example in error
  2018-11-14  6:36       ` Matthieu Moy
@ 2018-11-14  8:16         ` Junio C Hamano
  0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2018-11-14  8:16 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Ævar Arnfjörð Bjarmason, Git Mailing List

Matthieu Moy <git@matthieu-moy.fr> writes:

> "Junio C Hamano" <gitster@pobox.com> wrote:
>
>> > Where 'topic' is a tracking branch of 'origin/master' (I use
>> > push.default=upstream). I only recently discovered that I could push to
>> > 'HEAD" to do the same thing. So one ulterior motive is to make that more
>> > prominent.
> [...]
>> Do we consider the current behaviour useful? Is it documented
>
> Yes, since 1750783 (Documentation: more git push examples, 2009-01-26).
>
> It may be an accident that the doc says "to the same name on the
> remote." since it predates the introduction of push.default, but it
> does say so and it's the actual behavior.
>
>> already and widely known?
>
> https://stackoverflow.com/questions/14031970/git-push-current-branch-shortcut
>
> 458 votes for the answer suggesting it.

OK, that probably is good enough reason to keep the current
behaviour and convince ourselves that there is nothing that needs to
be done further on this topic.

Thanks.

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

end of thread, other threads:[~2018-11-14  8:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-13 20:39 [PATCH] push: change needlessly ambiguous example in error Ævar Arnfjörð Bjarmason
2018-11-13 21:37 ` Matthieu Moy
2018-11-13 21:55   ` Ævar Arnfjörð Bjarmason
2018-11-14  4:32     ` Junio C Hamano
2018-11-14  6:36       ` Matthieu Moy
2018-11-14  8:16         ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).