{"thread":{"id":"29711","subject":"[RFC/PATCH] Make git-{pull,rebase} no-tracking message friendlier","startedAt":"2012-02-23T16:05:15Z","lastAt":"2012-03-05T07:49:20Z","messageCount":11,"participants":["Carlos Martín Nieto","Junio C Hamano","Matthieu Moy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"185282","messageId":"1330013115-26355-1-git-send-email-cmn@elego.de","threadId":"29711","inReplyTo":null,"subject":"[RFC/PATCH] Make git-{pull,rebase} no-tracking message friendlier","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2012-02-23T16:05:15Z","receivedAt":"2012-02-23T16:05:15Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"The current message is too long and at too low a level for anybody to\nunderstand it if they don't know about the configuration format\nalready.\n\nReformat it to show the commands a user would be expected to use,\ninstead of the contents of the configuration file.\n---\n\nAs annoying as it is when people simply paste the output of 'git pull'\nand ask \"what does it mean\" without even reading it, I have to admit\nthat as a new user, I'd also be scared off by this message. Using\ngit-remote and git-branch should make it less scary and more relatable\nfor the user. I'm not aware of a way to set branch.$branch.rebase with\nporcelain, so I put in a config command there. Better\nsolutions/wordings welcome; I'd really like to get rid of the old\nmessage.\n\n git-parse-remote.sh |   23 ++++++++---------------\n 1 files changed, 8 insertions(+), 15 deletions(-)\n\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\nindex b24119d..96e76a9 100644\n--- a/git-parse-remote.sh\n+++ b/git-parse-remote.sh\n@@ -65,26 +65,19 @@ Please specify which branch you want to $op_type $op_prep on the command\n line and try again (e.g. '$example').\n See git-${cmd}(1) for details.\"\n \telse\n-\t\techo \"You asked me to $cmd without telling me which branch you\n-want to $op_type $op_prep, and 'branch.${branch_name#refs/heads/}.merge' in\n-your configuration file does not tell me, either. Please\n-specify which branch you want to use on the command line and\n+\t\techo \"You asked me to $cmd without telling me which branch you want to\n+$op_type $op_prep, and there is no tracking information for the current branch.\n+Please specify which branch you want to use on the command line and\n try again (e.g. '$example').\n See git-${cmd}(1) for details.\n \n If you often $op_type $op_prep the same branch, you may want to\n-use something like the following in your configuration file:\n-    [branch \\\"${branch_name#refs/heads/}\\\"]\n-    remote = <nickname>\n-    merge = <remote-ref>\"\n-\t\ttest rebase = \"$op_type\" &&\n-\t\techo \"    rebase = true\"\n-\t\techo \"\n-    [remote \\\"<nickname>\\\"]\n-    url = <url>\n-    fetch = <refspec>\n+run something like:\n \n-See git-config(1) for details.\"\n+    git remote add <remote> <url>\n+    git branch --set-upstream ${branch_name#refs/heads/} <remote>/<remote-branch>\"\n+\t\ttest rebase = \"$op_type\" &&\n+\t\techo \"    git config branch.${branch_name#refs/heads/}.rebase true\"\n \tfi\n \texit 1\n }\n-- \n1.7.8.352.g876a6f\n"},{"id":"185300","messageId":"7vhayh2t15.fsf@alter.siamese.dyndns.org","threadId":"29711","inReplyTo":"1330013115-26355-1-git-send-email-cmn@elego.de","subject":"Re: [RFC/PATCH] Make git-{pull,rebase} no-tracking message friendlier","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-23T20:28:54Z","receivedAt":"2012-02-23T20:28:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Carlos Martín Nieto <cmn@elego.de> writes:\n\n> The current message is too long and at too low a level for anybody to\n> understand it if they don't know about the configuration format\n> already.\n>\n> Reformat it to show the commands a user would be expected to use,\n> instead of the contents of the configuration file.\n> ---\n\nSounds like a change going in the right direction.  I am unsure if it is a\ngood idea to remove \"See git-config...\", but otherwise I like the updated\ntext much better.\n\nBut of course I am not the target audience, so let's see what we hear from\nothers.\n\nThanks.\n"},{"id":"185523","messageId":"1330362454.691.5.camel@centaur.lab.cmartin.tk","threadId":"29711","inReplyTo":"7vhayh2t15.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC/PATCH] Make git-{pull,rebase} no-tracking message friendlier","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2012-02-27T17:07:34Z","receivedAt":"2012-02-27T17:07:34Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"On Thu, 2012-02-23 at 12:28 -0800, Junio C Hamano wrote:\n> Carlos Martín Nieto <cmn@elego.de> writes:\n> \n> > The current message is too long and at too low a level for anybody to\n> > understand it if they don't know about the configuration format\n> > already.\n> >\n> > Reformat it to show the commands a user would be expected to use,\n> > instead of the contents of the configuration file.\n> > ---\n> \n> Sounds like a change going in the right direction.  I am unsure if it is a\n> good idea to remove \"See git-config...\", but otherwise I like the updated\n> text much better.\n\nWe're already telling them to go look at the git-pull or git-rebase\nmanpages, where there's already a lot of information and adding another\nRTFM seemed a bit unfriendly (and not that useful, as they'd be\nmanipulating the config via other commands and shouldn't need to care\nabout config that much)\n\n> \n> But of course I am not the target audience, so let's see what we hear from\n> others.\n\nSure, I'll see if I can come up with some better wording and send a\nsigned-off patch.\n\n   cmn\n\n\n"},{"id":"185571","messageId":"vpq399wc4ns.fsf@bauges.imag.fr","threadId":"29711","inReplyTo":"1330013115-26355-1-git-send-email-cmn@elego.de","subject":"Re: [RFC/PATCH] Make git-{pull,rebase} no-tracking message friendlier","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-02-27T22:06:31Z","receivedAt":"2012-02-27T22:06:31Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Carlos Martín Nieto <cmn@elego.de> writes:\n\n> -\t\techo \"You asked me to $cmd without telling me which branch you\n> -want to $op_type $op_prep, and 'branch.${branch_name#refs/heads/}.merge' in\n> -your configuration file does not tell me, either. Please\n> -specify which branch you want to use on the command line and\n> +\t\techo \"You asked me to $cmd without telling me which branch you want to\n> +$op_type $op_prep, and there is no tracking information for the current branch.\n> +Please specify which branch you want to use on the command line and\n>  try again (e.g. '$example').\n\nAt this point, it may be better to actually give the full command\ninstead of just this \"(e.g. '$example')\", i.e. stg like\n\n  git $op_type <remote> $example\n\nI also saw users confused by the message (indeed without reading it,\nbut ...). Giving them something as close as possible to\ncut-and-paste-able command should help.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"185698","messageId":"1330487854.691.24.camel@centaur.lab.cmartin.tk","threadId":"29711","inReplyTo":"vpq399wc4ns.fsf@bauges.imag.fr","subject":"Re: [RFC/PATCH] Make git-{pull,rebase} no-tracking message friendlier","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2012-02-29T03:57:34Z","receivedAt":"2012-02-29T03:57:34Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"On Mon, 2012-02-27 at 23:06 +0100, Matthieu Moy wrote:\n> Carlos Martín Nieto <cmn@elego.de> writes:\n> \n> > -\t\techo \"You asked me to $cmd without telling me which branch you\n> > -want to $op_type $op_prep, and 'branch.${branch_name#refs/heads/}.merge' in\n> > -your configuration file does not tell me, either. Please\n> > -specify which branch you want to use on the command line and\n> > +\t\techo \"You asked me to $cmd without telling me which branch you want to\n> > +$op_type $op_prep, and there is no tracking information for the current branch.\n> > +Please specify which branch you want to use on the command line and\n> >  try again (e.g. '$example').\n> \n> At this point, it may be better to actually give the full command\n> instead of just this \"(e.g. '$example')\", i.e. stg like\n> \n>   git $op_type <remote> $example\n> \n> I also saw users confused by the message (indeed without reading it,\n> but ...). Giving them something as close as possible to\n> cut-and-paste-able command should help.\n\n\n$example is a caller-given string which already contains the whole\ncommand (i.e. it's already 'git rebase <upstream branch>' or 'git pull\n<repository> <branch>').  In this patch I've moved that command to its\nown paragraph so the usage part of the output gets more visibility.\n\nAnother version of the patch, this one somewhat more intrusive,\nhopefully easier to digest.\n\n---8<---\nSubject: [PATCH] Make git-{pull,rebase} message without tracking information\n friendlier\n\nThe current message is too long and at too low a level for anybody to\nunderstand it if they don't know about the configuration format\nalready.\n\nReformat it to show the commands a user would be expected to use,\ninstead of the contents of the configuration file. Use <branch>\ninstead of <refspec> or <upstream branch> as they're bound to consfuse\nnew users more than help them. Use <remote> instead of <repository> in\nthe pull message.\n---\n git-parse-remote.sh |   26 ++++++++++----------------\n git-pull.sh         |    2 +-\n git-rebase.sh       |    2 +-\n 3 files changed, 12 insertions(+), 18 deletions(-)\n\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\nindex b24119d..bcb75a0 100644\n--- a/git-parse-remote.sh\n+++ b/git-parse-remote.sh\n@@ -66,25 +66,19 @@ line and try again (e.g. '$example').\n See git-${cmd}(1) for details.\"\n \telse\n \t\techo \"You asked me to $cmd without telling me which branch you\n-want to $op_type $op_prep, and 'branch.${branch_name#refs/heads/}.merge' in\n-your configuration file does not tell me, either. Please\n-specify which branch you want to use on the command line and\n-try again (e.g. '$example').\n-See git-${cmd}(1) for details.\n+want to $op_type $op_prep, and the current branch doesn't have\n+tracking information. Please specify which branch you want to\n+use on the command line and try again. See git-${cmd}(1) for details.\n+\n+    $example\n \n If you often $op_type $op_prep the same branch, you may want to\n-use something like the following in your configuration file:\n-    [branch \\\"${branch_name#refs/heads/}\\\"]\n-    remote = <nickname>\n-    merge = <remote-ref>\"\n-\t\ttest rebase = \"$op_type\" &&\n-\t\techo \"    rebase = true\"\n-\t\techo \"\n-    [remote \\\"<nickname>\\\"]\n-    url = <url>\n-    fetch = <refspec>\n+run something like:\n \n-See git-config(1) for details.\"\n+    git remote add <remote> <url>\n+    git branch --set-upstream ${branch_name#refs/heads/} <remote>/<branch>\"\n+\t\ttest rebase = \"$op_type\" &&\n+\t\techo \"    git config branch.${branch_name#refs/heads/}.rebase true\"\n \tfi\n \texit 1\n }\ndiff --git a/git-pull.sh b/git-pull.sh\nindex d8b64d7..309c7db 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -176,7 +176,7 @@ error_on_no_merge_candidates () {\n \telif [ -z \"$curr_branch\" -o -z \"$upstream\" ]; then\n \t\t. git-parse-remote\n \t\terror_on_missing_default_upstream \"pull\" $op_type $op_prep \\\n-\t\t\t\"git pull <repository> <refspec>\"\n+\t\t\t\"git pull <remote> <branch>\"\n \telse\n \t\techo \"Your configuration specifies to $op_type $op_prep the ref '${upstream#refs/heads/}'\"\n \t\techo \"from the remote, but no such ref was fetched.\"\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 00ca7b9..69c1374 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -380,7 +380,7 @@ then\n \t\tthen\n \t\t\t. git-parse-remote\n \t\t\terror_on_missing_default_upstream \"rebase\" \"rebase\" \\\n-\t\t\t\t\"against\" \"git rebase <upstream branch>\"\n+\t\t\t\t\"against\" \"git rebase <branch>\"\n \t\tfi\n \t\t;;\n \t*)\tupstream_name=\"$1\"\n-- \n1.7.9.2.3.g4346f\n"},{"id":"185705","messageId":"vpqbooit61u.fsf@bauges.imag.fr","threadId":"29711","inReplyTo":"1330487854.691.24.camel@centaur.lab.cmartin.tk","subject":"Re: [RFC/PATCH] Make git-{pull,rebase} no-tracking message friendlier","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-02-29T08:09:01Z","receivedAt":"2012-02-29T08:09:01Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Carlos Martín Nieto <cmn@elego.de> writes:\n\n> $example is a caller-given string which already contains the whole\n> command (i.e. it's already 'git rebase <upstream branch>' or 'git pull\n> <repository> <branch>').\n\nOK, I didn't remember the exact message.\n\n> In this patch I've moved that command to its own paragraph so the\n> usage part of the output gets more visibility.\n\nI prefer this, yes.\n\nPerhaps we could go further and try to guess a remote and a branch name\nto give in the example. \"git push\" already does that to some extend:\n\n  $ git -c push.default=tracking push\n  fatal: The current branch my-branch has no upstream branch.\n  To push the current branch and set the remote as upstream, use\n  \n      git push --set-upstream origin my-branch\n\ni.e. if there's a remote configured, then using it in the example makes\nsense. I'm not sure if using the current branch name in the example\nwould also be a good thing (it usually is for \"push\" because most users\nwould push to a branch with the same name on the remote end).\n\nIt may also make sense not to suggest \"git remote add\" if there's\nalready a remote configured. Otherwise, the case, which is probably the\nmost common, of:\n\n  git clone http://example.com/repo\n  cd repo\n  git checkout -b new-branch\n  git pull\n\nis made far more complex than it should for the newcommer.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"185725","messageId":"1330536843.22763.19.camel@beez.lab.cmartin.tk","threadId":"29711","inReplyTo":"vpqbooit61u.fsf@bauges.imag.fr","subject":"Re: [RFC/PATCH] Make git-{pull,rebase} no-tracking message friendlier","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2012-02-29T17:34:03Z","receivedAt":"2012-02-29T17:34:03Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"On Wed, 2012-02-29 at 09:09 +0100, Matthieu Moy wrote:\n> Carlos Martín Nieto <cmn@elego.de> writes:\n> \n> > $example is a caller-given string which already contains the whole\n> > command (i.e. it's already 'git rebase <upstream branch>' or 'git pull\n> > <repository> <branch>').\n> \n> OK, I didn't remember the exact message.\n> \n> > In this patch I've moved that command to its own paragraph so the\n> > usage part of the output gets more visibility.\n> \n> I prefer this, yes.\n> \n> Perhaps we could go further and try to guess a remote and a branch name\n> to give in the example. \"git push\" already does that to some extend:\n> \n>   $ git -c push.default=tracking push\n>   fatal: The current branch my-branch has no upstream branch.\n>   To push the current branch and set the remote as upstream, use\n>   \n>       git push --set-upstream origin my-branch\n> \n> i.e. if there's a remote configured, then using it in the example makes\n> sense. I'm not sure if using the current branch name in the example\n> would also be a good thing (it usually is for \"push\" because most users\n> would push to a branch with the same name on the remote end).\n\nWe do show the branch name in the 'remote add' text at the end, so we\nshould probably try to use it here as well. What I'm assuming is the\nmost usual case of one remote called 'origin' shouldn't be a problem. I\nthink I'll suppress the last part of the output when there are remotes\nconfigured, as we can probably assume that the user is aware of them.\n\nI'm tempted to throw out the second block and say to use either 'git\npull $remote $branch' or 'git branch --set-upstream $branch\n$remote/$branch' and refer to the documentation for more. After all,\nthis is an error message, not a man page.\n\n> \n> It may also make sense not to suggest \"git remote add\" if there's\n> already a remote configured. Otherwise, the case, which is probably the\n> most common, of:\n> \n>   git clone http://example.com/repo\n>   cd repo\n>   git checkout -b new-branch\n>   git pull\n> \n> is made far more complex than it should for the newcommer.\n\nIndeed. Removing the last part is probably better for everyone.\n\n   cmn\n\n"},{"id":"185730","messageId":"1330540914-14515-1-git-send-email-cmn@elego.de","threadId":"29711","inReplyTo":"vpqbooit61u.fsf@bauges.imag.fr","subject":"[PATCH] Make git-{pull,rebase} message without tracking information friendlier","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2012-02-29T18:41:54Z","receivedAt":"2012-02-29T18:41:54Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"The current message is too long and at too low a level for anybody to\nunderstand it if they don't know about the configuration format\nalready.\n\nThe text about setting up a remote is superfluous and doesn't help\nunderstand the error that has happened. Explain how to set up the\ntracking information, as it's the most likely way to get to the state\nthe user was expecting.\n\nAlso simplify the message we print on detached HEAD to remove clutter\nand a reference to branch.<branchname>.merge which is better left for\nthe documentation.\n---\n\nThis still needs some shell scripting to figure out whether we'd want\nto replace <remote> with a real value. The text gets to the matter of\nthings and even tells you how to fix it. More text doesn't really add\nmore useful information, and this isn't a manpage.\n\nI've left the branch --set-upstream in this version as it's probably\nthe most usual fix for a failing git push.\n\n git-parse-remote.sh |   32 ++++++++++----------------------\n git-pull.sh         |    2 +-\n git-rebase.sh       |    2 +-\n 3 files changed, 12 insertions(+), 24 deletions(-)\n\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\nindex b24119d..08adc90 100644\n--- a/git-parse-remote.sh\n+++ b/git-parse-remote.sh\n@@ -60,31 +60,19 @@ error_on_missing_default_upstream () {\n \tif test -z \"$branch_name\"\n \tthen\n \t\techo \"You are not currently on a branch, so I cannot use any\n-'branch.<branchname>.merge' in your configuration file.\n-Please specify which branch you want to $op_type $op_prep on the command\n-line and try again (e.g. '$example').\n-See git-${cmd}(1) for details.\"\n-\telse\n-\t\techo \"You asked me to $cmd without telling me which branch you\n-want to $op_type $op_prep, and 'branch.${branch_name#refs/heads/}.merge' in\n-your configuration file does not tell me, either. Please\n-specify which branch you want to use on the command line and\n-try again (e.g. '$example').\n+tracking information in your configuration file.\n+Please specify which branch you want to $op_type $op_prep.\n See git-${cmd}(1) for details.\n \n-If you often $op_type $op_prep the same branch, you may want to\n-use something like the following in your configuration file:\n-    [branch \\\"${branch_name#refs/heads/}\\\"]\n-    remote = <nickname>\n-    merge = <remote-ref>\"\n-\t\ttest rebase = \"$op_type\" &&\n-\t\techo \"    rebase = true\"\n-\t\techo \"\n-    [remote \\\"<nickname>\\\"]\n-    url = <url>\n-    fetch = <refspec>\n+    $example\"\n+\telse\n+\t\techo \"You asked me to $cmd without specifying a branch to\n+$op_type $op_prep, and the current branch doesn't have any tracking\n+information. Please specify a branch and try again. See git-${cmd}(1)\n+for details. To set the tracking information, you can use\n \n-See git-config(1) for details.\"\n+    git branch --set-upstream ${branch_name#refs/heads/} <remote>/<branch>\n+\"\n \tfi\n \texit 1\n }\ndiff --git a/git-pull.sh b/git-pull.sh\nindex d8b64d7..309c7db 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -176,7 +176,7 @@ error_on_no_merge_candidates () {\n \telif [ -z \"$curr_branch\" -o -z \"$upstream\" ]; then\n \t\t. git-parse-remote\n \t\terror_on_missing_default_upstream \"pull\" $op_type $op_prep \\\n-\t\t\t\"git pull <repository> <refspec>\"\n+\t\t\t\"git pull <remote> <branch>\"\n \telse\n \t\techo \"Your configuration specifies to $op_type $op_prep the ref '${upstream#refs/heads/}'\"\n \t\techo \"from the remote, but no such ref was fetched.\"\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 00ca7b9..69c1374 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -380,7 +380,7 @@ then\n \t\tthen\n \t\t\t. git-parse-remote\n \t\t\terror_on_missing_default_upstream \"rebase\" \"rebase\" \\\n-\t\t\t\t\"against\" \"git rebase <upstream branch>\"\n+\t\t\t\t\"against\" \"git rebase <branch>\"\n \t\tfi\n \t\t;;\n \t*)\tupstream_name=\"$1\"\n-- \n1.7.8.352.g876a6f\n"},{"id":"185739","messageId":"7vobshs8go.fsf@alter.siamese.dyndns.org","threadId":"29711","inReplyTo":"1330540914-14515-1-git-send-email-cmn@elego.de","subject":"Re: [PATCH] Make git-{pull,rebase} message without tracking information friendlier","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-29T20:14:31Z","receivedAt":"2012-02-29T20:14:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Carlos Martín Nieto <cmn@elego.de> writes:\n\n> The current message is too long and at too low a level for anybody to\n> understand it if they don't know about the configuration format\n> already.\n>\n> The text about setting up a remote is superfluous and doesn't help\n> understand the error that has happened. Explain how to set up the\n> tracking information, as it's the most likely way to get to the state\n> the user was expecting.\n>\n> Also simplify the message we print on detached HEAD to remove clutter\n> and a reference to branch.<branchname>.merge which is better left for\n> the documentation.\n> ---\n> This still needs some shell scripting to figure out whether we'd want\n> to replace <remote> with a real value. The text gets to the matter of\n> things and even tells you how to fix it. More text doesn't really add\n> more useful information, and this isn't a manpage.\n\nExactly.\n\nThis made me thinking again.  On the \"detached HEAD\" side of your patch,\nthe concluding \"Please specify which branch you mean\" is the most useful\ninformation; \", so I cannot use any tracking information in your\nconfiguration file\" may help _education_, but does not immediately help\nthe user to do what the user wanted to do.\n\nPerhaps it may read it better if we remove that part; the result becomes\neven more concise and to the point.\n\nOh the \"on a branch\" side of your patch, the updated message is trying to\nhelp the user by doing two things:\n\n - tell him to explicitly name the branch (by the way, you seem to have\n   lost the $example---is it intended) in order to immediately perform\n   what he wanted to.\n\n - educate him that he can configure upstream information and avoid\n   typing in a later invocation of the same command.\n\nI think it is easier to read if we have clear separation between the two,\nas the hasty users would want to stop reading after the first help.\n\nSo after \"See git-${cmd}(1) for details.\", have a paragraph break, add\nan indented \"$example\" just like you have for the \"detached HEAD\" case,\nanother paragraph break and then \"To set the tracking information\" as a\nnew pargraph, perhaps?\n\n> I've left the branch --set-upstream in this version as it's probably\n> the most usual fix for a failing git push.\n>\n>  git-parse-remote.sh |   32 ++++++++++----------------------\n>  git-pull.sh         |    2 +-\n>  git-rebase.sh       |    2 +-\n>  3 files changed, 12 insertions(+), 24 deletions(-)\n>\n> diff --git a/git-parse-remote.sh b/git-parse-remote.sh\n> index b24119d..08adc90 100644\n> --- a/git-parse-remote.sh\n> +++ b/git-parse-remote.sh\n> @@ -60,31 +60,19 @@ error_on_missing_default_upstream () {\n>  \tif test -z \"$branch_name\"\n>  \tthen\n>  \t\techo \"You are not currently on a branch, so I cannot use any\n> +tracking information in your configuration file.\n> +Please specify which branch you want to $op_type $op_prep.\n>  See git-${cmd}(1) for details.\n>  \n> +    $example\"\n> +\telse\n> +\t\techo \"You asked me to $cmd without specifying a branch to\n> +$op_type $op_prep, and the current branch doesn't have any tracking\n> +information. Please specify a branch and try again. See git-${cmd}(1)\n> +for details. To set the tracking information, you can use\n>  \n> -See git-config(1) for details.\"\n> +    git branch --set-upstream ${branch_name#refs/heads/} <remote>/<branch>\n> +\"\n>  \tfi\n>  \texit 1\n>  }\n> diff --git a/git-pull.sh b/git-pull.sh\n> index d8b64d7..309c7db 100755\n> --- a/git-pull.sh\n> +++ b/git-pull.sh\n> @@ -176,7 +176,7 @@ error_on_no_merge_candidates () {\n>  \telif [ -z \"$curr_branch\" -o -z \"$upstream\" ]; then\n>  \t\t. git-parse-remote\n>  \t\terror_on_missing_default_upstream \"pull\" $op_type $op_prep \\\n> -\t\t\t\"git pull <repository> <refspec>\"\n> +\t\t\t\"git pull <remote> <branch>\"\n>  \telse\n>  \t\techo \"Your configuration specifies to $op_type $op_prep the ref '${upstream#refs/heads/}'\"\n>  \t\techo \"from the remote, but no such ref was fetched.\"\n> diff --git a/git-rebase.sh b/git-rebase.sh\n> index 00ca7b9..69c1374 100755\n> --- a/git-rebase.sh\n> +++ b/git-rebase.sh\n> @@ -380,7 +380,7 @@ then\n>  \t\tthen\n>  \t\t\t. git-parse-remote\n>  \t\t\terror_on_missing_default_upstream \"rebase\" \"rebase\" \\\n> -\t\t\t\t\"against\" \"git rebase <upstream branch>\"\n> +\t\t\t\t\"against\" \"git rebase <branch>\"\n>  \t\tfi\n>  \t\t;;\n>  \t*)\tupstream_name=\"$1\"\n"},{"id":"186023","messageId":"1330836086.691.87.camel@centaur.lab.cmartin.tk","threadId":"29711","inReplyTo":"7vobshs8go.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Make git-{pull,rebase} message without tracking information friendlier","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2012-03-04T04:41:26Z","receivedAt":"2012-03-04T04:41:26Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"On Wed, 2012-02-29 at 12:14 -0800, Junio C Hamano wrote:\n> Carlos Martín Nieto <cmn@elego.de> writes:\n> [...]\n> \n> This made me thinking again.  On the \"detached HEAD\" side of your patch,\n> the concluding \"Please specify which branch you mean\" is the most useful\n> information; \", so I cannot use any tracking information in your\n> configuration file\" may help _education_, but does not immediately help\n> the user to do what the user wanted to do.\n\n> Perhaps it may read it better if we remove that part; the result becomes\n> even more concise and to the point.\n\nRight. Less is more. I may have stared at it for too long, but I get the\nfeeling that in the new message, \"You are not on a branch\" and \"Please\nspecify which branch\" don't really seem to go together. After the first\nsentence, I'm left thinking \"so what?\". Maybe something like \"On\ndetached HEAD, you must specify a branch to $op_type $op_prep. [...]\"\nwould work better?\n\n> \n> Oh the \"on a branch\" side of your patch, the updated message is trying to\n> help the user by doing two things:\n> \n>  - tell him to explicitly name the branch (by the way, you seem to have\n>    lost the $example---is it intended) in order to immediately perform\n>    what he wanted to.\n\nI did remove that on purpose because I couldn't figure out a good way to\nintroduce both versions. I was stubbornly keeping the configuration part\nfirst and it wasn't clicking.\n\n> \n>  - educate him that he can configure upstream information and avoid\n>    typing in a later invocation of the same command.\n> \n> I think it is easier to read if we have clear separation between the two,\n> as the hasty users would want to stop reading after the first help.\n\nYes. This is why I wanted to put the configuration information first, as\na user who calls 'git pull' expects things to happen automatically, so I\nwanted to tell her how to get it.\n\n> \n> So after \"See git-${cmd}(1) for details.\", have a paragraph break, add\n> an indented \"$example\" just like you have for the \"detached HEAD\" case,\n> another paragraph break and then \"To set the tracking information\" as a\n> new pargraph, perhaps?\n> \n\nThis way around looks much better and makes a lot more sense. Thanks for\nthe hint.\n\nI couldn't come up with a better way to count remotes than\n$(git remote | wc -l) as git config only uses the regex for the values\nand $(git config --list | grep -c '^remote\\..*\\.url') seems even worse. \n\nI'm kind of two minds about the remote thing. If the branch doesn't have\nan upstream already (either via checkout -t origin/branch or push -u),\nmaking pulling from a remote upstream branch easier might lead to more\nsenseless merges, which is the opposite direction to other changes in\npull which ask for a reason, so after we've given them most of the\ncommand to run so pull magically works on its own, we ask them to\njustify it... I don't know, maybe I'm overthinking this.\n\n   cmn\n\n--- 8< ---\nSubject: [PATCH] Make git-{pull,rebase} message without tracking information\n friendlier\n\nThe current message is too long and at too low a level for anybody to\nunderstand it if they don't know about the configuration format\nalready.\n\nThe text about setting up a remote is superfluous and doesn't help\nunderstand the error that has happened. Show the usage more\nprominently and explain how to set up the tracking information. If\nthere is only one remote, that name is used instead of the generic\n<remote>.\n\nAlso simplify the message we print on detached HEAD to remove\nunnecessary information which is better left for the documentation.\n\nSigned-off-by: Carlos Martín Nieto <cmn@elego.de>\n---\n git-parse-remote.sh |   42 +++++++++++++++++++-----------------------\n git-pull.sh         |    2 +-\n git-rebase.sh       |    2 +-\n 3 files changed, 21 insertions(+), 25 deletions(-)\n\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\nindex b24119d..4575309 100644\n--- a/git-parse-remote.sh\n+++ b/git-parse-remote.sh\n@@ -57,34 +57,30 @@ error_on_missing_default_upstream () {\n \top_prep=\"$3\"\n \texample=\"$4\"\n \tbranch_name=$(git symbolic-ref -q HEAD)\n+\t# If there's only one remote, use that in the suggestion\n+\tremote=\"<remote>\"\n+\tif test $(git remote | wc -l) -eq 1; then\n+\t    remote=$(git remote)\n+\tfi\n+\n \tif test -z \"$branch_name\"\n \tthen\n-\t\techo \"You are not currently on a branch, so I cannot use any\n-'branch.<branchname>.merge' in your configuration file.\n-Please specify which branch you want to $op_type $op_prep on the command\n-line and try again (e.g. '$example').\n-See git-${cmd}(1) for details.\"\n+\t\techo \"You are not currently on a branch. Please specify which\n+branch you want to $op_type $op_prep. See git-${cmd}(1) for details.\n+\n+    $example\n+\"\n \telse\n-\t\techo \"You asked me to $cmd without telling me which branch you\n-want to $op_type $op_prep, and 'branch.${branch_name#refs/heads/}.merge' in\n-your configuration file does not tell me, either. Please\n-specify which branch you want to use on the command line and\n-try again (e.g. '$example').\n-See git-${cmd}(1) for details.\n+\t\techo \"There is no tracking information for the current branch.\n+Please specify which branch you want to $op_type $op_prep.\n+See git-${cmd}(1) for details\n+\n+    $example\n \n-If you often $op_type $op_prep the same branch, you may want to\n-use something like the following in your configuration file:\n-    [branch \\\"${branch_name#refs/heads/}\\\"]\n-    remote = <nickname>\n-    merge = <remote-ref>\"\n-\t\ttest rebase = \"$op_type\" &&\n-\t\techo \"    rebase = true\"\n-\t\techo \"\n-    [remote \\\"<nickname>\\\"]\n-    url = <url>\n-    fetch = <refspec>\n+If you whish to set tracking information for this branch you can do so with:\n \n-See git-config(1) for details.\"\n+    git branch --set-upstream ${branch_name#refs/heads/} $remote/<branch>\n+\"\n \tfi\n \texit 1\n }\ndiff --git a/git-pull.sh b/git-pull.sh\nindex d8b64d7..309c7db 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -176,7 +176,7 @@ error_on_no_merge_candidates () {\n \telif [ -z \"$curr_branch\" -o -z \"$upstream\" ]; then\n \t\t. git-parse-remote\n \t\terror_on_missing_default_upstream \"pull\" $op_type $op_prep \\\n-\t\t\t\"git pull <repository> <refspec>\"\n+\t\t\t\"git pull <remote> <branch>\"\n \telse\n \t\techo \"Your configuration specifies to $op_type $op_prep the ref '${upstream#refs/heads/}'\"\n \t\techo \"from the remote, but no such ref was fetched.\"\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 00ca7b9..69c1374 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -380,7 +380,7 @@ then\n \t\tthen\n \t\t\t. git-parse-remote\n \t\t\terror_on_missing_default_upstream \"rebase\" \"rebase\" \\\n-\t\t\t\t\"against\" \"git rebase <upstream branch>\"\n+\t\t\t\t\"against\" \"git rebase <branch>\"\n \t\tfi\n \t\t;;\n \t*)\tupstream_name=\"$1\"\n-- \n1.7.9.2.3.g4346f\n"},{"id":"186086","messageId":"7vty2332tb.fsf@alter.siamese.dyndns.org","threadId":"29711","inReplyTo":"1330836086.691.87.camel@centaur.lab.cmartin.tk","subject":"Re: [PATCH] Make git-{pull,rebase} message without tracking information friendlier","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-05T07:49:20Z","receivedAt":"2012-03-05T07:49:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I think the updated message is much easier to read, so I've queued\nthis almost as-is (except for minor and obvious typo fixes,\ne.g. whish) and merged it to 'next'.\n\nThanks.\n\nBy the way, these needed to be squashed in.\n\ndiff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh\nindex e647272..370ffdf 100755\n--- a/t/t3400-rebase.sh\n+++ b/t/t3400-rebase.sh\n@@ -160,14 +160,12 @@ rm -f B\n \n test_expect_success 'fail when upstream arg is missing and not on branch' '\n \tgit checkout topic &&\n-\ttest_must_fail git rebase >output.out &&\n-\tgrep \"You are not currently on a branch\" output.out\n+\ttest_must_fail git rebase\n '\n \n test_expect_success 'fail when upstream arg is missing and not configured' '\n \tgit checkout -b no-config topic &&\n-\ttest_must_fail git rebase >output.out &&\n-\tgrep \"branch.no-config.merge\" output.out\n+\ttest_must_fail git rebase\n '\n \n test_expect_success 'default to @{upstream} when upstream arg is missing' '\n"}]}