Re: Confusing git pull error message
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 5, 2009, 19:08 UTC
- Message-ID
- <7vljjpacax.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <20091005115308.GA2122@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 5 quoted lines
> 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.
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.
Show 24 quoted lines
> diff --git a/git-pull.sh b/git-pull.sh
> index edf3ce3..a831db5 100755
> --- a/git-pull.sh
> +++ b/git-pull.sh
> @@ -97,6 +97,18 @@ error_on_no_merge_candidates () {
> echo "Please specify which branch you want to merge on the command"
> echo "line and try again (e.g. 'git pull <repository> <refspec>')."
> echo "See git-pull(1) for details."
> + elif [ -n "$1" ]; then
> + if [ $# -gt 1 ]; then
> + echo "You asked to pull from the remote '$1', but none"
> + echo "of the things you asked to fetch were candidates"
> + echo "for merging."
> + else
> + echo "You asked to pull from the remote '$1', but did"
> + echo "not specify a branch to merge. Because this is"
> + echo "not the default configured remote for your current"
> + echo "branch, you must specify a branch on the command"
> + echo "line."
> + fi
> elif [ -z "$upstream" ]; then
> echo "You asked me to pull without telling me which branch you"
> echo "want to merge with, and 'branch.${curr_branch}.merge' in"
>