{"thread":{"id":"35677","subject":"with git-next, git pull --rebase can print out \"fatal: No such ref: ''\" for branches without an upstream","startedAt":"2014-01-17T01:08:14Z","lastAt":"2014-01-17T20:02:32Z","messageCount":9,"participants":["Siddharth Agarwal","Jeff King","John Keeping","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"233240","messageId":"52D8827E.3060007@fb.com","threadId":"35677","inReplyTo":null,"subject":"with git-next, git pull --rebase can print out \"fatal: No such ref: ''\" for branches without an upstream","fromName":"Siddharth Agarwal","fromEmail":"sid0@fb.com","sentAt":"2014-01-17T01:08:14Z","receivedAt":"2014-01-17T01:08:14Z","isPatch":false,"sender":{"key":"sid0@fb.com","avatar":null},"body":"With git-next, where git pull --rebase can print out \"fatal: No such \nref: ''\" if git pull --rebase is run on branches without an upstream.\n\nWith git at b139ac2589b15d55cd9fa5c6957da44b150d0737, the following \ncommands demonstrate the problem:\n\ngit init repo1\ncd repo1\ntouch a; git add a; git commit -m \"a\"\ncd ..\ngit clone repo1 repo2\ncd repo2\ngit config remote.origin.fetch refs/heads/master:refs/remotes/origin/master\ngit checkout -b test\ngit pull --rebase\n\nThis results in the following output:\n\nfatal: No such ref: ''\nCurrent branch test is up to date.\n\nSo the pull --rebase looks like it works, but it prints out a spurious \nfatal error.\n\nI've managed to bisect this down to \nhttps://github.com/gitster/git/commit/48059e405028ebf8a09c5a9aede89dfb460cce98. \nLooks like get_remote_merge_branch is called without arguments, and it \nreturns an empty string. This string is passed as-is to git merge-base, \nwhich causes the error.\n"},{"id":"233250","messageId":"20140117022152.GB12444@sigill.intra.peff.net","threadId":"35677","inReplyTo":"52D8827E.3060007@fb.com","subject":"Re: with git-next, git pull --rebase can print out \"fatal: No such ref: ''\" for branches without an upstream","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2014-01-17T02:21:52Z","receivedAt":"2014-01-17T02:21:52Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jan 16, 2014 at 05:08:14PM -0800, Siddharth Agarwal wrote:\n\n> With git-next, where git pull --rebase can print out \"fatal: No such\n> ref: ''\" if git pull --rebase is run on branches without an upstream.\n\nThis is already fixed in bb3f458 (rebase: fix fork-point with zero\narguments, 2014-01-09), I think.\n\n-Peff\n"},{"id":"233258","messageId":"52D899CA.5050409@fb.com","threadId":"35677","inReplyTo":"20140117022152.GB12444@sigill.intra.peff.net","subject":"Re: with git-next, git pull --rebase can print out \"fatal: No such ref: ''\" for branches without an upstream","fromName":"Siddharth Agarwal","fromEmail":"sid0@fb.com","sentAt":"2014-01-17T02:47:38Z","receivedAt":"2014-01-17T02:47:38Z","isPatch":false,"sender":{"key":"sid0@fb.com","avatar":null},"body":"On 01/16/2014 06:21 PM, Jeff King wrote:\n> On Thu, Jan 16, 2014 at 05:08:14PM -0800, Siddharth Agarwal wrote:\n>\n>> With git-next, where git pull --rebase can print out \"fatal: No such\n>> ref: ''\" if git pull --rebase is run on branches without an upstream.\n> This is already fixed in bb3f458 (rebase: fix fork-point with zero\n> arguments, 2014-01-09), I think.\n\nIf I'm reading the patch correctly, that only fixes it for git rebase, \nnot for git pull --rebase. git-pull.sh contains a separate invocation of \ngit merge-base --fork-point.\n"},{"id":"233269","messageId":"20140117084010.GL7608@serenity.lan","threadId":"35677","inReplyTo":"52D899CA.5050409@fb.com","subject":"Re: with git-next, git pull --rebase can print out \"fatal: No such ref: ''\" for branches without an upstream","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2014-01-17T08:40:10Z","receivedAt":"2014-01-17T08:40:10Z","isPatch":false,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"On Thu, Jan 16, 2014 at 06:47:38PM -0800, Siddharth Agarwal wrote:\n> On 01/16/2014 06:21 PM, Jeff King wrote:\n> > On Thu, Jan 16, 2014 at 05:08:14PM -0800, Siddharth Agarwal wrote:\n> >\n> >> With git-next, where git pull --rebase can print out \"fatal: No such\n> >> ref: ''\" if git pull --rebase is run on branches without an upstream.\n> > This is already fixed in bb3f458 (rebase: fix fork-point with zero\n> > arguments, 2014-01-09), I think.\n> \n> If I'm reading the patch correctly, that only fixes it for git rebase, \n> not for git pull --rebase. git-pull.sh contains a separate invocation of \n> git merge-base --fork-point.\n\nI'm pretty sure the invocation in git-pull.sh is OK.  The error then\ncomes out of git-rebase.sh when git-pull invokes it.\n\nAre you running a version of git-next that includes bb3f458?\n"},{"id":"233294","messageId":"52D971E3.8090406@fb.com","threadId":"35677","inReplyTo":"20140117084010.GL7608@serenity.lan","subject":"Re: with git-next, git pull --rebase can print out \"fatal: No such ref: ''\" for branches without an upstream","fromName":"Siddharth Agarwal","fromEmail":"sid0@fb.com","sentAt":"2014-01-17T18:09:39Z","receivedAt":"2014-01-17T18:09:39Z","isPatch":false,"sender":{"key":"sid0@fb.com","avatar":null},"body":"On 01/17/2014 12:40 AM, John Keeping wrote:\n> On Thu, Jan 16, 2014 at 06:47:38PM -0800, Siddharth Agarwal wrote:\n>> On 01/16/2014 06:21 PM, Jeff King wrote:\n>>> On Thu, Jan 16, 2014 at 05:08:14PM -0800, Siddharth Agarwal wrote:\n>>>\n>>>> With git-next, where git pull --rebase can print out \"fatal: No such\n>>>> ref: ''\" if git pull --rebase is run on branches without an upstream.\n>>> This is already fixed in bb3f458 (rebase: fix fork-point with zero\n>>> arguments, 2014-01-09), I think.\n>> If I'm reading the patch correctly, that only fixes it for git rebase,\n>> not for git pull --rebase. git-pull.sh contains a separate invocation of\n>> git merge-base --fork-point.\n> I'm pretty sure the invocation in git-pull.sh is OK.  The error then\n> comes out of git-rebase.sh when git-pull invokes it.\n\nThat doesn't square with 48059e4 being the culprit commit.\n\n> Are you running a version of git-next that includes bb3f458?\n\nYes, I am.\n"},{"id":"233299","messageId":"xmqq8uuexwp7.fsf@gitster.dls.corp.google.com","threadId":"35677","inReplyTo":"20140117022152.GB12444@sigill.intra.peff.net","subject":"Re: with git-next, git pull --rebase can print out \"fatal: No such ref: ''\" for branches without an upstream","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-01-17T18:57:56Z","receivedAt":"2014-01-17T18:57:56Z","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 Thu, Jan 16, 2014 at 05:08:14PM -0800, Siddharth Agarwal wrote:\n>\n>> With git-next, where git pull --rebase can print out \"fatal: No such\n>> ref: ''\" if git pull --rebase is run on branches without an upstream.\n>\n> This is already fixed in bb3f458 (rebase: fix fork-point with zero\n> arguments, 2014-01-09), I think.\n\nDoesn't the call to get_remote_merge_branch in this part\n\n        test -n \"$curr_branch\" &&\n        . git-parse-remote &&\n        remoteref=\"$(get_remote_merge_branch \"$@\" 2>/dev/null)\" &&\n        oldremoteref=$(git merge-base --fork-point \"$remoteref\" $curr_branch)\n\nyield an empty string, feeding it to \"merge-base --fork-point\" as\nits first parameter?\n\nPerhaps something like this is needed?\n\n git-pull.sh | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/git-pull.sh b/git-pull.sh\nindex 605e957..467c66c 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -229,6 +229,7 @@ test true = \"$rebase\" && {\n \ttest -n \"$curr_branch\" &&\n \t. git-parse-remote &&\n \tremoteref=\"$(get_remote_merge_branch \"$@\" 2>/dev/null)\" &&\n+\ttest -n \"$remoteref\" &&\n \toldremoteref=$(git merge-base --fork-point \"$remoteref\" $curr_branch)\n }\n orig_head=$(git rev-parse -q --verify HEAD)\n"},{"id":"233306","messageId":"20140117192619.GP7608@serenity.lan","threadId":"35677","inReplyTo":"xmqq8uuexwp7.fsf@gitster.dls.corp.google.com","subject":"Re: with git-next, git pull --rebase can print out \"fatal: No such ref: ''\" for branches without an upstream","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2014-01-17T19:26:19Z","receivedAt":"2014-01-17T19:26:19Z","isPatch":false,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"On Fri, Jan 17, 2014 at 10:57:56AM -0800, Junio C Hamano wrote:\n> Jeff King <peff@peff.net> writes:\n> \n> > On Thu, Jan 16, 2014 at 05:08:14PM -0800, Siddharth Agarwal wrote:\n> >\n> >> With git-next, where git pull --rebase can print out \"fatal: No such\n> >> ref: ''\" if git pull --rebase is run on branches without an upstream.\n> >\n> > This is already fixed in bb3f458 (rebase: fix fork-point with zero\n> > arguments, 2014-01-09), I think.\n> \n> Doesn't the call to get_remote_merge_branch in this part\n> \n>         test -n \"$curr_branch\" &&\n>         . git-parse-remote &&\n>         remoteref=\"$(get_remote_merge_branch \"$@\" 2>/dev/null)\" &&\n>         oldremoteref=$(git merge-base --fork-point \"$remoteref\" $curr_branch)\n> \n> yield an empty string, feeding it to \"merge-base --fork-point\" as\n> its first parameter?\n\nFor some reason I assumed that get_remote_merge_branch would either\nyield a non-empty string or return failure, meaning that the &&-chain\nmakes everything OK.\n\nBefore the change to use \"merge-base --fork-point\", the code was:\n\n\toldremoteref=\"$(git rev-parse -q --verify \"$remoteref\")\" &&\n\tfor reflog in $(git rev-list -g $remoteref 2>/dev/null)\n\tdo\n\t\tif test \"$reflog\" = \"$(git merge-base $reflog $curr_branch)\"\n\t\tthen\n\t\t\toldremoteref=\"$reflog\"\n\t\t\tbreak\n\t\tfi\n\tdone\n\nwhich has a similar failure - rev-list requires a revision argument and\nprints its usage if not given one.\n\n> Perhaps something like this is needed?\n> \n>  git-pull.sh | 1 +\n>  1 file changed, 1 insertion(+)\n> \n> diff --git a/git-pull.sh b/git-pull.sh\n> index 605e957..467c66c 100755\n> --- a/git-pull.sh\n> +++ b/git-pull.sh\n> @@ -229,6 +229,7 @@ test true = \"$rebase\" && {\n>  \ttest -n \"$curr_branch\" &&\n>  \t. git-parse-remote &&\n>  \tremoteref=\"$(get_remote_merge_branch \"$@\" 2>/dev/null)\" &&\n> +\ttest -n \"$remoteref\" &&\n>  \toldremoteref=$(git merge-base --fork-point \"$remoteref\" $curr_branch)\n>  }\n>  orig_head=$(git rev-parse -q --verify HEAD)\n\nEither that or \"2>/dev/null\" like in the original, yes.\n"},{"id":"233311","messageId":"509ac5f3245546def79575174c52de2d0416fe24.1389988820.git.john@keeping.me.uk","threadId":"35677","inReplyTo":"20140117192619.GP7608@serenity.lan","subject":"[PATCH] pull: suppress error when no remoteref is found","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2014-01-17T20:00:20Z","receivedAt":"2014-01-17T20:00:20Z","isPatch":true,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"Commit 48059e4 (pull: use merge-base --fork-point when appropriate,\n2013-12-08) incorrectly assumes that get_remote_merge_branch will either\nyield a non-empty string or return an error, but there are circumstances\nwhere it will yield an empty string.\n\nThe previous code then invoked git-rev-list with no arguments, which\nresults in an error suppressed by redirecting stderr to /dev/null.  Now\nwe invoke git-merge-base with an empty branch name, which also results\nin an error.  Suppress this in the same way.\n\nSigned-off-by: John Keeping <john@keeping.me.uk>\n---\n git-pull.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/git-pull.sh b/git-pull.sh\nindex f210d0a..0a5aa2c 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -229,7 +229,7 @@ test true = \"$rebase\" && {\n \ttest -n \"$curr_branch\" &&\n \t. git-parse-remote &&\n \tremoteref=\"$(get_remote_merge_branch \"$@\" 2>/dev/null)\" &&\n-\toldremoteref=$(git merge-base --fork-point \"$remoteref\" $curr_branch)\n+\toldremoteref=$(git merge-base --fork-point \"$remoteref\" $curr_branch 2>/dev/null)\n }\n orig_head=$(git rev-parse -q --verify HEAD)\n git fetch $verbosity $progress $dry_run $recurse_submodules --update-head-ok \"$@\" || exit 1\n-- \n1.8.5.226.g0d60d77\n"},{"id":"233313","messageId":"xmqqeh46wf53.fsf@gitster.dls.corp.google.com","threadId":"35677","inReplyTo":"20140117192619.GP7608@serenity.lan","subject":"Re: with git-next, git pull --rebase can print out \"fatal: No such ref: ''\" for branches without an upstream","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-01-17T20:02:32Z","receivedAt":"2014-01-17T20:02:32Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"John Keeping <john@keeping.me.uk> writes:\n\n>> Perhaps something like this is needed?\n>>  ...\n> Either that or \"2>/dev/null\" like in the original, yes.\n\nAh, that makes sense.  I see you already followed-up with a patch,\nso I'll pick it up.\n\nThanks.\n"}]}