git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: with git-next, git pull --rebase can print out "fatal: No such ref: ''" for branches without an upstream

From
John Keeping <john@keeping.me.uk>
Date
Jan 17, 2014, 19:26 UTC
Message-ID
<20140117192619.GP7608@serenity.lan>
In-Reply-To
<xmqq8uuexwp7.fsf@gitster.dls.corp.google.com>
On Fri, Jan 17, 2014 at 10:57:56AM -0800, Junio C Hamano wrote:
Show 19 quoted lines
> 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.

Show 17 quoted lines
> 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.
Previous: Junio C HamanoNext: John Keeping
Message 7 of 9 in “with git-next, git pull --rebase can print out "fatal: No such ref: ''" for branches without an upstream”
  1. Siddharth AgarwalJan 17, 2014
  2. Jeff KingJan 17, 2014
  3. Siddharth AgarwalJan 17, 2014
  4. John KeepingJan 17, 2014
  5. Siddharth AgarwalJan 17, 2014
  6. Junio C HamanoJan 17, 2014
  7. John KeepingJan 17, 2014
  8. pull: suppress error when no remoteref is foundJohn Keeping, Jan 17, 2014
  9. Junio C HamanoJan 17, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.