All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Jan Krüger" <jk@jk.gs>, "Jeff King" <peff@peff.net>,
	"Jan Nieuwenhuizen" <janneke-list@xs4all.nl>,
	"Tomas Carnecky" <tom@dbservice.com>,
	"git list" <git@vger.kernel.org>
Subject: [PATCH] pull: clarify advice for the unconfigured error case
Date: Fri, 27 Nov 2009 08:17:05 -0600	[thread overview]
Message-ID: <20091127141704.GA24080@progeny.tock> (raw)
In-Reply-To: <20091113040754.GA3255@progeny.tock>

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.

The configuration suggested to remedy the situation uses a
confusing syntax, with variables specified in the dotted form
accepted by 'git config' but separated from their values by the
'=' delimiter used by config files.  Since the user will have to
edit this output anyway, it is more helpful to provide a config
file snippet to paste into an editor and modify.

Signed-off-by: Jan Krüger <jk@jk.gs>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Jonathan Nieder wrote:
> Jan Krüger wrote:
 
>> --- a/git-pull.sh
>> +++ b/git-pull.sh
>> @@ -91,45 +91,56 @@ error_on_no_merge_candidates () {
>[...]
>>  	if [ $# -gt 1 ]; then
>> -		echo "There are no candidates for merging in the refs that you just fetched."
>> +		echo "There are no candidates for using 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."
>
> This sounds a little awkward to me, maybe because all the remote refs
> are being used to populate the remotes/<remote>/* hierarchy.

Scratch that --- I was confused.

I still find pull pretty confusing.  In its three forms, it does
different things:

 - 'git pull' fetches from the current branch’s remote (both its
   standard fetch refspec and the current branch’s), then merges any
   branches that match the current branch’s refspec.

 - 'git pull foo' fetches from the specified remote.  If it is
   the current branch’s remote, this is just a synonym for
   'git pull'; otherwise, it first fetches and then complains.

 - 'git pull foo refspec' does a fetch according to the specified
   refspec, and if any branches match, merges them into the
   current branch.

I was worried about the first form before (but who uses wildcards
in their branches’ refspecs?), but as Peff explains in commit
a8c9bef (pull: improve advice for unconfigured error case,
2009-10-05) the third one should be much more common.

In the --rebase case, exactly one branch would have to match for
this to make any sense (there is no such thing as an octopus
rebase), so I reworded the message accordingly.

 git-pull.sh |   48 +++++++++++++++++++++++++++++++++---------------
 1 files changed, 33 insertions(+), 15 deletions(-)

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

  reply	other threads:[~2009-11-27 14:05 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-11 13:22 Unhelpful "branch.master.remote = <nickname>" advice? Jan Nieuwenhuizen
2009-11-11 14:08 ` Tomas Carnecky
     [not found]   ` <1257965806.26362.132.camel@heerbeest>
2009-11-11 19:10     ` Tomas Carnecky
2009-11-11 19:34       ` Jan Nieuwenhuizen
2009-11-11 20:32         ` Tomas Carnecky
2009-11-12 14:17           ` Jan Nieuwenhuizen
2009-11-12 14:53             ` [PATCH] git-pull.sh: overhaul error handling when no candidates are found Jan Krüger
2009-11-12 15:06               ` Jeff King
2009-11-12 15:25                 ` Jan Krüger
2009-11-12 15:28                   ` Jeff King
2009-11-12 16:08                 ` [PATCH v2] git-pull.sh --rebase: " Jan Krüger
2009-11-13  4:07                   ` Jonathan Nieder
2009-11-27 14:17                     ` Jonathan Nieder [this message]
2009-12-02 23:08                       ` [PATCH] pull: clarify advice for the unconfigured error case Junio C Hamano
2009-12-03  1:26                         ` Jonathan Nieder
2009-12-03  1:43                           ` Jeff King
2009-12-03  8:49                             ` Jan Nieuwenhuizen
2009-12-03 10:51                         ` Jan Krüger
2009-12-07  0:29                           ` Junio C Hamano
2009-11-15  9:08                   ` [PATCH v2] git-pull.sh --rebase: overhaul error handling when no candidates are found Junio C Hamano
2009-11-12 14:56             ` Unhelpful "branch.master.remote = <nickname>" advice? Björn Steinbrink
2009-11-12 15:03             ` Tomas Carnecky
2009-11-18 12:29   ` [PATCH] Makefile: add uninstall target. Fixes elementary good cleaning manners Jan Nieuwenhuizen
2009-11-18 13:28     ` Matthieu Moy
2009-11-11 14:13 ` Unhelpful "branch.master.remote = <nickname>" advice? Jan Krüger
2009-11-11 19:54 ` Junio C Hamano

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=20091127141704.GA24080@progeny.tock \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=janneke-list@xs4all.nl \
    --cc=jk@jk.gs \
    --cc=peff@peff.net \
    --cc=tom@dbservice.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.