{"thread":{"id":"20916","subject":"Confusing git pull error message","startedAt":"2009-09-12T20:01:45Z","lastAt":"2009-10-10T00:57:04Z","messageCount":28,"participants":["John Tapsell","Jeff King","Sverre Rabbelier","Junio C Hamano","Johannes Sixt","Nanako Shiraishi"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"122987","messageId":"43d8ce650909121301i4450489dhf475ff6894394a5f@mail.gmail.com","threadId":"20916","inReplyTo":null,"subject":"Confusing git pull error message","fromName":"John Tapsell","fromEmail":"johnflux@gmail.com","sentAt":"2009-09-12T20:01:45Z","receivedAt":"2009-09-12T20:01:45Z","isPatch":false,"sender":{"key":"johnflux@gmail.com","avatar":"https://gravatar.com/avatar/25f70d4c0f96396b84a2e34bcd9bdc233462c7b4be29b5fdca8266fc53f30b0c?d=mp&s=160"},"body":"Hi,\n\n  Because of another bug in git https, sometimes \"git ls-remote\norigin\" only sees a small subset of the actually available branches.\nThis lasts until someone using git:// makes a commit.\n\n  So anyway, I tried to do a \"git pull\" and it gives me the misleading error:\n\nYou asked me to pull without telling me which branch you\nwant to merge with, and 'branch.master.merge' in\nyour configuration file does not tell me either.  Please\nname which branch you want to merge on the command line and\ntry again (e.g. 'git pull <repository> <refspec>').\nSee git-pull(1) for details on the refspec.\n\nIf you often merge with the same branch, you may want to\nconfigure the following variables in your configuration\nfile:\n\n    branch.master.remote = <nickname>\n    branch.master.merge = <remote-ref>\n    remote.<nickname>.url = <url>\n    remote.<nickname>.fetch = <refspec>\n\nSee git-config(1) for details.\n\n\n\nBut the actual problem is that \"master\" doesn't exist on origin.  So\nbasically I _have_ told it what branch.master.remote and\nbranch.master.merge etc is, it's just that they don't appear to exist.\n\nThanks,\n\nJohn\n"},{"id":"122993","messageId":"20090912211119.GA30966@coredump.intra.peff.net","threadId":"20916","inReplyTo":"43d8ce650909121301i4450489dhf475ff6894394a5f@mail.gmail.com","subject":"Re: Confusing git pull error message","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-09-12T21:11:19Z","receivedAt":"2009-09-12T21:11:19Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Sep 12, 2009 at 11:01:45PM +0300, John Tapsell wrote:\n\n>   So anyway, I tried to do a \"git pull\" and it gives me the misleading error:\n> \n> You asked me to pull without telling me which branch you\n> want to merge with, and 'branch.master.merge' in\n> your configuration file does not tell me either.  Please\n> name which branch you want to merge on the command line and\n> try again (e.g. 'git pull <repository> <refspec>').\n> See git-pull(1) for details on the refspec.\n>\n> [...]\n>\n> But the actual problem is that \"master\" doesn't exist on origin.  So\n> basically I _have_ told it what branch.master.remote and\n> branch.master.merge etc is, it's just that they don't appear to exist.\n\nUgh. That is horrible. It's an artifact of the (IMHO) brain-dead way\nthat pull and fetch interact.\n\nPull doesn't actually look at the configuration at all. It just calls\nfetch, and then fetch writes out a file containing the refs it pulled,\nsome of which may be marked with a magic \"not-for-merge\" flag. So we see\nthat nothing is available for merging and guess that it must not have\nbeen configured. Which is of course wrong in your case; it just didn't\nexist.\n\nI think it is enough for git-pull to just check whether the config\nexists, and if so, guess that the ref was simply not fetched. IOW,\nthis:\n\n-- >8 --\nSubject: [PATCH] pull: make \"nothing to merge\" error message more accurate\n\nWhen pull sees that no branches are available for merge and\nthat we have a current branch, it assumes the problem is\nthat we had no branch.*.merge configuration. But it may also\nbe the case that we simply didn't pull the configured ref\n(probably because it doesn't exist). Let's distinguish those\ntwo cases.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n git-pull.sh |    9 ++++++++-\n 1 files changed, 8 insertions(+), 1 deletions(-)\n\ndiff --git a/git-pull.sh b/git-pull.sh\nindex 0bbd5bf..4ddd537 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -89,6 +89,9 @@ error_on_no_merge_candidates () {\n \tdone\n \n \tcurr_branch=${curr_branch#refs/heads/}\n+\tupstream=`git config \"branch.$curr_branch.merge\" ||\n+\t\t  git config \"branch.$curr_branch.rebase\"`\n+\tupstream_short=`echo \"$upstream\" | sed \"s|refs/heads/||\"`\n \n \tif [ -z \"$curr_branch\" ]; then\n \t\techo \"You are not currently on a branch, so I cannot use any\"\n@@ -96,7 +99,7 @@ error_on_no_merge_candidates () {\n \t\techo \"Please specify which branch you want to merge on the command\"\n \t\techo \"line and try again (e.g. 'git pull <repository> <refspec>').\"\n \t\techo \"See git-pull(1) for details.\"\n-\telse\n+\telif [ -z \"$upstream\" ]; then\n \t\techo \"You asked me to pull without telling me which branch you\"\n \t\techo \"want to merge with, and 'branch.${curr_branch}.merge' in\"\n \t\techo \"your configuration file does not tell me either.\tPlease\"\n@@ -114,6 +117,10 @@ error_on_no_merge_candidates () {\n \t\techo \"    remote.<nickname>.fetch = <refspec>\"\n \t\techo\n \t\techo \"See git-config(1) for details.\"\n+\telse\n+\t\techo \"Your configuration specified for us to pull the ref\"\n+\t\techo \"'$upstream_short', but we were unable to fetch it from\"\n+\t\techo \"the remote.\"\n \tfi\n \texit 1\n }\n-- \n1.6.5.rc0.201.g76b4d.dirty\n"},{"id":"122994","messageId":"43d8ce650909121431o382b9348q19ee7db5adbb4a72@mail.gmail.com","threadId":"20916","inReplyTo":"20090912211119.GA30966@coredump.intra.peff.net","subject":"Re: Confusing git pull error message","fromName":"John Tapsell","fromEmail":"johnflux@gmail.com","sentAt":"2009-09-12T21:31:46Z","receivedAt":"2009-09-12T21:31:46Z","isPatch":false,"sender":{"key":"johnflux@gmail.com","avatar":"https://gravatar.com/avatar/25f70d4c0f96396b84a2e34bcd9bdc233462c7b4be29b5fdca8266fc53f30b0c?d=mp&s=160"},"body":"2009/9/13 Jeff King <peff@peff.net>:\n\n> +       else\n> +               echo \"Your configuration specified for us to pull the ref\"\n> +               echo \"'$upstream_short', but we were unable to fetch it from\"\n> +               echo \"the remote.\"\n\nThanks!\n\nBut why was it 'unable' ?  Are there cases other than it not existing?\n Maybe something less cryptic:\n\n\"Attempted to pull from ref $upstream_short but this branch does not\nexist on remote.\"\n\nOr something?\n\nJohn\n"},{"id":"122995","messageId":"fabb9a1e0909121437q4eb432e3idde98993ac552b5@mail.gmail.com","threadId":"20916","inReplyTo":"20090912211119.GA30966@coredump.intra.peff.net","subject":"Re: Confusing git pull error message","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-09-12T21:37:47Z","receivedAt":"2009-09-12T21:37:47Z","isPatch":false,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Sat, Sep 12, 2009 at 23:11, Jeff King <peff@peff.net> wrote:\n>        if [ -z \"$curr_branch\" ]; then\n>                echo \"You are not currently on a branch, so I cannot use any\"\n> @@ -96,7 +99,7 @@ error_on_no_merge_candidates () {\n>                echo \"Please specify which branch you want to merge on the command\"\n>                echo \"line and try again (e.g. 'git pull <repository> <refspec>').\"\n>                echo \"See git-pull(1) for details.\"\n> -       else\n> +       elif [ -z \"$upstream\" ]; then\n>                echo \"You asked me to pull without telling me which branch you\"\n>                echo \"want to merge with, and 'branch.${curr_branch}.merge' in\"\n>                echo \"your configuration file does not tell me either.  Please\"\n> @@ -114,6 +117,10 @@ error_on_no_merge_candidates () {\n>                echo \"    remote.<nickname>.fetch = <refspec>\"\n>                echo\n>                echo \"See git-config(1) for details.\"\n> +       else\n> +               echo \"Your configuration specified for us to pull the ref\"\n> +               echo \"'$upstream_short', but we were unable to fetch it from\"\n> +               echo \"the remote.\"\n>        fi\n>        exit 1\n>  }\n\nPretty bad case of multiple personality disorder here? At first\nthere's a \"me\", then again a \"me\", and then all of a sudden a \"we\"?\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"123000","messageId":"20090912223137.GA8748@coredump.intra.peff.net","threadId":"20916","inReplyTo":"fabb9a1e0909121437q4eb432e3idde98993ac552b5@mail.gmail.com","subject":"Re: Confusing git pull error message","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-09-12T22:31:37Z","receivedAt":"2009-09-12T22:31:37Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Sep 12, 2009 at 11:37:47PM +0200, Sverre Rabbelier wrote:\n\n> > +               echo \"Your configuration specified for us to pull the ref\"\n> > +               echo \"'$upstream_short', but we were unable to fetch it from\"\n> > +               echo \"the remote.\"\n> >        fi\n> >        exit 1\n> >  }\n> \n> Pretty bad case of multiple personality disorder here? At first\n> there's a \"me\", then again a \"me\", and then all of a sudden a \"we\"?\n\nFair enough. I'll change it to \"I was unable to fetch\" in the re-roll.\n\n-Peff\n"},{"id":"123001","messageId":"20090912223406.GB8748@coredump.intra.peff.net","threadId":"20916","inReplyTo":"43d8ce650909121431o382b9348q19ee7db5adbb4a72@mail.gmail.com","subject":"Re: Confusing git pull error message","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-09-12T22:34:06Z","receivedAt":"2009-09-12T22:34:06Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Sep 13, 2009 at 12:31:46AM +0300, John Tapsell wrote:\n\n> 2009/9/13 Jeff King <peff@peff.net>:\n> \n> > +       else\n> > +               echo \"Your configuration specified for us to pull the ref\"\n> > +               echo \"'$upstream_short', but we were unable to fetch it from\"\n> > +               echo \"the remote.\"\n> \n> Thanks!\n> \n> But why was it 'unable' ?  Are there cases other than it not existing?\n>  Maybe something less cryptic:\n> \n> \"Attempted to pull from ref $upstream_short but this branch does not\n> exist on remote.\"\n> \n> Or something?\n\nI'm not sure if there are other cases, so I left it unspecified. I think\nthat \"does not exist\" is probably the only one that should make it this\nfar, though, as any actual error would cause fetch to die, aborting the\npull.\n\nAnd you can see that when you ask for a specific bogus ref, as in:\n\n  $ git pull origin bogus\n  fatal: Couldn't find remote ref bogus\n\nI'll re-roll the patch with more specific wording.\n\n-Peff\n"},{"id":"123004","messageId":"fabb9a1e0909121537l37fcaaaewdbab37bbd61630b3@mail.gmail.com","threadId":"20916","inReplyTo":"20090912223137.GA8748@coredump.intra.peff.net","subject":"Re: Confusing git pull error message","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-09-12T22:37:06Z","receivedAt":"2009-09-12T22:37:06Z","isPatch":false,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Sun, Sep 13, 2009 at 00:31, Jeff King <peff@peff.net> wrote:\n> Fair enough. I'll change it to \"I was unable to fetch\" in the re-roll.\n\nActually, from grepping through the source there's a lot of we-ing\ngoing on already (although mostly in the comments), and fairly little\nI-ing (not based on actual numbers, just what I could judge at a\nglance), so maybe changing the ones above to \"we\" instead is more\nappropriate?\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"123103","messageId":"7v1vmar353.fsf@alter.siamese.dyndns.org","threadId":"20916","inReplyTo":"20090912211119.GA30966@coredump.intra.peff.net","subject":"Re: Confusing git pull error message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-09-13T20:38:48Z","receivedAt":"2009-09-13T20:38:48Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> I think it is enough for git-pull to just check whether the config\n> exists, and if so, guess that the ref was simply not fetched. IOW,\n> this:\n\nThanks.\n\nI saw some discussion on improving the wording.  Here is what I plan to\ncommit.\n\ndiff --git a/git-pull.sh b/git-pull.sh\nindex 0bbd5bf..2c2fa79 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -89,6 +89,8 @@ error_on_no_merge_candidates () {\n \tdone\n \n \tcurr_branch=${curr_branch#refs/heads/}\n+\tupstream=$(git config \"branch.$curr_branch.merge\" ||\n+\t\t\tgit config \"branch.$curr_branch.rebase\")\n \n \tif [ -z \"$curr_branch\" ]; then\n \t\techo \"You are not currently on a branch, so I cannot use any\"\n@@ -96,7 +98,7 @@ error_on_no_merge_candidates () {\n \t\techo \"Please specify which branch you want to merge on the command\"\n \t\techo \"line and try again (e.g. 'git pull <repository> <refspec>').\"\n \t\techo \"See git-pull(1) for details.\"\n-\telse\n+\telif [ -z \"$upstream\" ]; then\n \t\techo \"You asked me to pull without telling me which branch you\"\n \t\techo \"want to merge with, and 'branch.${curr_branch}.merge' in\"\n \t\techo \"your configuration file does not tell me either.\tPlease\"\n@@ -114,6 +116,10 @@ error_on_no_merge_candidates () {\n \t\techo \"    remote.<nickname>.fetch = <refspec>\"\n \t\techo\n \t\techo \"See git-config(1) for details.\"\n+\telse\n+\t\techo \"Your configuration specifies to merge the ref\"\n+\t\techo \"'${upstream#refs/heads/}' from the remote, but no such ref\"\n+\t\techo \"was fetched.\"\n \tfi\n \texit 1\n }\n"},{"id":"123105","messageId":"20090913204231.GA8654@coredump.intra.peff.net","threadId":"20916","inReplyTo":"7v1vmar353.fsf@alter.siamese.dyndns.org","subject":"Re: Confusing git pull error message","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-09-13T20:42:31Z","receivedAt":"2009-09-13T20:42:31Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Sep 13, 2009 at 01:38:48PM -0700, Junio C Hamano wrote:\n\n> I saw some discussion on improving the wording.  Here is what I plan to\n> commit.\n\nThanks for picking this up, I meant to re-post with improvements.\n\n> +\telse\n> +\t\techo \"Your configuration specifies to merge the ref\"\n> +\t\techo \"'${upstream#refs/heads/}' from the remote, but no such ref\"\n> +\t\techo \"was fetched.\"\n\nWhat you have here is precisely what we observed. But I think one of the\ncomplaints was to say more explicitly \"that ref doesn't exist on the\nremote\", which I think should be the case if we have got to this point\n(anything else would have triggered an error in fetch).\n\nI don't have a strong feeling either way, though.\n\n-Peff\n"},{"id":"123107","messageId":"7vfxaqpnpa.fsf@alter.siamese.dyndns.org","threadId":"20916","inReplyTo":"20090913204231.GA8654@coredump.intra.peff.net","subject":"Re: Confusing git pull error message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-09-13T20:57:37Z","receivedAt":"2009-09-13T20:57:37Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> What you have here is precisely what we observed. But I think one of the\n> complaints was to say more explicitly \"that ref doesn't exist on the\n> remote\", which I think should be the case if we have got to this point\n> (anything else would have triggered an error in fetch).\n\nWouldn't you get into the situation with this?\n\n\t[remote \"origin\"]\n        \tfetch = refs/heads/master:refs/heads/master\n\t[branch \"master\"]\n        \tremote = origin\n                merge = refs/heads/next\n\nI think saying \"does not exist\" will repeat the same mistake of\noverguessing you are trying to rectify.\n"},{"id":"123108","messageId":"43d8ce650909131357m50428ffbs9c939be051254eb7@mail.gmail.com","threadId":"20916","inReplyTo":"20090913204231.GA8654@coredump.intra.peff.net","subject":"Re: Confusing git pull error message","fromName":"John Tapsell","fromEmail":"johnflux@gmail.com","sentAt":"2009-09-13T20:57:37Z","receivedAt":"2009-09-13T20:57:37Z","isPatch":false,"sender":{"key":"johnflux@gmail.com","avatar":"https://gravatar.com/avatar/25f70d4c0f96396b84a2e34bcd9bdc233462c7b4be29b5fdca8266fc53f30b0c?d=mp&s=160"},"body":"2009/9/13 Jeff King <peff@peff.net>:\n> On Sun, Sep 13, 2009 at 01:38:48PM -0700, Junio C Hamano wrote:\n>\n>> I saw some discussion on improving the wording.  Here is what I plan to\n>> commit.\n>\n> Thanks for picking this up, I meant to re-post with improvements.\n>\n>> +     else\n>> +             echo \"Your configuration specifies to merge the ref\"\n>> +             echo \"'${upstream#refs/heads/}' from the remote, but no such ref\"\n>> +             echo \"was fetched.\"\n>\n> What you have here is precisely what we observed. But I think one of the\n> complaints was to say more explicitly \"that ref doesn't exist on the\n> remote\", which I think should be the case if we have got to this point\n> (anything else would have triggered an error in fetch).\n\nYeah, it kinda sounds like git is just being lazy, and can't be\nbothered to fetch it :-)\n"},{"id":"123110","messageId":"7v7hw2pmtk.fsf@alter.siamese.dyndns.org","threadId":"20916","inReplyTo":"20090913204231.GA8654@coredump.intra.peff.net","subject":"Re: Confusing git pull error message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-09-13T21:16:39Z","receivedAt":"2009-09-13T21:16:39Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Sun, Sep 13, 2009 at 01:38:48PM -0700, Junio C Hamano wrote:\n>\n>> I saw some discussion on improving the wording.  Here is what I plan to\n>> commit.\n>\n> Thanks for picking this up, I meant to re-post with improvements.\n\nI am _not_ going to commit the following patch, because it will interfere\nwith this clarification effort, but I think we want to do something along\nthis line after the \"clarification\" settles.\n\nAn observation I'd like to make is that this is way too ugly:\n\n\t[advice]\n        \tpullNoMergeFound = false\n                pushNonFastForward = false\n                statusHints = false\n\nthan\n\n\t[IKnowWhatIAmDoingThankYouVeryMuch]\n        \tpullNoMergeFound\n                pushNonFastForward\n                statusHints\n\nbut this feature is for people who know what they are doing, so I guess\nthe current set-up would be fine.\n\n git-pull.sh |   78 ++++++++++++++++++++++++++++++++++++++++------------------\n 1 files changed, 54 insertions(+), 24 deletions(-)\n\ndiff --git a/git-pull.sh b/git-pull.sh\nindex 0bbd5bf..101545e 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -76,14 +76,64 @@ do\n \tshift\n done\n \n+advice_tags_only () {\n+\tif test -z \"$1\"\n+\tthen\n+\t\techo \"Fetching tags only.\"\n+\t\treturn\n+\tfi\n+\techo \"Fetching tags only, you probably meant:\"\n+\techo \"  git fetch --tags\"\n+}\n+\n+advice_detached_head () {\n+\tif test -z \"$1\"\n+\tthen\n+\t\techo \"No default merge candidate on a detached HEAD.\"\n+\t\treturn\n+\tfi\n+\techo \"You are not currently on a branch, so I cannot use any\"\n+\techo \"'branch.<branchname>.merge' in your configuration file.\"\n+\techo \"Please specify which branch you want to merge on the command\"\n+\techo \"line and try again (e.g. 'git pull <repository> <refspec>').\"\n+\techo \"See git-pull(1) for details.\"\n+}\n+\n+advice_no_merge_candidates () {\n+\tif test -z \"$1\"\n+\tthen\n+\t\techo \"No merge candidate for the current branch fetched.\"\n+\t\treturn\n+\tfi\n+\tcat <<EOF\n+You asked me to pull without telling me which branch you\n+want to merge with, and 'branch.$2.merge' in\n+your configuration file does not tell me either.  Please\n+specify which branch you want to merge on the command line and\n+try again (e.g. 'git pull <repository> <refspec>').\n+See git-pull(1) for details.\n+\n+If you often merge with the same branch, you may want to\n+configure the following variables in your configuration\n+file:\n+\n+    branch.$2.remote = <nickname>\n+    branch.$2.merge = <remote-ref>\n+    remote.<nickname>.url = <url>\"\n+    remote.<nickname>.fetch = <refspec>\n+\n+See git-config(1) for details.\n+EOF\n+}\n+\n error_on_no_merge_candidates () {\n \texec >&2\n+\tadvice=$(git config --bool advice.pullNoMergeFound)\n \tfor opt\n \tdo\n \t\tcase \"$opt\" in\n \t\t-t|--t|--ta|--tag|--tags)\n-\t\t\techo \"Fetching tags only, you probably meant:\"\n-\t\t\techo \"  git fetch --tags\"\n+\t\t\tadvice_tags_only \"$advice\"\n \t\t\texit 1\n \t\tesac\n \tdone\n@@ -91,29 +141,9 @@ error_on_no_merge_candidates () {\n \tcurr_branch=${curr_branch#refs/heads/}\n \n \tif [ -z \"$curr_branch\" ]; then\n-\t\techo \"You are not currently on a branch, so I cannot use any\"\n-\t\techo \"'branch.<branchname>.merge' in your configuration file.\"\n-\t\techo \"Please specify which branch you want to merge on the command\"\n-\t\techo \"line and try again (e.g. 'git pull <repository> <refspec>').\"\n-\t\techo \"See git-pull(1) for details.\"\n+\t\tadvice_detached_head \"$advice\"\n \telse\n-\t\techo \"You asked me to pull without telling me which branch you\"\n-\t\techo \"want to merge with, and 'branch.${curr_branch}.merge' in\"\n-\t\techo \"your configuration file does not tell me either.\tPlease\"\n-\t\techo \"specify which branch you want to merge on the command line and\"\n-\t\techo \"try again (e.g. 'git pull <repository> <refspec>').\"\n-\t\techo \"See git-pull(1) for details.\"\n-\t\techo\n-\t\techo \"If you often merge with the same branch, you may want to\"\n-\t\techo \"configure the following variables in your configuration\"\n-\t\techo \"file:\"\n-\t\techo\n-\t\techo \"    branch.${curr_branch}.remote = <nickname>\"\n-\t\techo \"    branch.${curr_branch}.merge = <remote-ref>\"\n-\t\techo \"    remote.<nickname>.url = <url>\"\n-\t\techo \"    remote.<nickname>.fetch = <refspec>\"\n-\t\techo\n-\t\techo \"See git-config(1) for details.\"\n+\t\tadvice_no_merge_candidate \"$advice\" \"$curr_branch\"\n \tfi\n \texit 1\n }\n"},{"id":"123111","messageId":"7vy6oio86a.fsf@alter.siamese.dyndns.org","threadId":"20916","inReplyTo":"43d8ce650909131357m50428ffbs9c939be051254eb7@mail.gmail.com","subject":"Re: Confusing git pull error message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-09-13T21:18:21Z","receivedAt":"2009-09-13T21:18:21Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"John Tapsell <johnflux@gmail.com> writes:\n\n> Yeah, it kinda sounds like git is just being lazy, and can't be\n> bothered to fetch it :-)\n\nDo you want it to say \"you didn't tell us to fetch it\"?\n\nAfter all, we only do what the user instructs us to do, so I thought that\ngoes without saying it.\n"},{"id":"123115","messageId":"20090913213609.GA6993@sigill.intra.peff.net","threadId":"20916","inReplyTo":"7vfxaqpnpa.fsf@alter.siamese.dyndns.org","subject":"Re: Confusing git pull error message","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-09-13T21:36:09Z","receivedAt":"2009-09-13T21:36:09Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Sep 13, 2009 at 01:57:37PM -0700, Junio C Hamano wrote:\n\n> > What you have here is precisely what we observed. But I think one of the\n> > complaints was to say more explicitly \"that ref doesn't exist on the\n> > remote\", which I think should be the case if we have got to this point\n> > (anything else would have triggered an error in fetch).\n> \n> Wouldn't you get into the situation with this?\n> \n> \t[remote \"origin\"]\n>         \tfetch = refs/heads/master:refs/heads/master\n> \t[branch \"master\"]\n>         \tremote = origin\n>                 merge = refs/heads/next\n> \n> I think saying \"does not exist\" will repeat the same mistake of\n> overguessing you are trying to rectify.\n\nYou are right, of course. I think your wording makes sense, then\n(otherwise we get stuck with \"well, we didn't fetch it. Maybe because it\ndidn't exist. Or maybe because your configuration didn't include it.\").\n\n-Peff\n"},{"id":"123117","messageId":"7veiqamr5e.fsf@alter.siamese.dyndns.org","threadId":"20916","inReplyTo":"20090913213609.GA6993@sigill.intra.peff.net","subject":"Re: Confusing git pull error message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-09-13T22:11:25Z","receivedAt":"2009-09-13T22:11:25Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n>> I think saying \"does not exist\" will repeat the same mistake of\n>> overguessing you are trying to rectify.\n>\n> You are right, of course. I think your wording makes sense, then\n> (otherwise we get stuck with \"well, we didn't fetch it. Maybe because it\n> didn't exist. Or maybe because your configuration didn't include it.\").\n\nYeah, the saddest part of this whole story is that the message given by\nthe very original was succinct and accurate.\n\n   echo >&2 \"Warning: No merge candidate found because value of config option\n    \\\"branch.${curr_branch}.merge\\\" does not match any remote branch fetched.\"\n   echo >&2 \"No changes.\"\n\nThen we piled up different messages for various cases, and it went\ndownhill from there.\n\n - First, 8fc293c (Make git-pull complain and give advice when there is\n   nothing to merge with, 2007-10-02) made the message say essentially the\n   same thing, but with a lot more verbosity, covering only one _common_\n   case.\n\n - Then 441ed41 (\"git pull --tags\": error out with a better message.,\n   2007-12-28) added a special case for --tags.  The description before\n   8fc293c would have still been correct without this change.  This was\n   necessary because 8fc293c talked only about the \"I am on branch and\n   there is no configuration\" case.\n\n - Then 61e6108 (git-pull.sh: better warning message for \"git pull\" on\n   detached head., 2009-04-08) added another special case, again because\n   the \"helpful\" instruction given by 8fc293c did not make any sense in\n   the detached HEAD case.\n\nIt definitely is worth to further cover cases the message by 8fc293c did\nnot consider, as this thread suggested, but at the same time, I think the\nadvice mechanism should be used to bring back a succinct and to-the-point\nmessage, close to the original one, e.g.\n\n\tWarning: Not merging anything, as no default merge candidate ref\n\twas fetched from the remote.\n\nso that people who know what they are doing can squelch potentially\nmisleading \"helpful\" advices and diagnose/think for their own.\n"},{"id":"123120","messageId":"20090913223923.GA8840@coredump.intra.peff.net","threadId":"20916","inReplyTo":"7v7hw2pmtk.fsf@alter.siamese.dyndns.org","subject":"Re: Confusing git pull error message","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-09-13T22:39:23Z","receivedAt":"2009-09-13T22:39:23Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Sep 13, 2009 at 02:16:39PM -0700, Junio C Hamano wrote:\n\n> I am _not_ going to commit the following patch, because it will interfere\n> with this clarification effort, but I think we want to do something along\n> this line after the \"clarification\" settles.\n\nPlease, yes. When I first suggested the advice.* mechanism, I had a\nfeeling in the back of my mind that there were several such messages\nwhich had bothered me, but I didn't read through the code base looking\nfor them. But now that you mention it, this \"no merge candidate\" message\nis definitely one of them (not even because it's wrong or anything, but\nbecause of sheer _size_ of it).\n\n> An observation I'd like to make is that this is way too ugly:\n> \n> \t[advice]\n>         \tpullNoMergeFound = false\n>                 pushNonFastForward = false\n>                 statusHints = false\n> \n> than\n> \n> \t[IKnowWhatIAmDoingThankYouVeryMuch]\n>         \tpullNoMergeFound\n>                 pushNonFastForward\n>                 statusHints\n> \n> but this feature is for people who know what they are doing, so I guess\n> the current set-up would be fine.\n\nMaybe a nice shorthand would be '!' for negative booleans. I.e.,\n\n  [advice]\n  !pullNoMergeFound\n  !pushNonFastForward\n  !statusHints\n\n-Peff\n"},{"id":"123140","messageId":"20090914111432.GA15893@sigill.intra.peff.net","threadId":"20916","inReplyTo":"7v1vmar353.fsf@alter.siamese.dyndns.org","subject":"Re: Confusing git pull error message","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-09-14T11:14:32Z","receivedAt":"2009-09-14T11:14:32Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Sep 13, 2009 at 01:38:48PM -0700, Junio C Hamano wrote:\n\n> I saw some discussion on improving the wording.  Here is what I plan to\n> commit.\n> \n> diff --git a/git-pull.sh b/git-pull.sh\n> index 0bbd5bf..2c2fa79 100755\n> --- a/git-pull.sh\n> +++ b/git-pull.sh\n> @@ -89,6 +89,8 @@ error_on_no_merge_candidates () {\n>  \tdone\n>  \n>  \tcurr_branch=${curr_branch#refs/heads/}\n> +\tupstream=$(git config \"branch.$curr_branch.merge\" ||\n> +\t\t\tgit config \"branch.$curr_branch.rebase\")\n\nArgh, I made a mistake in my original patch which was retained in your\nversion. For some reason I was thinking that \"branch.*.rebase\" was an\n_alternative_ to branch.*.merge, but it is in fact a bool that modifies\nhow we interpret branch.*.merge (I think when the feature was originally\ndiscussed, that was one such proposal, and as I am not a user of the\nfeature, I proceeded with a totally bogus mental model since then).\n\nSo this really should read simply:\n\n  upstream=$(git config \"branch.$curr_branch.merge\")\n\n-Peff\n"},{"id":"124242","messageId":"4AC9D952.3050108@viscovery.net","threadId":"20916","inReplyTo":"7v1vmar353.fsf@alter.siamese.dyndns.org","subject":"Re: Confusing git pull error message","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-10-05T11:32:34Z","receivedAt":"2009-10-05T11:32:34Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Junio C Hamano schrieb:\n> Jeff King <peff@peff.net> writes:\n>> I think it is enough for git-pull to just check whether the config\n>> exists, and if so, guess that the ref was simply not fetched. IOW,\n>> this:\n> \n> Thanks.\n> \n> I saw some discussion on improving the wording.  Here is what I plan to\n> commit.\n> \n> diff --git a/git-pull.sh b/git-pull.sh\n> index 0bbd5bf..2c2fa79 100755\n> --- a/git-pull.sh\n> +++ b/git-pull.sh\n> @@ -89,6 +89,8 @@ error_on_no_merge_candidates () {\n>  \tdone\n>  \n>  \tcurr_branch=${curr_branch#refs/heads/}\n> +\tupstream=$(git config \"branch.$curr_branch.merge\" ||\n> +\t\t\tgit config \"branch.$curr_branch.rebase\")\n>  \n>  \tif [ -z \"$curr_branch\" ]; then\n>  \t\techo \"You are not currently on a branch, so I cannot use any\"\n> @@ -96,7 +98,7 @@ error_on_no_merge_candidates () {\n>  \t\techo \"Please specify which branch you want to merge on the command\"\n>  \t\techo \"line and try again (e.g. 'git pull <repository> <refspec>').\"\n>  \t\techo \"See git-pull(1) for details.\"\n> -\telse\n> +\telif [ -z \"$upstream\" ]; then\n>  \t\techo \"You asked me to pull without telling me which branch you\"\n>  \t\techo \"want to merge with, and 'branch.${curr_branch}.merge' in\"\n>  \t\techo \"your configuration file does not tell me either.\tPlease\"\n> @@ -114,6 +116,10 @@ error_on_no_merge_candidates () {\n>  \t\techo \"    remote.<nickname>.fetch = <refspec>\"\n>  \t\techo\n>  \t\techo \"See git-config(1) for details.\"\n> +\telse\n> +\t\techo \"Your configuration specifies to merge the ref\"\n> +\t\techo \"'${upstream#refs/heads/}' from the remote, but no such ref\"\n> +\t\techo \"was fetched.\"\n>  \tfi\n>  \texit 1\n>  }\n\nUnfortunately, this is not water-tight. See what I just observed:\n\n  $ git pull hk\n  From /exports/repos/hk/viscovery\n     9455552..6429037  master     -> hk/master\n  Your configuration specifies to merge the ref\n  'master' from the remote, but no such ref\n  was fetched.\n\nThe message is confusing when it says \"'master' was not fetched\" when\nclearly master _was_ fetched.\n\nMore importantly, the message is wrong to say that \"Your configuration\nspecifies to merge the ref 'master' from the remote\", because I have this\nconfiguration:\n\n  $ git config -l | egrep '^(remote|branch)'\n  remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*\n  remote.origin.url=/exports/repos/js/viscovery\n  branch.master.remote=origin\n  branch.master.merge=refs/heads/master\n  remote.hk.url=/exports/repos/hk/viscovery\n  remote.hk.fetch=+refs/heads/*:refs/remotes/hk/*\n\ni.e. while on master, I merge master from \"origin\", not from \"hk\".\n\n-- Hannes\n"},{"id":"124243","messageId":"20091005115308.GA2122@coredump.intra.peff.net","threadId":"20916","inReplyTo":"4AC9D952.3050108@viscovery.net","subject":"Re: Confusing git pull error message","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-10-05T11:53:08Z","receivedAt":"2009-10-05T11:53:08Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Oct 05, 2009 at 01:32:34PM +0200, Johannes Sixt wrote:\n\n> Unfortunately, this is not water-tight. See what I just observed:\n> \n>   $ git pull hk\n>   From /exports/repos/hk/viscovery\n>      9455552..6429037  master     -> hk/master\n>   Your configuration specifies to merge the ref\n>   'master' from the remote, but no such ref\n>   was fetched.\n> \n> The message is confusing when it says \"'master' was not fetched\" when\n> clearly master _was_ fetched.\n> \n> More importantly, the message is wrong to say that \"Your configuration\n> specifies to merge the ref 'master' from the remote\", because I have this\n> configuration:\n\nAh, yeah. Looking at %(upstream) from for-each-ref (which is how we\ndetermine to show that message) always uses the configured remote. But\nif we have asked for another remote, then that doesn't make much sense.\n\nSo I think we need something like this. I wasn't able to figure out a\ntest case to trigger the first code path below, though. It may not be\npossible; if we give a refspec on the command line, either it will be a\ncandidate for merging or, if it does not exist, fetch will barf. So it\nmay be that we can just collapse it down to a single case.\n\ndiff --git a/git-pull.sh b/git-pull.sh\nindex edf3ce3..a831db5 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -97,6 +97,18 @@ error_on_no_merge_candidates () {\n \t\techo \"Please specify which branch you want to merge on the command\"\n \t\techo \"line and try again (e.g. 'git pull <repository> <refspec>').\"\n \t\techo \"See git-pull(1) for details.\"\n+\telif [ -n \"$1\" ]; then\n+\t\tif [ $# -gt 1 ]; then\n+\t\t\techo \"You asked to pull from the remote '$1', but none\"\n+\t\t\techo \"of the things you asked to fetch were candidates\"\n+\t\t\techo \"for merging.\"\n+\t\telse\n+\t\t\techo \"You asked to pull from the remote '$1', but did\"\n+\t\t\techo \"not specify a branch to merge. Because this is\"\n+\t\t\techo \"not the default configured remote for your current\"\n+\t\t\techo \"branch, you must specify a branch on the command\"\n+\t\t\techo \"line.\"\n+\t\tfi\n \telif [ -z \"$upstream\" ]; then\n \t\techo \"You asked me to pull without telling me which branch you\"\n \t\techo \"want to merge with, and 'branch.${curr_branch}.merge' in\"\n"},{"id":"124245","messageId":"4AC9E2DE.8050108@viscovery.net","threadId":"20916","inReplyTo":"20091005115308.GA2122@coredump.intra.peff.net","subject":"Re: Confusing git pull error message","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-10-05T12:13:18Z","receivedAt":"2009-10-05T12:13:18Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Jeff King schrieb:\n> On Mon, Oct 05, 2009 at 01:32:34PM +0200, Johannes Sixt wrote:\n> Ah, yeah. Looking at %(upstream) from for-each-ref (which is how we\n> determine to show that message) always uses the configured remote. But\n> if we have asked for another remote, then that doesn't make much sense.\n> \n> So I think we need something like this. I wasn't able to figure out a\n> test case to trigger the first code path below, though. It may not be\n> possible; if we give a refspec on the command line, either it will be a\n> candidate for merging or, if it does not exist, fetch will barf. So it\n> may be that we can just collapse it down to a single case.\n> \n> diff --git a/git-pull.sh b/git-pull.sh\n> index edf3ce3..a831db5 100755\n> --- a/git-pull.sh\n> +++ b/git-pull.sh\n> @@ -97,6 +97,18 @@ error_on_no_merge_candidates () {\n>  \t\techo \"Please specify which branch you want to merge on the command\"\n>  \t\techo \"line and try again (e.g. 'git pull <repository> <refspec>').\"\n>  \t\techo \"See git-pull(1) for details.\"\n> +\telif [ -n \"$1\" ]; then\n> +\t\tif [ $# -gt 1 ]; then\n> +\t\t\techo \"You asked to pull from the remote '$1', but none\"\n> +\t\t\techo \"of the things you asked to fetch were candidates\"\n> +\t\t\techo \"for merging.\"\n> +\t\telse\n> +\t\t\techo \"You asked to pull from the remote '$1', but did\"\n> +\t\t\techo \"not specify a branch to merge. Because this is\"\n> +\t\t\techo \"not the default configured remote for your current\"\n> +\t\t\techo \"branch, you must specify a branch on the command\"\n> +\t\t\techo \"line.\"\n> +\t\tfi\n>  \telif [ -z \"$upstream\" ]; then\n>  \t\techo \"You asked me to pull without telling me which branch you\"\n>  \t\techo \"want to merge with, and 'branch.${curr_branch}.merge' in\"\n\nThanks, this gives a much better error message.\n\nBut, can we *please* have a more pleasantly wrapped message, even if this\ngrows lines in the source code beyond the 80 char limit? Like:\n\n\techo \"You asked to pull from the remote '$1',\"\n\techo \"but did not specify a branch to merge. Because this is\"\n\techo \"not the default configured remote for your current branch,\"\n\techo \"you must specify a branch on the command line.\"\n\nI.e.:\n\n- Reserve more room for a long $1 in the first line.\n\n- Don't wrap lines in \"current branch\" and \"command line\" when they are at\nthe end of a major logical unit of the sentence.\n\n-- Hannes\n"},{"id":"124266","messageId":"7vljjpacax.fsf@alter.siamese.dyndns.org","threadId":"20916","inReplyTo":"20091005115308.GA2122@coredump.intra.peff.net","subject":"Re: Confusing git pull error message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-05T19:08:38Z","receivedAt":"2009-10-05T19:08:38Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> So I think we need something like this. I wasn't able to figure out a\n> test case to trigger the first code path below, though. It may not be\n> possible; if we give a refspec on the command line, either it will be a\n> candidate for merging or, if it does not exist, fetch will barf. So it\n> may be that we can just collapse it down to a single case.\n\nI think you are right.\n\nBy the way, I think the other case arms in the case statement that has the\nsole caller of this function are never reached, no?\n\nBack when you added the check in a74b170 (git-pull: disallow implicit\nmerging to detached HEAD, 2007-01-15), $? referred to the error status of\nreading HEAD as a symbolic-ref so the check did make sense, but cd67e4d\n(Teach 'git pull' about --rebase, 2007-11-28) made a stupid mistake that\nnobody noticed.\n\n> diff --git a/git-pull.sh b/git-pull.sh\n> index edf3ce3..a831db5 100755\n> --- a/git-pull.sh\n> +++ b/git-pull.sh\n> @@ -97,6 +97,18 @@ error_on_no_merge_candidates () {\n>  \t\techo \"Please specify which branch you want to merge on the command\"\n>  \t\techo \"line and try again (e.g. 'git pull <repository> <refspec>').\"\n>  \t\techo \"See git-pull(1) for details.\"\n> +\telif [ -n \"$1\" ]; then\n> +\t\tif [ $# -gt 1 ]; then\n> +\t\t\techo \"You asked to pull from the remote '$1', but none\"\n> +\t\t\techo \"of the things you asked to fetch were candidates\"\n> +\t\t\techo \"for merging.\"\n> +\t\telse\n> +\t\t\techo \"You asked to pull from the remote '$1', but did\"\n> +\t\t\techo \"not specify a branch to merge. Because this is\"\n> +\t\t\techo \"not the default configured remote for your current\"\n> +\t\t\techo \"branch, you must specify a branch on the command\"\n> +\t\t\techo \"line.\"\n> +\t\tfi\n>  \telif [ -z \"$upstream\" ]; then\n>  \t\techo \"You asked me to pull without telling me which branch you\"\n>  \t\techo \"want to merge with, and 'branch.${curr_branch}.merge' in\"\n>\n"},{"id":"124267","messageId":"20091005191257.GA24305@coredump.intra.peff.net","threadId":"20916","inReplyTo":"7vljjpacax.fsf@alter.siamese.dyndns.org","subject":"Re: Confusing git pull error message","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-10-05T19:12:57Z","receivedAt":"2009-10-05T19:12:57Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Oct 05, 2009 at 12:08:38PM -0700, Junio C Hamano wrote:\n\n> Jeff King <peff@peff.net> writes:\n> \n> > So I think we need something like this. I wasn't able to figure out a\n> > test case to trigger the first code path below, though. It may not be\n> > possible; if we give a refspec on the command line, either it will be a\n> > candidate for merging or, if it does not exist, fetch will barf. So it\n> > may be that we can just collapse it down to a single case.\n> \n> I think you are right.\n\nNope, I'm not. I figured out one more case that it needs to handle.\nRevised patch coming up in a few minutes.\n\n> By the way, I think the other case arms in the case statement that has the\n> sole caller of this function are never reached, no?\n> \n> Back when you added the check in a74b170 (git-pull: disallow implicit\n> merging to detached HEAD, 2007-01-15), $? referred to the error status of\n> reading HEAD as a symbolic-ref so the check did make sense, but cd67e4d\n> (Teach 'git pull' about --rebase, 2007-11-28) made a stupid mistake that\n> nobody noticed.\n\nHmm. I'm not sure. I don't see how $? could not be zero, though, because\nthe last thing we run is a subshell with sed and tr. But beyond that, we\nactually handle the detached case in error_on_no_merge_candidates\nalready. So I think that case statement can simply be collapsed to the\nfirst case.\n\n-Peff\n"},{"id":"124270","messageId":"20091005193516.GB20078@coredump.intra.peff.net","threadId":"20916","inReplyTo":"20091005191257.GA24305@coredump.intra.peff.net","subject":"Re: Confusing git pull error message","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-10-05T19:35:16Z","receivedAt":"2009-10-05T19:35:16Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Oct 05, 2009 at 03:12:57PM -0400, Jeff King wrote:\n\n> > I think you are right.\n> \n> Nope, I'm not. I figured out one more case that it needs to handle.\n> Revised patch coming up in a few minutes.\n\nOK, here it is, which I think covers all of the cases. I also re-wrapped\nthe text, as I agree with JSixt that it was pretty ugly. I also\nre-wrapped some of the existing text, as it gave the very choppy:\n\n  Your configuration specifies to merge the ref\n  'foo' from the remote, but no such ref\n  was fetched.\n\nIt would be really nice to just pipe it through 'fmt', but I suspect\nthat will create portability problems.\n\n-- >8 --\nSubject: [PATCH] pull: improve advice for unconfigured error case\n\nThere are several reasons a git-pull invocation might not\nhave anything marked for merge:\n\n  1. We're not on a branch, so there is no branch\n     configuration.\n\n  2. We're on a branch, but there is no configuration for\n     this branch.\n\n  3. We fetched from the configured remote, but the\n     configured branch to merge didn't get fetched (either\n     it doesn't exist, or wasn't part of the fetch refspec).\n\n  4. We fetched from the non-default remote, but didn't\n     specify a branch to merge. We can't use the configured\n     one because it applies to the default remote.\n\n  5. We fetched from a specified remote, and a refspec was\n     given, but it ended up not fetching anything (this is\n     actually hard to do; if the refspec points to a remote\n     branch and it doesn't exist, then fetch will fail and\n     we never make it to this code path. But if you provide\n     a wildcard refspec like\n\n       refs/bogus/*:refs/remotes/origin/*\n\n     then you can see this failure).\n\nWe have handled (1) and (2) for some time. Recently, commit\na6dbf88 added code to handle case (3).\n\nThis patch handles cases (4) and (5), which previously just\nfell under other cases, producing a confusing message.\n\nWhile we're at it, let's rewrap the text for case (3), which\nlooks terribly ugly as it is.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n git-pull.sh |   16 ++++++++++++----\n 1 files changed, 12 insertions(+), 4 deletions(-)\n\ndiff --git a/git-pull.sh b/git-pull.sh\nindex edf3ce3..8b0b6f6 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -90,8 +90,17 @@ error_on_no_merge_candidates () {\n \n \tcurr_branch=${curr_branch#refs/heads/}\n \tupstream=$(git config \"branch.$curr_branch.merge\")\n+\tremote=$(git config \"branch.$curr_branch.remote\")\n \n-\tif [ -z \"$curr_branch\" ]; then\n+\tif [ $# -gt 1 ]; then\n+\t\techo \"There are no candidates for merging in the refs that you just fetched.\"\n+\t\techo \"Generally this means that you provided a wildcard refspec which had no\"\n+\t\techo \"matches on the remote end.\"\n+\telif [ $# -gt 0 ] && [ \"$1\" != \"$remote\" ]; then\n+\t\techo \"You asked to pull from the remote '$1', but did not specify\"\n+\t\techo \"a branch to merge. Because this is not the default configured remote\"\n+\t\techo \"for your current branch, you must specify a branch on the command line.\"\n+\telif [ -z \"$curr_branch\" ]; then\n \t\techo \"You are not currently on a branch, so I cannot use any\"\n \t\techo \"'branch.<branchname>.merge' in your configuration file.\"\n \t\techo \"Please specify which branch you want to merge on the command\"\n@@ -116,9 +125,8 @@ error_on_no_merge_candidates () {\n \t\techo\n \t\techo \"See git-config(1) for details.\"\n \telse\n-\t\techo \"Your configuration specifies to merge the ref\"\n-\t\techo \"'${upstream#refs/heads/}' from the remote, but no such ref\"\n-\t\techo \"was fetched.\"\n+\t\techo \"Your configuration specifies to merge the ref '${upstream#refs/heads/}' from the\"\n+\t\techo \"remote, but no such ref was fetched.\"\n \tfi\n \texit 1\n }\n-- \n1.6.5.rc2.219.g00ca\n"},{"id":"124269","messageId":"7vd451ab16.fsf@alter.siamese.dyndns.org","threadId":"20916","inReplyTo":"20091005191257.GA24305@coredump.intra.peff.net","subject":"Re: Confusing git pull error message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-05T19:36:05Z","receivedAt":"2009-10-05T19:36:05Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Mon, Oct 05, 2009 at 12:08:38PM -0700, Junio C Hamano wrote:\n>\n>> Jeff King <peff@peff.net> writes:\n>> \n>> > So I think we need something like this. I wasn't able to figure out a\n>> > test case to trigger the first code path below, though. It may not be\n>> > possible; if we give a refspec on the command line, either it will be a\n>> > candidate for merging or, if it does not exist, fetch will barf. So it\n>> > may be that we can just collapse it down to a single case.\n>> \n>> I think you are right.\n>\n> Nope, I'm not. I figured out one more case that it needs to handle.\n> Revised patch coming up in a few minutes.\n>\n>> By the way, I think the other case arms in the case statement that has the\n>> sole caller of this function are never reached, no?\n>> \n>> Back when you added the check in a74b170 (git-pull: disallow implicit\n>> merging to detached HEAD, 2007-01-15), $? referred to the error status of\n>> reading HEAD as a symbolic-ref so the check did make sense, but cd67e4d\n>> (Teach 'git pull' about --rebase, 2007-11-28) made a stupid mistake that\n>> nobody noticed.\n>\n> Hmm. I'm not sure. I don't see how $? could not be zero, though, because\n> the last thing we run is a subshell with sed and tr. But beyond that, we\n> actually handle the detached case in error_on_no_merge_candidates\n> already. So I think that case statement can simply be collapsed to the\n> first case.\n>\n> -Peff\n\n-- >8 --\nSubject: [PATCH] git-pull: dead code removal\n\nBack when a74b170 (git-pull: disallow implicit merging to detached HEAD,\n2007-01-15) added this check, $? referred to the error status of reading\nHEAD as a symbolic-ref; but cd67e4d (Teach 'git pull' about --rebase,\n2007-11-28) moved the command away from where the check is, and nobody\nnoticed the breakage.  Ever since, $? has always been 0 (tr at the end of\nthe pipe to find merge_head never fails) and other case arms were never\nreached.\n\nThese days, error_on_no_merge_candidates function is prepared to handle a\ndetached HEAD case, which was what the code this patch removes used to\nhandle.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n git-pull.sh |    9 +--------\n 1 files changed, 1 insertions(+), 8 deletions(-)\n\ndiff --git a/git-pull.sh b/git-pull.sh\nindex edf3ce3..66d73eb 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -182,14 +182,7 @@ merge_head=$(sed -e '/\tnot-for-merge\t/d' \\\n \n case \"$merge_head\" in\n '')\n-\tcase $? in\n-\t0) error_on_no_merge_candidates \"$@\";;\n-\t1) echo >&2 \"You are not currently on a branch; you must explicitly\"\n-\t   echo >&2 \"specify which branch you wish to merge:\"\n-\t   echo >&2 \"  git pull <remote> <branch>\"\n-\t   exit 1;;\n-\t*) exit $?;;\n-\tesac\n+\terror_on_no_merge_candidates \"$@\"\n \t;;\n ?*' '?*)\n \tif test -z \"$orig_head\"\n-- \n1.6.5.rc2.77.g2ea4a\n"},{"id":"124286","messageId":"20091005220032.GA29113@coredump.intra.peff.net","threadId":"20916","inReplyTo":"7vd451ab16.fsf@alter.siamese.dyndns.org","subject":"Re: Confusing git pull error message","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-10-05T22:00:32Z","receivedAt":"2009-10-05T22:00:32Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Oct 05, 2009 at 12:36:05PM -0700, Junio C Hamano wrote:\n\n> -- >8 --\n> Subject: [PATCH] git-pull: dead code removal\n> \n> Back when a74b170 (git-pull: disallow implicit merging to detached HEAD,\n> 2007-01-15) added this check, $? referred to the error status of reading\n> HEAD as a symbolic-ref; but cd67e4d (Teach 'git pull' about --rebase,\n> 2007-11-28) moved the command away from where the check is, and nobody\n> noticed the breakage.  Ever since, $? has always been 0 (tr at the end of\n> the pipe to find merge_head never fails) and other case arms were never\n> reached.\n> \n> These days, error_on_no_merge_candidates function is prepared to handle a\n> detached HEAD case, which was what the code this patch removes used to\n> handle.\n\nLooks good to me.\n\nAcked-by: Jeff King <peff@peff.net>\n\n-Peff\n"},{"id":"124405","messageId":"20091009070122.6117@nanako3.lavabit.com","threadId":"20916","inReplyTo":"20091005193516.GB20078@coredump.intra.peff.net","subject":"Re: Confusing git pull error message","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-10-08T22:01:22Z","receivedAt":"2009-10-08T22:01:22Z","isPatch":false,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Jeff King <peff@peff.net>\n\n> On Mon, Oct 05, 2009 at 03:12:57PM -0400, Jeff King wrote:\n>\n>> > I think you are right.\n>> \n>> Nope, I'm not. I figured out one more case that it needs to handle.\n>> Revised patch coming up in a few minutes.\n>\n> OK, here it is, which I think covers all of the cases. I also re-wrapped\n> the text, as I agree with JSixt that it was pretty ugly. I also\n> re-wrapped some of the existing text, as it gave the very choppy:\n>\n>   Your configuration specifies to merge the ref\n>   'foo' from the remote, but no such ref\n>   was fetched.\n>\n> It would be really nice to just pipe it through 'fmt', but I suspect\n> that will create portability problems.\n>\n> -- >8 --\n> Subject: [PATCH] pull: improve advice for unconfigured error case\n>\n> There are several reasons a git-pull invocation might not\n> have anything marked for merge:\n>\n>   1. We're not on a branch, so there is no branch\n>      configuration.\n>\n>   2. We're on a branch, but there is no configuration for\n>      this branch.\n>\n>   3. We fetched from the configured remote, but the\n>      configured branch to merge didn't get fetched (either\n>      it doesn't exist, or wasn't part of the fetch refspec).\n>\n>   4. We fetched from the non-default remote, but didn't\n>      specify a branch to merge. We can't use the configured\n>      one because it applies to the default remote.\n>\n>   5. We fetched from a specified remote, and a refspec was\n>      given, but it ended up not fetching anything (this is\n>      actually hard to do; if the refspec points to a remote\n>      branch and it doesn't exist, then fetch will fail and\n>      we never make it to this code path. But if you provide\n>      a wildcard refspec like\n>\n>        refs/bogus/*:refs/remotes/origin/*\n>\n>      then you can see this failure).\n>\n> We have handled (1) and (2) for some time. Recently, commit\n> a6dbf88 added code to handle case (3).\n>\n> This patch handles cases (4) and (5), which previously just\n> fell under other cases, producing a confusing message.\n>\n> While we're at it, let's rewrap the text for case (3), which\n> looks terribly ugly as it is.\n>\n> Signed-off-by: Jeff King <peff@peff.net>\n> ---\n>  git-pull.sh |   16 ++++++++++++----\n>  1 files changed, 12 insertions(+), 4 deletions(-)\n\nJunio, may I ask what happened to this patch?\n"},{"id":"124437","messageId":"7vy6nl10fg.fsf@alter.siamese.dyndns.org","threadId":"20916","inReplyTo":"20091009070122.6117@nanako3.lavabit.com","subject":"Re: Confusing git pull error message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-09T07:38:59Z","receivedAt":"2009-10-09T07:38:59Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nanako Shiraishi <nanako3@lavabit.com> writes:\n\n> Quoting Jeff King <peff@peff.net>\n>\n>> Subject: [PATCH] pull: improve advice for unconfigured error case\n>> ...\n> Junio, may I ask what happened to this patch?\n\nThanks for prodding.  Unfortunately I lost track.  Will look at it again\nbut probably not tonight.\n"},{"id":"124546","messageId":"7vbpkgf4m7.fsf@alter.siamese.dyndns.org","threadId":"20916","inReplyTo":"7vy6nl10fg.fsf@alter.siamese.dyndns.org","subject":"Re: Confusing git pull error message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-10T00:57:04Z","receivedAt":"2009-10-10T00:57:04Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Nanako Shiraishi <nanako3@lavabit.com> writes:\n>\n>> Quoting Jeff King <peff@peff.net>\n>>\n>>> Subject: [PATCH] pull: improve advice for unconfigured error case\n>>> ...\n>> Junio, may I ask what happened to this patch?\n>\n> Thanks for prodding.  Unfortunately I lost track.  Will look at it again\n> but probably not tonight.\n\nApplied the patch as-is, as it looked quite good.\n\nThanks.\n"}]}