{"thread":{"id":"49825","subject":"[PATCH] push: change needlessly ambiguous example in error","startedAt":"2018-11-13T20:39:23Z","lastAt":"2018-11-14T08:16:21Z","messageCount":6,"participants":["Ævar Arnfjörð Bjarmason","Matthieu Moy","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"363216","messageId":"20181113203909.30740-1-avarab@gmail.com","threadId":"49825","inReplyTo":null,"subject":"[PATCH] push: change needlessly ambiguous example in error","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-11-13T20:39:09Z","receivedAt":"2018-11-13T20:39:23Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change an example push added in b55e677522 (\"push: introduce new\npush.default mode \"simple\"\", 2012-04-24) to always mean the same thing\nwhether the current setting happens to be \"simple\" or not.\n\nThis error is only emitted under \"simple\", but message is explaining\nto the user that they can get two sorts of different behaviors by\nthese two invocations.\n\nLet's use \"git push <remote> HEAD\" which always means push the current\nbranch name to that remote, instead of \"git push <remote>\n<current-branch-name>\" which will do that under \"simple\", but is not\nguaranteed to do under \"upstream\".\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/push.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/push.c b/builtin/push.c\nindex d09a42062c..8bb8a0849b 100644\n--- a/builtin/push.c\n+++ b/builtin/push.c\n@@ -173,10 +173,10 @@ static NORETURN int die_push_simple(struct branch *branch, struct remote *remote\n \t      \"\\n\"\n \t      \"To push to the branch of the same name on the remote, use\\n\"\n \t      \"\\n\"\n-\t      \"    git push %s %s\\n\"\n+\t      \"    git push %s HEAD\\n\"\n \t      \"%s\"),\n \t    remote->name, short_upstream,\n-\t    remote->name, branch->name, advice_maybe);\n+\t    remote->name, advice_maybe);\n }\n \n static const char message_detached_head_die[] =\n-- \n2.19.1.1182.g4ecb1133ce\n\n"},{"id":"363222","messageId":"87wopg1w2z.fsf@evledraar.gmail.com","threadId":"49825","inReplyTo":"1615698920.2718456.1542145071499.JavaMail.zimbra@matthieu-moy.fr","subject":"Re: [PATCH] push: change needlessly ambiguous example in error","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-11-13T21:55:32Z","receivedAt":"2018-11-13T21:55:38Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Tue, Nov 13 2018, Matthieu Moy wrote:\n\n> Ævar Arnfjörð Bjarmason\" <avarab@gmail.com> wrote:\n>\n>> Let's use \"git push <remote> HEAD\" which always means push the current\n>> branch name to that remote, instead of \"git push <remote>\n>> <current-branch-name>\" which will do that under \"simple\", but is not\n>> guaranteed to do under \"upstream\".\n>\n> Probably a good idea indeed.\n>\n> One potential objection though: I think many people know\n>\n>   git push origin master\n>\n> (not that they necessarily understand it, but I've seen many people talking\n> or asking questions about what \"origin master\" is)\n>\n> This \"git push origin HEAD\" is IMHO less common. It may confuse users.\n> Or users may learn it and be happy thanks to your message. I don't know.\n\nI was hoping for the latter. I'm slightly embarrassed to say that for\nthe entire time I've been using git I've been doing:\n\n    # on branch 'topic'\n    git push origin topic:topic\n\nWhere 'topic' is a tracking branch of 'origin/master' (I use\npush.default=upstream). I only recently discovered that I could push to\n'HEAD\" to do the same thing. So one ulterior motive is to make that more\nprominent.\n\nI was going to add a hint on such invocations saying \"you can just use\nHEAD\", but have not found the relevant code yet after some brief\nsearching...\n"},{"id":"363223","messageId":"1615698920.2718456.1542145071499.JavaMail.zimbra@matthieu-moy.fr","threadId":"49825","inReplyTo":"20181113203909.30740-1-avarab@gmail.com","subject":"Re: [PATCH] push: change needlessly ambiguous example in error","fromName":"Matthieu Moy","fromEmail":"git@matthieu-moy.fr","sentAt":"2018-11-13T21:37:51Z","receivedAt":"2018-11-13T22:03:42Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Ævar Arnfjörð Bjarmason\" <avarab@gmail.com> wrote:\n\n> Let's use \"git push <remote> HEAD\" which always means push the current\n> branch name to that remote, instead of \"git push <remote>\n> <current-branch-name>\" which will do that under \"simple\", but is not\n> guaranteed to do under \"upstream\".\n\nProbably a good idea indeed.\n\nOne potential objection though: I think many people know\n\n  git push origin master\n\n(not that they necessarily understand it, but I've seen many people talking\nor asking questions about what \"origin master\" is)\n\nThis \"git push origin HEAD\" is IMHO less common. It may confuse users.\nOr users may learn it and be happy thanks to your message. I don't know.\n\n-- \nMatthieu Moy\nhttps://matthieu-moy.fr/\n"},{"id":"363308","messageId":"xmqqva50p9c6.fsf@gitster-ct.c.googlers.com","threadId":"49825","inReplyTo":"87wopg1w2z.fsf@evledraar.gmail.com","subject":"Re: [PATCH] push: change needlessly ambiguous example in error","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-14T04:32:57Z","receivedAt":"2018-11-14T04:33:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n>> This \"git push origin HEAD\" is IMHO less common. It may confuse users.\n>> Or users may learn it and be happy thanks to your message. I don't know.\n>\n> I was hoping for the latter. I'm slightly embarrassed to say that for\n> the entire time I've been using git I've been doing:\n>\n>     # on branch 'topic'\n>     git push origin topic:topic\n>\n> Where 'topic' is a tracking branch of 'origin/master' (I use\n> push.default=upstream). I only recently discovered that I could push to\n> 'HEAD\" to do the same thing. So one ulterior motive is to make that more\n> prominent.\n\nPersonally I do not think you should feel embarrassed at all.  I\ndidn't know it myself, and I do not recall designing such a\nbehaviour, so I would not be surprised if it is merely what the code\nright now happens to do.  FWIW, I would have expected that a \"git\npush origin HEAD\" when HEAD is a symref to a branch 'x' would behave\nas if \"git push origin x\" were given, going through the usual\nsimple/upstream/matching etc. dance.\n\nDo we consider the current behaviour useful?  Is it documented\nalready and widely known?  If the answers are yes/no, of course we\nshould document it, but if they are no/no, it may not be a bad idea\nto deprecate it and replace it with a saner version (i.e. deref HEAD\nto branch name and behave the same way as pushing that branch) over\ntime.\n\n\n"},{"id":"363321","messageId":"850526490.3010891.1542177378884.JavaMail.zimbra@matthieu-moy.fr","threadId":"49825","inReplyTo":"xmqqva50p9c6.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH] push: change needlessly ambiguous example in error","fromName":"Matthieu Moy","fromEmail":"git@matthieu-moy.fr","sentAt":"2018-11-14T06:36:18Z","receivedAt":"2018-11-14T06:36:28Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"\"Junio C Hamano\" <gitster@pobox.com> wrote:\n\n> > Where 'topic' is a tracking branch of 'origin/master' (I use\n> > push.default=upstream). I only recently discovered that I could push to\n> > 'HEAD\" to do the same thing. So one ulterior motive is to make that more\n> > prominent.\n[...]\n> Do we consider the current behaviour useful? Is it documented\n\nYes, since 1750783 (Documentation: more git push examples, 2009-01-26).\n\nIt may be an accident that the doc says \"to the same name on the\nremote.\" since it predates the introduction of push.default, but it\ndoes say so and it's the actual behavior.\n\n> already and widely known?\n\nhttps://stackoverflow.com/questions/14031970/git-push-current-branch-shortcut\n\n458 votes for the answer suggesting it.\n\n-- \nMatthieu Moy\nhttps://matthieu-moy.fr/\n"},{"id":"363335","messageId":"xmqqsh04m5v3.fsf@gitster-ct.c.googlers.com","threadId":"49825","inReplyTo":"850526490.3010891.1542177378884.JavaMail.zimbra@matthieu-moy.fr","subject":"Re: [PATCH] push: change needlessly ambiguous example in error","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-14T08:16:16Z","receivedAt":"2018-11-14T08:16:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <git@matthieu-moy.fr> writes:\n\n> \"Junio C Hamano\" <gitster@pobox.com> wrote:\n>\n>> > Where 'topic' is a tracking branch of 'origin/master' (I use\n>> > push.default=upstream). I only recently discovered that I could push to\n>> > 'HEAD\" to do the same thing. So one ulterior motive is to make that more\n>> > prominent.\n> [...]\n>> Do we consider the current behaviour useful? Is it documented\n>\n> Yes, since 1750783 (Documentation: more git push examples, 2009-01-26).\n>\n> It may be an accident that the doc says \"to the same name on the\n> remote.\" since it predates the introduction of push.default, but it\n> does say so and it's the actual behavior.\n>\n>> already and widely known?\n>\n> https://stackoverflow.com/questions/14031970/git-push-current-branch-shortcut\n>\n> 458 votes for the answer suggesting it.\n\nOK, that probably is good enough reason to keep the current\nbehaviour and convince ourselves that there is nothing that needs to\nbe done further on this topic.\n\nThanks.\n"}]}