{"thread":{"id":"32121","subject":"[PATCH] status: add advice on how to push/pull to tracking branch","startedAt":"2012-11-15T10:45:00Z","lastAt":"2012-11-16T09:27:03Z","messageCount":5,"participants":["Matthieu Moy","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"203282","messageId":"1352976300-20159-1-git-send-email-Matthieu.Moy@imag.fr","threadId":"32121","inReplyTo":null,"subject":"[PATCH] status: add advice on how to push/pull to tracking branch","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2012-11-15T10:45:00Z","receivedAt":"2012-11-15T10:45:00Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\nI thought this was obvious enough not to deserve an advice, but a\ncolleague of mine had troubles with \"commited but not pushed\" changes.\nMaybe an additional advice would have helped. After all, it's an\nadvice, and can be deactivated ...\n\n remote.c                   | 13 ++++++++++---\n t/t2020-checkout-detach.sh |  1 +\n 2 files changed, 11 insertions(+), 3 deletions(-)\n\ndiff --git a/remote.c b/remote.c\nindex 04fd9ea..9c19689 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1627,13 +1627,15 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)\n \n \tbase = branch->merge[0]->dst;\n \tbase = shorten_unambiguous_ref(base, 0);\n-\tif (!num_theirs)\n+\tif (!num_theirs) {\n \t\tstrbuf_addf(sb,\n \t\t\tQ_(\"Your branch is ahead of '%s' by %d commit.\\n\",\n \t\t\t   \"Your branch is ahead of '%s' by %d commits.\\n\",\n \t\t\t   num_ours),\n \t\t\tbase, num_ours);\n-\telse if (!num_ours)\n+\t\tstrbuf_addf(sb,\n+\t\t\t_(\"  (use \\\"git push\\\" to publish your local commits)\\n\"));\n+\t} else if (!num_ours) {\n \t\tstrbuf_addf(sb,\n \t\t\tQ_(\"Your branch is behind '%s' by %d commit, \"\n \t\t\t       \"and can be fast-forwarded.\\n\",\n@@ -1641,7 +1643,9 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)\n \t\t\t       \"and can be fast-forwarded.\\n\",\n \t\t\t   num_theirs),\n \t\t\tbase, num_theirs);\n-\telse\n+\t\tstrbuf_addf(sb,\n+\t\t\t_(\"  (use \\\"git pull\\\" to update your local branch)\\n\"));\n+\t} else {\n \t\tstrbuf_addf(sb,\n \t\t\tQ_(\"Your branch and '%s' have diverged,\\n\"\n \t\t\t       \"and have %d and %d different commit each, \"\n@@ -1651,6 +1655,9 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)\n \t\t\t       \"respectively.\\n\",\n \t\t\t   num_theirs),\n \t\t\tbase, num_ours, num_theirs);\n+\t\tstrbuf_addf(sb,\n+\t\t\t_(\"  (use \\\"git pull\\\" to merge the remote branch into yours)\\n\"));\n+\t}\n \treturn 1;\n }\n \ndiff --git a/t/t2020-checkout-detach.sh b/t/t2020-checkout-detach.sh\nindex 8100537..5d68729 100755\n--- a/t/t2020-checkout-detach.sh\n+++ b/t/t2020-checkout-detach.sh\n@@ -151,6 +151,7 @@ test_expect_success 'checkout does not warn leaving reachable commit' '\n \n cat >expect <<'EOF'\n Your branch is behind 'master' by 1 commit, and can be fast-forwarded.\n+  (use \"git pull\" to update your local branch)\n EOF\n test_expect_success 'tracking count is accurate after orphan check' '\n \treset &&\n-- \n1.8.0.319.g8abfee4\n"},{"id":"203303","messageId":"7vr4nu92hm.fsf@alter.siamese.dyndns.org","threadId":"32121","inReplyTo":"1352976300-20159-1-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [PATCH] status: add advice on how to push/pull to tracking branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-11-15T17:53:41Z","receivedAt":"2012-11-15T17:53:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@imag.fr> writes:\n\n> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n> ---\n> I thought this was obvious enough not to deserve an advice, but a\n> colleague of mine had troubles with \"commited but not pushed\" changes.\n> Maybe an additional advice would have helped. After all, it's an\n> advice, and can be deactivated ...\n>\n>  remote.c                   | 13 ++++++++++---\n>  t/t2020-checkout-detach.sh |  1 +\n>  2 files changed, 11 insertions(+), 3 deletions(-)\n>\n> diff --git a/remote.c b/remote.c\n> index 04fd9ea..9c19689 100644\n> --- a/remote.c\n> +++ b/remote.c\n> @@ -1627,13 +1627,15 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)\n>  \n>  \tbase = branch->merge[0]->dst;\n>  \tbase = shorten_unambiguous_ref(base, 0);\n> -\tif (!num_theirs)\n> +\tif (!num_theirs) {\n>  \t\tstrbuf_addf(sb,\n>  \t\t\tQ_(\"Your branch is ahead of '%s' by %d commit.\\n\",\n>  \t\t\t   \"Your branch is ahead of '%s' by %d commits.\\n\",\n>  \t\t\t   num_ours),\n>  \t\t\tbase, num_ours);\n> -\telse if (!num_ours)\n> +\t\tstrbuf_addf(sb,\n> +\t\t\t_(\"  (use \\\"git push\\\" to publish your local commits)\\n\"));\n> +\t} else if (!num_ours) {\n\nThe message should make it clear that the two words in double quotes\nonly hint what command is used to \"publish your local commits\" and\nnot to be taken as literal \"here is what you exactly would type\",\nbut I do not think that is what I would get from this if I were a\ntotal newbie who would need this advise.\n\nIt is even more true given that this is showing an arbitrary, and\nmore likely than not a non-current branch, especially with the\nrecent move from \"matching\" to \"simple\" where a naive use of \"git\npush\" is to push the branch that is currently checked out and no\nother branches.\n\n\tsee 'git push --help' to learn how to publish your local commits\n\nmight be more appropriate.\n\n> +\t\tstrbuf_addf(sb,\n> +\t\t\t_(\"  (use \\\"git pull\\\" to update your local branch)\\n\"));\n> +\t} else {\n\nLikewise, and the non-currentness of the branch being described is\neven worse in here, as unlike \"git push\" that can still be used to\npush a non-current branch, \"git pull\" is never to be used to update\nlocal branch that is not current, which means the advice must mention\n\"git checkout\" somewhere.\n"},{"id":"203313","messageId":"vpqmwyid59i.fsf@grenoble-inp.fr","threadId":"32121","inReplyTo":"7vr4nu92hm.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] status: add advice on how to push/pull to tracking branch","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-11-15T19:40:09Z","receivedAt":"2012-11-15T19:40:09Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>> -\tif (!num_theirs)\n>> +\tif (!num_theirs) {\n>>  \t\tstrbuf_addf(sb,\n>>  \t\t\tQ_(\"Your branch is ahead of '%s' by %d commit.\\n\",\n>>  \t\t\t   \"Your branch is ahead of '%s' by %d commits.\\n\",\n>>  \t\t\t   num_ours),\n>>  \t\t\tbase, num_ours);\n>> -\telse if (!num_ours)\n>> +\t\tstrbuf_addf(sb,\n>> +\t\t\t_(\"  (use \\\"git push\\\" to publish your local commits)\\n\"));\n>> +\t} else if (!num_ours) {\n>\n> The message should make it clear that the two words in double quotes\n> only hint what command is used to \"publish your local commits\" and\n> not to be taken as literal \"here is what you exactly would type\",\n> but I do not think that is what I would get from this if I were a\n> total newbie who would need this advise.\n>\n> It is even more true given that this is showing an arbitrary, and\n> more likely than not a non-current branch, especially with the\n> recent move from \"matching\" to \"simple\" where a naive use of \"git\n> push\" is to push the branch that is currently checked out and no\n> other branches.\n\nI don't understand what you mean by \"non-current\". If you mean a local\nbranch not pointed to by HEAD, then I don't understand the remark, as\nthe message is shown by \"git status\" (looking more closely, it is also\nshown by \"git checkout\", but after switching branch so also showing a\nmessage about the current branch) and precisely talks about the current\nbranch. If you mean that the upsteam branch has a name different from\nthe local one, then with \"push.default=simple\", argumentless \"git push\"\nwill fail and show a detailed explanation to the user, which I find\nacceptable.\n\nI can tweak the advice to show the full \"git push\" command with\npush.default=matching/current, but first, I'd like to understand your\nremark.\n\n>> +\t\tstrbuf_addf(sb,\n>> +\t\t\t_(\"  (use \\\"git pull\\\" to update your local branch)\\n\"));\n>> +\t} else {\n>\n> Likewise, and the non-currentness of the branch being described is\n> even worse in here, as unlike \"git push\" that can still be used to\n> push a non-current branch, \"git pull\" is never to be used to update\n> local branch that is not current, which means the advice must mention\n> \"git checkout\" somewhere.\n\nI understand this remark even less. We're showing a message about the\ncurrent branch and its upstream branch. In which case would \"git pull\"\nnot do the right thing?\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"203316","messageId":"7vmwyi8rjt.fsf@alter.siamese.dyndns.org","threadId":"32121","inReplyTo":"vpqmwyid59i.fsf@grenoble-inp.fr","subject":"Re: [PATCH] status: add advice on how to push/pull to tracking branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-11-15T21:49:58Z","receivedAt":"2012-11-15T21:49:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> I don't understand what you mean by \"non-current\". If you mean a local\n> branch not pointed to by HEAD, then I don't understand the remark, as\n> the message is shown by \"git status\" (looking more closely, it is also\n> shown by \"git checkout\", but after switching branch so also showing a\n> message about the current branch) and precisely talks about the current\n> branch.\n\nAh, Ok, I somehow thought that \"branch -v\" would also use this\ninformation, and/or during my absense this function from remote.c\ngot linked into \"git remote show\" ;-)\n\nSo it is not an issue right now, but we will have to worry about the\nmessaging when we start using this to describe a branch that is not\ncurrently checked out.\n"},{"id":"203334","messageId":"vpqy5i1c2zc.fsf@grenoble-inp.fr","threadId":"32121","inReplyTo":"7vmwyi8rjt.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] status: add advice on how to push/pull to tracking branch","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-11-16T09:27:03Z","receivedAt":"2012-11-16T09:27:03Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n>\n>> I don't understand what you mean by \"non-current\". If you mean a local\n>> branch not pointed to by HEAD, then I don't understand the remark, as\n>> the message is shown by \"git status\" (looking more closely, it is also\n>> shown by \"git checkout\", but after switching branch so also showing a\n>> message about the current branch) and precisely talks about the current\n>> branch.\n>\n> Ah, Ok, I somehow thought that \"branch -v\" would also use this\n> information, and/or during my absense this function from remote.c\n> got linked into \"git remote show\" ;-)\n\nOK.\n\n> So it is not an issue right now, but we will have to worry about the\n> messaging when we start using this to describe a branch that is not\n> currently checked out.\n\n(Anyway, we'd have to reword it a bit: saying \"Your branch ...\" would be\nwrong in this case)\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}