git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* with git-next, git pull --rebase can print out "fatal: No such ref: ''" for branches without an upstream
@ 2014-01-17  1:08 Siddharth Agarwal
  2014-01-17  2:21 ` Jeff King
  0 siblings, 1 reply; 9+ messages in thread
From: Siddharth Agarwal @ 2014-01-17  1:08 UTC (permalink / raw)
  To: git; +Cc: john

With git-next, where git pull --rebase can print out "fatal: No such 
ref: ''" if git pull --rebase is run on branches without an upstream.

With git at b139ac2589b15d55cd9fa5c6957da44b150d0737, the following 
commands demonstrate the problem:

git init repo1
cd repo1
touch a; git add a; git commit -m "a"
cd ..
git clone repo1 repo2
cd repo2
git config remote.origin.fetch refs/heads/master:refs/remotes/origin/master
git checkout -b test
git pull --rebase

This results in the following output:

fatal: No such ref: ''
Current branch test is up to date.

So the pull --rebase looks like it works, but it prints out a spurious 
fatal error.

I've managed to bisect this down to 
https://github.com/gitster/git/commit/48059e405028ebf8a09c5a9aede89dfb460cce98. 
Looks like get_remote_merge_branch is called without arguments, and it 
returns an empty string. This string is passed as-is to git merge-base, 
which causes the error.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: with git-next, git pull --rebase can print out "fatal: No such ref: ''" for branches without an upstream
  2014-01-17  1:08 with git-next, git pull --rebase can print out "fatal: No such ref: ''" for branches without an upstream Siddharth Agarwal
@ 2014-01-17  2:21 ` Jeff King
  2014-01-17  2:47   ` Siddharth Agarwal
  2014-01-17 18:57   ` Junio C Hamano
  0 siblings, 2 replies; 9+ messages in thread
From: Jeff King @ 2014-01-17  2:21 UTC (permalink / raw)
  To: Siddharth Agarwal; +Cc: git, john

On Thu, Jan 16, 2014 at 05:08:14PM -0800, Siddharth Agarwal wrote:

> With git-next, where git pull --rebase can print out "fatal: No such
> ref: ''" if git pull --rebase is run on branches without an upstream.

This is already fixed in bb3f458 (rebase: fix fork-point with zero
arguments, 2014-01-09), I think.

-Peff

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: with git-next, git pull --rebase can print out "fatal: No such ref: ''" for branches without an upstream
  2014-01-17  2:21 ` Jeff King
@ 2014-01-17  2:47   ` Siddharth Agarwal
  2014-01-17  8:40     ` John Keeping
  2014-01-17 18:57   ` Junio C Hamano
  1 sibling, 1 reply; 9+ messages in thread
From: Siddharth Agarwal @ 2014-01-17  2:47 UTC (permalink / raw)
  To: Jeff King; +Cc: git, john

On 01/16/2014 06:21 PM, Jeff King wrote:
> On Thu, Jan 16, 2014 at 05:08:14PM -0800, Siddharth Agarwal wrote:
>
>> With git-next, where git pull --rebase can print out "fatal: No such
>> ref: ''" if git pull --rebase is run on branches without an upstream.
> This is already fixed in bb3f458 (rebase: fix fork-point with zero
> arguments, 2014-01-09), I think.

If I'm reading the patch correctly, that only fixes it for git rebase, 
not for git pull --rebase. git-pull.sh contains a separate invocation of 
git merge-base --fork-point.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: with git-next, git pull --rebase can print out "fatal: No such ref: ''" for branches without an upstream
  2014-01-17  2:47   ` Siddharth Agarwal
@ 2014-01-17  8:40     ` John Keeping
  2014-01-17 18:09       ` Siddharth Agarwal
  0 siblings, 1 reply; 9+ messages in thread
From: John Keeping @ 2014-01-17  8:40 UTC (permalink / raw)
  To: Siddharth Agarwal; +Cc: Jeff King, git

On Thu, Jan 16, 2014 at 06:47:38PM -0800, Siddharth Agarwal wrote:
> On 01/16/2014 06:21 PM, Jeff King wrote:
> > On Thu, Jan 16, 2014 at 05:08:14PM -0800, Siddharth Agarwal wrote:
> >
> >> With git-next, where git pull --rebase can print out "fatal: No such
> >> ref: ''" if git pull --rebase is run on branches without an upstream.
> > This is already fixed in bb3f458 (rebase: fix fork-point with zero
> > arguments, 2014-01-09), I think.
> 
> If I'm reading the patch correctly, that only fixes it for git rebase, 
> not for git pull --rebase. git-pull.sh contains a separate invocation of 
> git merge-base --fork-point.

I'm pretty sure the invocation in git-pull.sh is OK.  The error then
comes out of git-rebase.sh when git-pull invokes it.

Are you running a version of git-next that includes bb3f458?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: with git-next, git pull --rebase can print out "fatal: No such ref: ''" for branches without an upstream
  2014-01-17  8:40     ` John Keeping
@ 2014-01-17 18:09       ` Siddharth Agarwal
  0 siblings, 0 replies; 9+ messages in thread
From: Siddharth Agarwal @ 2014-01-17 18:09 UTC (permalink / raw)
  To: John Keeping; +Cc: Jeff King, git

On 01/17/2014 12:40 AM, John Keeping wrote:
> On Thu, Jan 16, 2014 at 06:47:38PM -0800, Siddharth Agarwal wrote:
>> On 01/16/2014 06:21 PM, Jeff King wrote:
>>> On Thu, Jan 16, 2014 at 05:08:14PM -0800, Siddharth Agarwal wrote:
>>>
>>>> With git-next, where git pull --rebase can print out "fatal: No such
>>>> ref: ''" if git pull --rebase is run on branches without an upstream.
>>> This is already fixed in bb3f458 (rebase: fix fork-point with zero
>>> arguments, 2014-01-09), I think.
>> If I'm reading the patch correctly, that only fixes it for git rebase,
>> not for git pull --rebase. git-pull.sh contains a separate invocation of
>> git merge-base --fork-point.
> I'm pretty sure the invocation in git-pull.sh is OK.  The error then
> comes out of git-rebase.sh when git-pull invokes it.

That doesn't square with 48059e4 being the culprit commit.

> Are you running a version of git-next that includes bb3f458?

Yes, I am.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: with git-next, git pull --rebase can print out "fatal: No such ref: ''" for branches without an upstream
  2014-01-17  2:21 ` Jeff King
  2014-01-17  2:47   ` Siddharth Agarwal
@ 2014-01-17 18:57   ` Junio C Hamano
  2014-01-17 19:26     ` John Keeping
  1 sibling, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2014-01-17 18:57 UTC (permalink / raw)
  To: Jeff King; +Cc: Siddharth Agarwal, git, john

Jeff King <peff@peff.net> writes:

> On Thu, Jan 16, 2014 at 05:08:14PM -0800, Siddharth Agarwal wrote:
>
>> With git-next, where git pull --rebase can print out "fatal: No such
>> ref: ''" if git pull --rebase is run on branches without an upstream.
>
> This is already fixed in bb3f458 (rebase: fix fork-point with zero
> arguments, 2014-01-09), I think.

Doesn't the call to get_remote_merge_branch in this part

        test -n "$curr_branch" &&
        . git-parse-remote &&
        remoteref="$(get_remote_merge_branch "$@" 2>/dev/null)" &&
        oldremoteref=$(git merge-base --fork-point "$remoteref" $curr_branch)

yield an empty string, feeding it to "merge-base --fork-point" as
its first parameter?

Perhaps something like this is needed?

 git-pull.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/git-pull.sh b/git-pull.sh
index 605e957..467c66c 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -229,6 +229,7 @@ test true = "$rebase" && {
 	test -n "$curr_branch" &&
 	. git-parse-remote &&
 	remoteref="$(get_remote_merge_branch "$@" 2>/dev/null)" &&
+	test -n "$remoteref" &&
 	oldremoteref=$(git merge-base --fork-point "$remoteref" $curr_branch)
 }
 orig_head=$(git rev-parse -q --verify HEAD)

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: with git-next, git pull --rebase can print out "fatal: No such ref: ''" for branches without an upstream
  2014-01-17 18:57   ` Junio C Hamano
@ 2014-01-17 19:26     ` John Keeping
  2014-01-17 20:00       ` [PATCH] pull: suppress error when no remoteref is found John Keeping
  2014-01-17 20:02       ` with git-next, git pull --rebase can print out "fatal: No such ref: ''" for branches without an upstream Junio C Hamano
  0 siblings, 2 replies; 9+ messages in thread
From: John Keeping @ 2014-01-17 19:26 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jeff King, Siddharth Agarwal, git

On Fri, Jan 17, 2014 at 10:57:56AM -0800, Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
> 
> > On Thu, Jan 16, 2014 at 05:08:14PM -0800, Siddharth Agarwal wrote:
> >
> >> With git-next, where git pull --rebase can print out "fatal: No such
> >> ref: ''" if git pull --rebase is run on branches without an upstream.
> >
> > This is already fixed in bb3f458 (rebase: fix fork-point with zero
> > arguments, 2014-01-09), I think.
> 
> Doesn't the call to get_remote_merge_branch in this part
> 
>         test -n "$curr_branch" &&
>         . git-parse-remote &&
>         remoteref="$(get_remote_merge_branch "$@" 2>/dev/null)" &&
>         oldremoteref=$(git merge-base --fork-point "$remoteref" $curr_branch)
> 
> yield an empty string, feeding it to "merge-base --fork-point" as
> its first parameter?

For some reason I assumed that get_remote_merge_branch would either
yield a non-empty string or return failure, meaning that the &&-chain
makes everything OK.

Before the change to use "merge-base --fork-point", the code was:

	oldremoteref="$(git rev-parse -q --verify "$remoteref")" &&
	for reflog in $(git rev-list -g $remoteref 2>/dev/null)
	do
		if test "$reflog" = "$(git merge-base $reflog $curr_branch)"
		then
			oldremoteref="$reflog"
			break
		fi
	done

which has a similar failure - rev-list requires a revision argument and
prints its usage if not given one.

> Perhaps something like this is needed?
> 
>  git-pull.sh | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/git-pull.sh b/git-pull.sh
> index 605e957..467c66c 100755
> --- a/git-pull.sh
> +++ b/git-pull.sh
> @@ -229,6 +229,7 @@ test true = "$rebase" && {
>  	test -n "$curr_branch" &&
>  	. git-parse-remote &&
>  	remoteref="$(get_remote_merge_branch "$@" 2>/dev/null)" &&
> +	test -n "$remoteref" &&
>  	oldremoteref=$(git merge-base --fork-point "$remoteref" $curr_branch)
>  }
>  orig_head=$(git rev-parse -q --verify HEAD)

Either that or "2>/dev/null" like in the original, yes.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] pull: suppress error when no remoteref is found
  2014-01-17 19:26     ` John Keeping
@ 2014-01-17 20:00       ` John Keeping
  2014-01-17 20:02       ` with git-next, git pull --rebase can print out "fatal: No such ref: ''" for branches without an upstream Junio C Hamano
  1 sibling, 0 replies; 9+ messages in thread
From: John Keeping @ 2014-01-17 20:00 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Jeff King, Siddharth Agarwal, John Keeping

Commit 48059e4 (pull: use merge-base --fork-point when appropriate,
2013-12-08) incorrectly assumes that get_remote_merge_branch will either
yield a non-empty string or return an error, but there are circumstances
where it will yield an empty string.

The previous code then invoked git-rev-list with no arguments, which
results in an error suppressed by redirecting stderr to /dev/null.  Now
we invoke git-merge-base with an empty branch name, which also results
in an error.  Suppress this in the same way.

Signed-off-by: John Keeping <john@keeping.me.uk>
---
 git-pull.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-pull.sh b/git-pull.sh
index f210d0a..0a5aa2c 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -229,7 +229,7 @@ test true = "$rebase" && {
 	test -n "$curr_branch" &&
 	. git-parse-remote &&
 	remoteref="$(get_remote_merge_branch "$@" 2>/dev/null)" &&
-	oldremoteref=$(git merge-base --fork-point "$remoteref" $curr_branch)
+	oldremoteref=$(git merge-base --fork-point "$remoteref" $curr_branch 2>/dev/null)
 }
 orig_head=$(git rev-parse -q --verify HEAD)
 git fetch $verbosity $progress $dry_run $recurse_submodules --update-head-ok "$@" || exit 1
-- 
1.8.5.226.g0d60d77

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: with git-next, git pull --rebase can print out "fatal: No such ref: ''" for branches without an upstream
  2014-01-17 19:26     ` John Keeping
  2014-01-17 20:00       ` [PATCH] pull: suppress error when no remoteref is found John Keeping
@ 2014-01-17 20:02       ` Junio C Hamano
  1 sibling, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2014-01-17 20:02 UTC (permalink / raw)
  To: John Keeping; +Cc: Jeff King, Siddharth Agarwal, git

John Keeping <john@keeping.me.uk> writes:

>> Perhaps something like this is needed?
>>  ...
> Either that or "2>/dev/null" like in the original, yes.

Ah, that makes sense.  I see you already followed-up with a patch,
so I'll pick it up.

Thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-01-17 20:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-17  1:08 with git-next, git pull --rebase can print out "fatal: No such ref: ''" for branches without an upstream Siddharth Agarwal
2014-01-17  2:21 ` Jeff King
2014-01-17  2:47   ` Siddharth Agarwal
2014-01-17  8:40     ` John Keeping
2014-01-17 18:09       ` Siddharth Agarwal
2014-01-17 18:57   ` Junio C Hamano
2014-01-17 19:26     ` John Keeping
2014-01-17 20:00       ` [PATCH] pull: suppress error when no remoteref is found John Keeping
2014-01-17 20:02       ` with git-next, git pull --rebase can print out "fatal: No such ref: ''" for branches without an upstream Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).