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

Re: [PATCH] pull: clarify advice for the unconfigured error case

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 2, 2009, 23:08 UTC
Message-ID
<7vk4x57z4e.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20091127141704.GA24080@progeny.tock>
Jonathan Nieder <jrnieder@gmail.com> writes:
Show 5 quoted lines
> From: Jan Krüger <jk@jk.gs>
>
> When pull --rebase fails because it cannot find what branch to
> merge against, the error message implies we are trying to merge.
> Say "rebase against" instead of "merge with" to avoid confusion.

I was going over the mail archive to see if I missed any important fixes that should be in before 1.6.6 final and noticed that this is not applied, and there was no follow-up to this message either.

Is this a good replacement for 31971b3 (git-pull.sh --rebase: overhaul error handling when no candidates are found, 2009-11-12) that is on 'pu' and does the lack of follow-up mean everybody involved in the discussion is happy with this version?

Show 85 quoted lines
> diff --git a/git-pull.sh b/git-pull.sh
> index 37f3d93..2c384c4 100755
> --- a/git-pull.sh
> +++ b/git-pull.sh
> @@ -91,45 +91,63 @@ error_on_no_merge_candidates () {
>  		esac
>  	done
>  
> +	if test true = "$rebase"
> +	then
> +		op_type=rebase
> +		op_prep=against
> +	else
> +		op_type=merge
> +		op_prep=with
> +	fi
> +
>  	curr_branch=${curr_branch#refs/heads/}
>  	upstream=$(git config "branch.$curr_branch.merge")
>  	remote=$(git config "branch.$curr_branch.remote")
>  
>  	if [ $# -gt 1 ]; then
> -		echo "There are no candidates for merging in the refs that you just fetched."
> +		if [ "$rebase" = true ]; then
> +			printf "There is no candidate for rebasing against "
> +		else
> +			printf "There are no candidates for merging "
> +		fi
> +		echo "among the refs that you just fetched."
>  		echo "Generally this means that you provided a wildcard refspec which had no"
>  		echo "matches on the remote end."
>  	elif [ $# -gt 0 ] && [ "$1" != "$remote" ]; then
>  		echo "You asked to pull from the remote '$1', but did not specify"
> -		echo "a branch to merge. Because this is not the default configured remote"
> +		echo "a branch. Because this is not the default configured remote"
>  		echo "for your current branch, you must specify a branch on the command line."
>  	elif [ -z "$curr_branch" ]; then
>  		echo "You are not currently on a branch, so I cannot use any"
>  		echo "'branch.<branchname>.merge' in your configuration file."
> -		echo "Please specify which branch you want to merge on the command"
> +		echo "Please specify which remote branch you want to use on the command"
>  		echo "line and try again (e.g. 'git pull <repository> <refspec>')."
>  		echo "See git-pull(1) for details."
>  	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"
> -		echo "your configuration file does not tell me either.	Please"
> -		echo "specify which branch you want to merge on the command line and"
> +		echo "want to $op_type $op_prep, and 'branch.${curr_branch}.merge' in"
> +		echo "your configuration file does not tell me, either. Please"
> +		echo "specify which branch you want to use on the command line and"
>  		echo "try again (e.g. 'git pull <repository> <refspec>')."
>  		echo "See git-pull(1) for details."
>  		echo
> -		echo "If you often merge with the same branch, you may want to"
> -		echo "configure the following variables in your configuration"
> -		echo "file:"
> +		echo "If you often $op_type $op_prep the same branch, you may want to"
> +		echo "use something like the following in your configuration file:"
> +		echo
> +		echo "    [branch \"${curr_branch}\"]"
> +		echo "    remote = <nickname>"
> +		echo "    merge = <remote-ref>"
> +		test rebase = "$op_type" &&
> +			echo "    rebase = true"
>  		echo
> -		echo "    branch.${curr_branch}.remote = <nickname>"
> -		echo "    branch.${curr_branch}.merge = <remote-ref>"
> -		echo "    remote.<nickname>.url = <url>"
> -		echo "    remote.<nickname>.fetch = <refspec>"
> +		echo "    [remote \"<nickname>\"]"
> +		echo "    url = <url>"
> +		echo "    fetch = <refspec>"
>  		echo
>  		echo "See git-config(1) for details."
>  	else
> -		echo "Your configuration specifies to merge the ref '${upstream#refs/heads/}' from the"
> -		echo "remote, but no such ref was fetched."
> +		echo "Your configuration specifies to $op_type $op_prep the ref '${upstream#refs/heads/}'"
> +		echo "from the remote, but no such ref was fetched."
>  	fi
>  	exit 1
>  }
> -- 
> 1.6.5.3
Previous: Jonathan NiederNext: Jonathan Nieder
Message 18 of 26 in “Unhelpful "branch.master.remote = <nickname>" advice?”
  1. Jan NieuwenhuizenNov 11, 2009
  2. Tomas CarneckyNov 11, 2009
  3. Makefile: add uninstall target. Fixes elementary good cleaning manners.Jan Nieuwenhuizen, Nov 18, 2009
  4. Matthieu MoyNov 18, 2009
  5. Jan KrügerNov 11, 2009
  6. Junio C HamanoNov 11, 2009
  7. Tomas CarneckyNov 11, 2009
  8. Jan NieuwenhuizenNov 11, 2009
  9. Tomas CarneckyNov 11, 2009
  10. Jan NieuwenhuizenNov 12, 2009
  11. git-pull.sh: overhaul error handling when no candidates are foundJan Krüger, Nov 12, 2009
  12. Jeff KingNov 12, 2009
  13. Jan KrügerNov 12, 2009
  14. Jeff KingNov 12, 2009
  15. git-pull.sh --rebase: overhaul error handling when no candidates are foundJan Krüger, Nov 12, 2009
  16. Jonathan NiederNov 13, 2009
  17. pull: clarify advice for the unconfigured error caseJonathan Nieder, Nov 27, 2009
  18. Junio C HamanoDec 2, 2009
  19. Jonathan NiederDec 3, 2009
  20. Jeff KingDec 3, 2009
  21. Jan NieuwenhuizenDec 3, 2009
  22. Jan KrügerDec 3, 2009
  23. Junio C HamanoDec 7, 2009
  24. Junio C HamanoNov 15, 2009
  25. Björn SteinbrinkNov 12, 2009
  26. Tomas CarneckyNov 12, 2009

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.