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

Re: [PATCH] git-{parse-remote,pull}: throw away stderr of git-symbolic-ref

From
Junio C Hamano <junkio@cox.net>
Date
Jan 15, 2007, 22:07 UTC
Message-ID
<7vk5zo0ws1.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20070115212442.GA7409@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 6 quoted lines
> We look up the destination of the HEAD symref in order to get the
> default remote and merge head for the current branch. However, if we
> have a detached HEAD, there is no current branch. We handle this
> situation by looking up branch..remote, which is empty.
> Unfortunately, git-symbolic-ref complained to stderr, potentially
> scaring users.

I think what I sent out was a moral equivalent, but generally speaking I do not think we should discard stderr output indiscriminatingly.

Show 13 quoted lines
> diff --git a/git-pull.sh b/git-pull.sh
> index 9592617..f0cc023 100755
> --- a/git-pull.sh
> +++ b/git-pull.sh
> @@ -83,7 +83,7 @@ merge_head=$(sed -e '/	not-for-merge	/d' \
>  
>  case "$merge_head" in
>  '')
> -	curr_branch=$(git-symbolic-ref HEAD | \
> +	curr_branch=$(git-symbolic-ref HEAD 2>/dev/null | \
>  		sed -e 's|^refs/heads/||')
>  	echo >&2 "Warning: No merge candidate found because value of config option
>           \"branch.${curr_branch}.merge\" does not match any remote branch fetched."

I missed this one, but I think this needs a bit more through rework. This is what happens when you say "git pull origin" while your HEAD is detached, and specifying "branch..merge" in the configuration should not be the way to define the default remote branch to be merged while on a detached HEAD. In fact, I think there should not be any such default.

I think it makes more sense to say "your HEAD is detached and you need to explicitly say which branch you would want to merge in" in this case.

Previous: Jeff KingNext: Jeff King
Message 3 of 7 in “git-fetch while on "(no branch)"”
  1. Andy ParkinsJan 15, 2007
  2. git-{parse-remote,pull}: throw away stderr of git-symbolic-refJeff King, Jan 15, 2007
  3. Junio C HamanoJan 15, 2007
  4. git-pull: disallow implicit merging to detached HEADJeff King, Jan 15, 2007
  5. Jeff KingJan 15, 2007
  6. Junio C HamanoJan 15, 2007
  7. Jeff KingJan 15, 2007

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.