git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Junio C Hamano <gitster@pobox.com>,
	Johannes Sixt <j.sixt@viscovery.net>,
	John Tapsell <johnflux@gmail.com>, Git List <git@vger.kernel.org>
Subject: Re: Confusing git pull error message
Date: Mon, 05 Oct 2009 12:36:05 -0700	[thread overview]
Message-ID: <7vd451ab16.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20091005191257.GA24305@coredump.intra.peff.net> (Jeff King's message of "Mon\, 5 Oct 2009 15\:12\:57 -0400")

Jeff King <peff@peff.net> writes:

> On Mon, Oct 05, 2009 at 12:08:38PM -0700, Junio C Hamano wrote:
>
>> Jeff King <peff@peff.net> writes:
>> 
>> > So I think we need something like this. I wasn't able to figure out a
>> > test case to trigger the first code path below, though. It may not be
>> > possible; if we give a refspec on the command line, either it will be a
>> > candidate for merging or, if it does not exist, fetch will barf. So it
>> > may be that we can just collapse it down to a single case.
>> 
>> I think you are right.
>
> Nope, I'm not. I figured out one more case that it needs to handle.
> Revised patch coming up in a few minutes.
>
>> By the way, I think the other case arms in the case statement that has the
>> sole caller of this function are never reached, no?
>> 
>> Back when you added the check in a74b170 (git-pull: disallow implicit
>> merging to detached HEAD, 2007-01-15), $? referred to the error status of
>> reading HEAD as a symbolic-ref so the check did make sense, but cd67e4d
>> (Teach 'git pull' about --rebase, 2007-11-28) made a stupid mistake that
>> nobody noticed.
>
> Hmm. I'm not sure. I don't see how $? could not be zero, though, because
> the last thing we run is a subshell with sed and tr. But beyond that, we
> actually handle the detached case in error_on_no_merge_candidates
> already. So I think that case statement can simply be collapsed to the
> first case.
>
> -Peff

-- >8 --
Subject: [PATCH] git-pull: dead code removal

Back when a74b170 (git-pull: disallow implicit merging to detached HEAD,
2007-01-15) added this check, $? referred to the error status of reading
HEAD as a symbolic-ref; but cd67e4d (Teach 'git pull' about --rebase,
2007-11-28) moved the command away from where the check is, and nobody
noticed the breakage.  Ever since, $? has always been 0 (tr at the end of
the pipe to find merge_head never fails) and other case arms were never
reached.

These days, error_on_no_merge_candidates function is prepared to handle a
detached HEAD case, which was what the code this patch removes used to
handle.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-pull.sh |    9 +--------
 1 files changed, 1 insertions(+), 8 deletions(-)

diff --git a/git-pull.sh b/git-pull.sh
index edf3ce3..66d73eb 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -182,14 +182,7 @@ merge_head=$(sed -e '/	not-for-merge	/d' \
 
 case "$merge_head" in
 '')
-	case $? in
-	0) error_on_no_merge_candidates "$@";;
-	1) echo >&2 "You are not currently on a branch; you must explicitly"
-	   echo >&2 "specify which branch you wish to merge:"
-	   echo >&2 "  git pull <remote> <branch>"
-	   exit 1;;
-	*) exit $?;;
-	esac
+	error_on_no_merge_candidates "$@"
 	;;
 ?*' '?*)
 	if test -z "$orig_head"
-- 
1.6.5.rc2.77.g2ea4a

  parent reply	other threads:[~2009-10-05 19:37 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-12 20:01 Confusing git pull error message John Tapsell
2009-09-12 21:11 ` Jeff King
2009-09-12 21:31   ` John Tapsell
2009-09-12 22:34     ` Jeff King
2009-09-12 21:37   ` Sverre Rabbelier
2009-09-12 22:31     ` Jeff King
2009-09-12 22:37       ` Sverre Rabbelier
2009-09-13 20:38   ` Junio C Hamano
2009-09-13 20:42     ` Jeff King
2009-09-13 20:57       ` Junio C Hamano
2009-09-13 21:36         ` Jeff King
2009-09-13 22:11           ` Junio C Hamano
2009-09-13 20:57       ` John Tapsell
2009-09-13 21:18         ` Junio C Hamano
2009-09-13 21:16       ` Junio C Hamano
2009-09-13 22:39         ` Jeff King
2009-09-14 11:14     ` Jeff King
2009-10-05 11:32     ` Johannes Sixt
2009-10-05 11:53       ` Jeff King
2009-10-05 12:13         ` Johannes Sixt
2009-10-05 19:08         ` Junio C Hamano
2009-10-05 19:12           ` Jeff King
2009-10-05 19:35             ` Jeff King
2009-10-08 22:01               ` Nanako Shiraishi
2009-10-09  7:38                 ` Junio C Hamano
2009-10-10  0:57                   ` Junio C Hamano
2009-10-05 19:36             ` Junio C Hamano [this message]
2009-10-05 22:00               ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vd451ab16.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=j.sixt@viscovery.net \
    --cc=johnflux@gmail.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).