All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC/PATCH] Make git-{pull,rebase} no-tracking message friendlier
@ 2012-02-23 16:05 Carlos Martín Nieto
  2012-02-23 20:28 ` Junio C Hamano
  2012-02-27 22:06 ` Matthieu Moy
  0 siblings, 2 replies; 11+ messages in thread
From: Carlos Martín Nieto @ 2012-02-23 16:05 UTC (permalink / raw)
  To: git

The current message is too long and at too low a level for anybody to
understand it if they don't know about the configuration format
already.

Reformat it to show the commands a user would be expected to use,
instead of the contents of the configuration file.
---

As annoying as it is when people simply paste the output of 'git pull'
and ask "what does it mean" without even reading it, I have to admit
that as a new user, I'd also be scared off by this message. Using
git-remote and git-branch should make it less scary and more relatable
for the user. I'm not aware of a way to set branch.$branch.rebase with
porcelain, so I put in a config command there. Better
solutions/wordings welcome; I'd really like to get rid of the old
message.

 git-parse-remote.sh |   23 ++++++++---------------
 1 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index b24119d..96e76a9 100644
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -65,26 +65,19 @@ Please specify which branch you want to $op_type $op_prep on the command
 line and try again (e.g. '$example').
 See git-${cmd}(1) for details."
 	else
-		echo "You asked me to $cmd without telling me which branch you
-want to $op_type $op_prep, and 'branch.${branch_name#refs/heads/}.merge' in
-your configuration file does not tell me, either. Please
-specify which branch you want to use on the command line and
+		echo "You asked me to $cmd without telling me which branch you want to
+$op_type $op_prep, and there is no tracking information for the current branch.
+Please specify which branch you want to use on the command line and
 try again (e.g. '$example').
 See git-${cmd}(1) for details.
 
 If you often $op_type $op_prep the same branch, you may want to
-use something like the following in your configuration file:
-    [branch \"${branch_name#refs/heads/}\"]
-    remote = <nickname>
-    merge = <remote-ref>"
-		test rebase = "$op_type" &&
-		echo "    rebase = true"
-		echo "
-    [remote \"<nickname>\"]
-    url = <url>
-    fetch = <refspec>
+run something like:
 
-See git-config(1) for details."
+    git remote add <remote> <url>
+    git branch --set-upstream ${branch_name#refs/heads/} <remote>/<remote-branch>"
+		test rebase = "$op_type" &&
+		echo "    git config branch.${branch_name#refs/heads/}.rebase true"
 	fi
 	exit 1
 }
-- 
1.7.8.352.g876a6f

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [RFC/PATCH] Make git-{pull,rebase} no-tracking message friendlier
  2012-02-23 16:05 [RFC/PATCH] Make git-{pull,rebase} no-tracking message friendlier Carlos Martín Nieto
@ 2012-02-23 20:28 ` Junio C Hamano
  2012-02-27 17:07   ` Carlos Martín Nieto
  2012-02-27 22:06 ` Matthieu Moy
  1 sibling, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2012-02-23 20:28 UTC (permalink / raw)
  To: Carlos Martín Nieto; +Cc: git

Carlos Martín Nieto <cmn@elego.de> writes:

> The current message is too long and at too low a level for anybody to
> understand it if they don't know about the configuration format
> already.
>
> Reformat it to show the commands a user would be expected to use,
> instead of the contents of the configuration file.
> ---

Sounds like a change going in the right direction.  I am unsure if it is a
good idea to remove "See git-config...", but otherwise I like the updated
text much better.

But of course I am not the target audience, so let's see what we hear from
others.

Thanks.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC/PATCH] Make git-{pull,rebase} no-tracking message friendlier
  2012-02-23 20:28 ` Junio C Hamano
@ 2012-02-27 17:07   ` Carlos Martín Nieto
  0 siblings, 0 replies; 11+ messages in thread
From: Carlos Martín Nieto @ 2012-02-27 17:07 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 1092 bytes --]

On Thu, 2012-02-23 at 12:28 -0800, Junio C Hamano wrote:
> Carlos Martín Nieto <cmn@elego.de> writes:
> 
> > The current message is too long and at too low a level for anybody to
> > understand it if they don't know about the configuration format
> > already.
> >
> > Reformat it to show the commands a user would be expected to use,
> > instead of the contents of the configuration file.
> > ---
> 
> Sounds like a change going in the right direction.  I am unsure if it is a
> good idea to remove "See git-config...", but otherwise I like the updated
> text much better.

We're already telling them to go look at the git-pull or git-rebase
manpages, where there's already a lot of information and adding another
RTFM seemed a bit unfriendly (and not that useful, as they'd be
manipulating the config via other commands and shouldn't need to care
about config that much)

> 
> But of course I am not the target audience, so let's see what we hear from
> others.

Sure, I'll see if I can come up with some better wording and send a
signed-off patch.

   cmn



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC/PATCH] Make git-{pull,rebase} no-tracking message friendlier
  2012-02-23 16:05 [RFC/PATCH] Make git-{pull,rebase} no-tracking message friendlier Carlos Martín Nieto
  2012-02-23 20:28 ` Junio C Hamano
@ 2012-02-27 22:06 ` Matthieu Moy
  2012-02-29  3:57   ` Carlos Martín Nieto
  1 sibling, 1 reply; 11+ messages in thread
From: Matthieu Moy @ 2012-02-27 22:06 UTC (permalink / raw)
  To: Carlos Martín Nieto; +Cc: git

Carlos Martín Nieto <cmn@elego.de> writes:

> -		echo "You asked me to $cmd without telling me which branch you
> -want to $op_type $op_prep, and 'branch.${branch_name#refs/heads/}.merge' in
> -your configuration file does not tell me, either. Please
> -specify which branch you want to use on the command line and
> +		echo "You asked me to $cmd without telling me which branch you want to
> +$op_type $op_prep, and there is no tracking information for the current branch.
> +Please specify which branch you want to use on the command line and
>  try again (e.g. '$example').

At this point, it may be better to actually give the full command
instead of just this "(e.g. '$example')", i.e. stg like

  git $op_type <remote> $example

I also saw users confused by the message (indeed without reading it,
but ...). Giving them something as close as possible to
cut-and-paste-able command should help.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC/PATCH] Make git-{pull,rebase} no-tracking message friendlier
  2012-02-27 22:06 ` Matthieu Moy
@ 2012-02-29  3:57   ` Carlos Martín Nieto
  2012-02-29  8:09     ` Matthieu Moy
  0 siblings, 1 reply; 11+ messages in thread
From: Carlos Martín Nieto @ 2012-02-29  3:57 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git

On Mon, 2012-02-27 at 23:06 +0100, Matthieu Moy wrote:
> Carlos Martín Nieto <cmn@elego.de> writes:
> 
> > -		echo "You asked me to $cmd without telling me which branch you
> > -want to $op_type $op_prep, and 'branch.${branch_name#refs/heads/}.merge' in
> > -your configuration file does not tell me, either. Please
> > -specify which branch you want to use on the command line and
> > +		echo "You asked me to $cmd without telling me which branch you want to
> > +$op_type $op_prep, and there is no tracking information for the current branch.
> > +Please specify which branch you want to use on the command line and
> >  try again (e.g. '$example').
> 
> At this point, it may be better to actually give the full command
> instead of just this "(e.g. '$example')", i.e. stg like
> 
>   git $op_type <remote> $example
> 
> I also saw users confused by the message (indeed without reading it,
> but ...). Giving them something as close as possible to
> cut-and-paste-able command should help.


$example is a caller-given string which already contains the whole
command (i.e. it's already 'git rebase <upstream branch>' or 'git pull
<repository> <branch>').  In this patch I've moved that command to its
own paragraph so the usage part of the output gets more visibility.

Another version of the patch, this one somewhat more intrusive,
hopefully easier to digest.

---8<---
Subject: [PATCH] Make git-{pull,rebase} message without tracking information
 friendlier

The current message is too long and at too low a level for anybody to
understand it if they don't know about the configuration format
already.

Reformat it to show the commands a user would be expected to use,
instead of the contents of the configuration file. Use <branch>
instead of <refspec> or <upstream branch> as they're bound to consfuse
new users more than help them. Use <remote> instead of <repository> in
the pull message.
---
 git-parse-remote.sh |   26 ++++++++++----------------
 git-pull.sh         |    2 +-
 git-rebase.sh       |    2 +-
 3 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index b24119d..bcb75a0 100644
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -66,25 +66,19 @@ line and try again (e.g. '$example').
 See git-${cmd}(1) for details."
 	else
 		echo "You asked me to $cmd without telling me which branch you
-want to $op_type $op_prep, and 'branch.${branch_name#refs/heads/}.merge' in
-your configuration file does not tell me, either. Please
-specify which branch you want to use on the command line and
-try again (e.g. '$example').
-See git-${cmd}(1) for details.
+want to $op_type $op_prep, and the current branch doesn't have
+tracking information. Please specify which branch you want to
+use on the command line and try again. See git-${cmd}(1) for details.
+
+    $example
 
 If you often $op_type $op_prep the same branch, you may want to
-use something like the following in your configuration file:
-    [branch \"${branch_name#refs/heads/}\"]
-    remote = <nickname>
-    merge = <remote-ref>"
-		test rebase = "$op_type" &&
-		echo "    rebase = true"
-		echo "
-    [remote \"<nickname>\"]
-    url = <url>
-    fetch = <refspec>
+run something like:
 
-See git-config(1) for details."
+    git remote add <remote> <url>
+    git branch --set-upstream ${branch_name#refs/heads/} <remote>/<branch>"
+		test rebase = "$op_type" &&
+		echo "    git config branch.${branch_name#refs/heads/}.rebase true"
 	fi
 	exit 1
 }
diff --git a/git-pull.sh b/git-pull.sh
index d8b64d7..309c7db 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -176,7 +176,7 @@ error_on_no_merge_candidates () {
 	elif [ -z "$curr_branch" -o -z "$upstream" ]; then
 		. git-parse-remote
 		error_on_missing_default_upstream "pull" $op_type $op_prep \
-			"git pull <repository> <refspec>"
+			"git pull <remote> <branch>"
 	else
 		echo "Your configuration specifies to $op_type $op_prep the ref '${upstream#refs/heads/}'"
 		echo "from the remote, but no such ref was fetched."
diff --git a/git-rebase.sh b/git-rebase.sh
index 00ca7b9..69c1374 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -380,7 +380,7 @@ then
 		then
 			. git-parse-remote
 			error_on_missing_default_upstream "rebase" "rebase" \
-				"against" "git rebase <upstream branch>"
+				"against" "git rebase <branch>"
 		fi
 		;;
 	*)	upstream_name="$1"
-- 
1.7.9.2.3.g4346f

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [RFC/PATCH] Make git-{pull,rebase} no-tracking message friendlier
  2012-02-29  3:57   ` Carlos Martín Nieto
@ 2012-02-29  8:09     ` Matthieu Moy
  2012-02-29 17:34       ` Carlos Martín Nieto
  2012-02-29 18:41       ` [PATCH] Make git-{pull,rebase} message without tracking information friendlier Carlos Martín Nieto
  0 siblings, 2 replies; 11+ messages in thread
From: Matthieu Moy @ 2012-02-29  8:09 UTC (permalink / raw)
  To: Carlos Martín Nieto; +Cc: git

Carlos Martín Nieto <cmn@elego.de> writes:

> $example is a caller-given string which already contains the whole
> command (i.e. it's already 'git rebase <upstream branch>' or 'git pull
> <repository> <branch>').

OK, I didn't remember the exact message.

> In this patch I've moved that command to its own paragraph so the
> usage part of the output gets more visibility.

I prefer this, yes.

Perhaps we could go further and try to guess a remote and a branch name
to give in the example. "git push" already does that to some extend:

  $ git -c push.default=tracking push
  fatal: The current branch my-branch has no upstream branch.
  To push the current branch and set the remote as upstream, use
  
      git push --set-upstream origin my-branch

i.e. if there's a remote configured, then using it in the example makes
sense. I'm not sure if using the current branch name in the example
would also be a good thing (it usually is for "push" because most users
would push to a branch with the same name on the remote end).

It may also make sense not to suggest "git remote add" if there's
already a remote configured. Otherwise, the case, which is probably the
most common, of:

  git clone http://example.com/repo
  cd repo
  git checkout -b new-branch
  git pull

is made far more complex than it should for the newcommer.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC/PATCH] Make git-{pull,rebase} no-tracking message friendlier
  2012-02-29  8:09     ` Matthieu Moy
@ 2012-02-29 17:34       ` Carlos Martín Nieto
  2012-02-29 18:41       ` [PATCH] Make git-{pull,rebase} message without tracking information friendlier Carlos Martín Nieto
  1 sibling, 0 replies; 11+ messages in thread
From: Carlos Martín Nieto @ 2012-02-29 17:34 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 2184 bytes --]

On Wed, 2012-02-29 at 09:09 +0100, Matthieu Moy wrote:
> Carlos Martín Nieto <cmn@elego.de> writes:
> 
> > $example is a caller-given string which already contains the whole
> > command (i.e. it's already 'git rebase <upstream branch>' or 'git pull
> > <repository> <branch>').
> 
> OK, I didn't remember the exact message.
> 
> > In this patch I've moved that command to its own paragraph so the
> > usage part of the output gets more visibility.
> 
> I prefer this, yes.
> 
> Perhaps we could go further and try to guess a remote and a branch name
> to give in the example. "git push" already does that to some extend:
> 
>   $ git -c push.default=tracking push
>   fatal: The current branch my-branch has no upstream branch.
>   To push the current branch and set the remote as upstream, use
>   
>       git push --set-upstream origin my-branch
> 
> i.e. if there's a remote configured, then using it in the example makes
> sense. I'm not sure if using the current branch name in the example
> would also be a good thing (it usually is for "push" because most users
> would push to a branch with the same name on the remote end).

We do show the branch name in the 'remote add' text at the end, so we
should probably try to use it here as well. What I'm assuming is the
most usual case of one remote called 'origin' shouldn't be a problem. I
think I'll suppress the last part of the output when there are remotes
configured, as we can probably assume that the user is aware of them.

I'm tempted to throw out the second block and say to use either 'git
pull $remote $branch' or 'git branch --set-upstream $branch
$remote/$branch' and refer to the documentation for more. After all,
this is an error message, not a man page.

> 
> It may also make sense not to suggest "git remote add" if there's
> already a remote configured. Otherwise, the case, which is probably the
> most common, of:
> 
>   git clone http://example.com/repo
>   cd repo
>   git checkout -b new-branch
>   git pull
> 
> is made far more complex than it should for the newcommer.

Indeed. Removing the last part is probably better for everyone.

   cmn


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH] Make git-{pull,rebase} message without tracking information friendlier
  2012-02-29  8:09     ` Matthieu Moy
  2012-02-29 17:34       ` Carlos Martín Nieto
@ 2012-02-29 18:41       ` Carlos Martín Nieto
  2012-02-29 20:14         ` Junio C Hamano
  1 sibling, 1 reply; 11+ messages in thread
From: Carlos Martín Nieto @ 2012-02-29 18:41 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git

The current message is too long and at too low a level for anybody to
understand it if they don't know about the configuration format
already.

The text about setting up a remote is superfluous and doesn't help
understand the error that has happened. Explain how to set up the
tracking information, as it's the most likely way to get to the state
the user was expecting.

Also simplify the message we print on detached HEAD to remove clutter
and a reference to branch.<branchname>.merge which is better left for
the documentation.
---

This still needs some shell scripting to figure out whether we'd want
to replace <remote> with a real value. The text gets to the matter of
things and even tells you how to fix it. More text doesn't really add
more useful information, and this isn't a manpage.

I've left the branch --set-upstream in this version as it's probably
the most usual fix for a failing git push.

 git-parse-remote.sh |   32 ++++++++++----------------------
 git-pull.sh         |    2 +-
 git-rebase.sh       |    2 +-
 3 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index b24119d..08adc90 100644
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -60,31 +60,19 @@ error_on_missing_default_upstream () {
 	if test -z "$branch_name"
 	then
 		echo "You are not currently on a branch, so I cannot use any
-'branch.<branchname>.merge' in your configuration file.
-Please specify which branch you want to $op_type $op_prep on the command
-line and try again (e.g. '$example').
-See git-${cmd}(1) for details."
-	else
-		echo "You asked me to $cmd without telling me which branch you
-want to $op_type $op_prep, and 'branch.${branch_name#refs/heads/}.merge' in
-your configuration file does not tell me, either. Please
-specify which branch you want to use on the command line and
-try again (e.g. '$example').
+tracking information in your configuration file.
+Please specify which branch you want to $op_type $op_prep.
 See git-${cmd}(1) for details.
 
-If you often $op_type $op_prep the same branch, you may want to
-use something like the following in your configuration file:
-    [branch \"${branch_name#refs/heads/}\"]
-    remote = <nickname>
-    merge = <remote-ref>"
-		test rebase = "$op_type" &&
-		echo "    rebase = true"
-		echo "
-    [remote \"<nickname>\"]
-    url = <url>
-    fetch = <refspec>
+    $example"
+	else
+		echo "You asked me to $cmd without specifying a branch to
+$op_type $op_prep, and the current branch doesn't have any tracking
+information. Please specify a branch and try again. See git-${cmd}(1)
+for details. To set the tracking information, you can use
 
-See git-config(1) for details."
+    git branch --set-upstream ${branch_name#refs/heads/} <remote>/<branch>
+"
 	fi
 	exit 1
 }
diff --git a/git-pull.sh b/git-pull.sh
index d8b64d7..309c7db 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -176,7 +176,7 @@ error_on_no_merge_candidates () {
 	elif [ -z "$curr_branch" -o -z "$upstream" ]; then
 		. git-parse-remote
 		error_on_missing_default_upstream "pull" $op_type $op_prep \
-			"git pull <repository> <refspec>"
+			"git pull <remote> <branch>"
 	else
 		echo "Your configuration specifies to $op_type $op_prep the ref '${upstream#refs/heads/}'"
 		echo "from the remote, but no such ref was fetched."
diff --git a/git-rebase.sh b/git-rebase.sh
index 00ca7b9..69c1374 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -380,7 +380,7 @@ then
 		then
 			. git-parse-remote
 			error_on_missing_default_upstream "rebase" "rebase" \
-				"against" "git rebase <upstream branch>"
+				"against" "git rebase <branch>"
 		fi
 		;;
 	*)	upstream_name="$1"
-- 
1.7.8.352.g876a6f

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] Make git-{pull,rebase} message without tracking information friendlier
  2012-02-29 18:41       ` [PATCH] Make git-{pull,rebase} message without tracking information friendlier Carlos Martín Nieto
@ 2012-02-29 20:14         ` Junio C Hamano
  2012-03-04  4:41           ` Carlos Martín Nieto
  0 siblings, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2012-02-29 20:14 UTC (permalink / raw)
  To: Carlos Martín Nieto; +Cc: Matthieu Moy, git

Carlos Martín Nieto <cmn@elego.de> writes:

> The current message is too long and at too low a level for anybody to
> understand it if they don't know about the configuration format
> already.
>
> The text about setting up a remote is superfluous and doesn't help
> understand the error that has happened. Explain how to set up the
> tracking information, as it's the most likely way to get to the state
> the user was expecting.
>
> Also simplify the message we print on detached HEAD to remove clutter
> and a reference to branch.<branchname>.merge which is better left for
> the documentation.
> ---
> This still needs some shell scripting to figure out whether we'd want
> to replace <remote> with a real value. The text gets to the matter of
> things and even tells you how to fix it. More text doesn't really add
> more useful information, and this isn't a manpage.

Exactly.

This made me thinking again.  On the "detached HEAD" side of your patch,
the concluding "Please specify which branch you mean" is the most useful
information; ", so I cannot use any tracking information in your
configuration file" may help _education_, but does not immediately help
the user to do what the user wanted to do.

Perhaps it may read it better if we remove that part; the result becomes
even more concise and to the point.

Oh the "on a branch" side of your patch, the updated message is trying to
help the user by doing two things:

 - tell him to explicitly name the branch (by the way, you seem to have
   lost the $example---is it intended) in order to immediately perform
   what he wanted to.

 - educate him that he can configure upstream information and avoid
   typing in a later invocation of the same command.

I think it is easier to read if we have clear separation between the two,
as the hasty users would want to stop reading after the first help.

So after "See git-${cmd}(1) for details.", have a paragraph break, add
an indented "$example" just like you have for the "detached HEAD" case,
another paragraph break and then "To set the tracking information" as a
new pargraph, perhaps?

> I've left the branch --set-upstream in this version as it's probably
> the most usual fix for a failing git push.
>
>  git-parse-remote.sh |   32 ++++++++++----------------------
>  git-pull.sh         |    2 +-
>  git-rebase.sh       |    2 +-
>  3 files changed, 12 insertions(+), 24 deletions(-)
>
> diff --git a/git-parse-remote.sh b/git-parse-remote.sh
> index b24119d..08adc90 100644
> --- a/git-parse-remote.sh
> +++ b/git-parse-remote.sh
> @@ -60,31 +60,19 @@ error_on_missing_default_upstream () {
>  	if test -z "$branch_name"
>  	then
>  		echo "You are not currently on a branch, so I cannot use any
> +tracking information in your configuration file.
> +Please specify which branch you want to $op_type $op_prep.
>  See git-${cmd}(1) for details.
>  
> +    $example"
> +	else
> +		echo "You asked me to $cmd without specifying a branch to
> +$op_type $op_prep, and the current branch doesn't have any tracking
> +information. Please specify a branch and try again. See git-${cmd}(1)
> +for details. To set the tracking information, you can use
>  
> -See git-config(1) for details."
> +    git branch --set-upstream ${branch_name#refs/heads/} <remote>/<branch>
> +"
>  	fi
>  	exit 1
>  }
> diff --git a/git-pull.sh b/git-pull.sh
> index d8b64d7..309c7db 100755
> --- a/git-pull.sh
> +++ b/git-pull.sh
> @@ -176,7 +176,7 @@ error_on_no_merge_candidates () {
>  	elif [ -z "$curr_branch" -o -z "$upstream" ]; then
>  		. git-parse-remote
>  		error_on_missing_default_upstream "pull" $op_type $op_prep \
> -			"git pull <repository> <refspec>"
> +			"git pull <remote> <branch>"
>  	else
>  		echo "Your configuration specifies to $op_type $op_prep the ref '${upstream#refs/heads/}'"
>  		echo "from the remote, but no such ref was fetched."
> diff --git a/git-rebase.sh b/git-rebase.sh
> index 00ca7b9..69c1374 100755
> --- a/git-rebase.sh
> +++ b/git-rebase.sh
> @@ -380,7 +380,7 @@ then
>  		then
>  			. git-parse-remote
>  			error_on_missing_default_upstream "rebase" "rebase" \
> -				"against" "git rebase <upstream branch>"
> +				"against" "git rebase <branch>"
>  		fi
>  		;;
>  	*)	upstream_name="$1"

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Make git-{pull,rebase} message without tracking information friendlier
  2012-02-29 20:14         ` Junio C Hamano
@ 2012-03-04  4:41           ` Carlos Martín Nieto
  2012-03-05  7:49             ` Junio C Hamano
  0 siblings, 1 reply; 11+ messages in thread
From: Carlos Martín Nieto @ 2012-03-04  4:41 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Matthieu Moy, git

On Wed, 2012-02-29 at 12:14 -0800, Junio C Hamano wrote:
> Carlos Martín Nieto <cmn@elego.de> writes:
> [...]
> 
> This made me thinking again.  On the "detached HEAD" side of your patch,
> the concluding "Please specify which branch you mean" is the most useful
> information; ", so I cannot use any tracking information in your
> configuration file" may help _education_, but does not immediately help
> the user to do what the user wanted to do.

> Perhaps it may read it better if we remove that part; the result becomes
> even more concise and to the point.

Right. Less is more. I may have stared at it for too long, but I get the
feeling that in the new message, "You are not on a branch" and "Please
specify which branch" don't really seem to go together. After the first
sentence, I'm left thinking "so what?". Maybe something like "On
detached HEAD, you must specify a branch to $op_type $op_prep. [...]"
would work better?

> 
> Oh the "on a branch" side of your patch, the updated message is trying to
> help the user by doing two things:
> 
>  - tell him to explicitly name the branch (by the way, you seem to have
>    lost the $example---is it intended) in order to immediately perform
>    what he wanted to.

I did remove that on purpose because I couldn't figure out a good way to
introduce both versions. I was stubbornly keeping the configuration part
first and it wasn't clicking.

> 
>  - educate him that he can configure upstream information and avoid
>    typing in a later invocation of the same command.
> 
> I think it is easier to read if we have clear separation between the two,
> as the hasty users would want to stop reading after the first help.

Yes. This is why I wanted to put the configuration information first, as
a user who calls 'git pull' expects things to happen automatically, so I
wanted to tell her how to get it.

> 
> So after "See git-${cmd}(1) for details.", have a paragraph break, add
> an indented "$example" just like you have for the "detached HEAD" case,
> another paragraph break and then "To set the tracking information" as a
> new pargraph, perhaps?
> 

This way around looks much better and makes a lot more sense. Thanks for
the hint.

I couldn't come up with a better way to count remotes than
$(git remote | wc -l) as git config only uses the regex for the values
and $(git config --list | grep -c '^remote\..*\.url') seems even worse. 

I'm kind of two minds about the remote thing. If the branch doesn't have
an upstream already (either via checkout -t origin/branch or push -u),
making pulling from a remote upstream branch easier might lead to more
senseless merges, which is the opposite direction to other changes in
pull which ask for a reason, so after we've given them most of the
command to run so pull magically works on its own, we ask them to
justify it... I don't know, maybe I'm overthinking this.

   cmn

--- 8< ---
Subject: [PATCH] Make git-{pull,rebase} message without tracking information
 friendlier

The current message is too long and at too low a level for anybody to
understand it if they don't know about the configuration format
already.

The text about setting up a remote is superfluous and doesn't help
understand the error that has happened. Show the usage more
prominently and explain how to set up the tracking information. If
there is only one remote, that name is used instead of the generic
<remote>.

Also simplify the message we print on detached HEAD to remove
unnecessary information which is better left for the documentation.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
---
 git-parse-remote.sh |   42 +++++++++++++++++++-----------------------
 git-pull.sh         |    2 +-
 git-rebase.sh       |    2 +-
 3 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index b24119d..4575309 100644
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -57,34 +57,30 @@ error_on_missing_default_upstream () {
 	op_prep="$3"
 	example="$4"
 	branch_name=$(git symbolic-ref -q HEAD)
+	# If there's only one remote, use that in the suggestion
+	remote="<remote>"
+	if test $(git remote | wc -l) -eq 1; then
+	    remote=$(git remote)
+	fi
+
 	if test -z "$branch_name"
 	then
-		echo "You are not currently on a branch, so I cannot use any
-'branch.<branchname>.merge' in your configuration file.
-Please specify which branch you want to $op_type $op_prep on the command
-line and try again (e.g. '$example').
-See git-${cmd}(1) for details."
+		echo "You are not currently on a branch. Please specify which
+branch you want to $op_type $op_prep. See git-${cmd}(1) for details.
+
+    $example
+"
 	else
-		echo "You asked me to $cmd without telling me which branch you
-want to $op_type $op_prep, and 'branch.${branch_name#refs/heads/}.merge' in
-your configuration file does not tell me, either. Please
-specify which branch you want to use on the command line and
-try again (e.g. '$example').
-See git-${cmd}(1) for details.
+		echo "There is no tracking information for the current branch.
+Please specify which branch you want to $op_type $op_prep.
+See git-${cmd}(1) for details
+
+    $example
 
-If you often $op_type $op_prep the same branch, you may want to
-use something like the following in your configuration file:
-    [branch \"${branch_name#refs/heads/}\"]
-    remote = <nickname>
-    merge = <remote-ref>"
-		test rebase = "$op_type" &&
-		echo "    rebase = true"
-		echo "
-    [remote \"<nickname>\"]
-    url = <url>
-    fetch = <refspec>
+If you whish to set tracking information for this branch you can do so with:
 
-See git-config(1) for details."
+    git branch --set-upstream ${branch_name#refs/heads/} $remote/<branch>
+"
 	fi
 	exit 1
 }
diff --git a/git-pull.sh b/git-pull.sh
index d8b64d7..309c7db 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -176,7 +176,7 @@ error_on_no_merge_candidates () {
 	elif [ -z "$curr_branch" -o -z "$upstream" ]; then
 		. git-parse-remote
 		error_on_missing_default_upstream "pull" $op_type $op_prep \
-			"git pull <repository> <refspec>"
+			"git pull <remote> <branch>"
 	else
 		echo "Your configuration specifies to $op_type $op_prep the ref '${upstream#refs/heads/}'"
 		echo "from the remote, but no such ref was fetched."
diff --git a/git-rebase.sh b/git-rebase.sh
index 00ca7b9..69c1374 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -380,7 +380,7 @@ then
 		then
 			. git-parse-remote
 			error_on_missing_default_upstream "rebase" "rebase" \
-				"against" "git rebase <upstream branch>"
+				"against" "git rebase <branch>"
 		fi
 		;;
 	*)	upstream_name="$1"
-- 
1.7.9.2.3.g4346f

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] Make git-{pull,rebase} message without tracking information friendlier
  2012-03-04  4:41           ` Carlos Martín Nieto
@ 2012-03-05  7:49             ` Junio C Hamano
  0 siblings, 0 replies; 11+ messages in thread
From: Junio C Hamano @ 2012-03-05  7:49 UTC (permalink / raw)
  To: Carlos Martín Nieto; +Cc: Matthieu Moy, git

I think the updated message is much easier to read, so I've queued
this almost as-is (except for minor and obvious typo fixes,
e.g. whish) and merged it to 'next'.

Thanks.

By the way, these needed to be squashed in.

diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index e647272..370ffdf 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -160,14 +160,12 @@ rm -f B
 
 test_expect_success 'fail when upstream arg is missing and not on branch' '
 	git checkout topic &&
-	test_must_fail git rebase >output.out &&
-	grep "You are not currently on a branch" output.out
+	test_must_fail git rebase
 '
 
 test_expect_success 'fail when upstream arg is missing and not configured' '
 	git checkout -b no-config topic &&
-	test_must_fail git rebase >output.out &&
-	grep "branch.no-config.merge" output.out
+	test_must_fail git rebase
 '
 
 test_expect_success 'default to @{upstream} when upstream arg is missing' '

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-03-05  7:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-23 16:05 [RFC/PATCH] Make git-{pull,rebase} no-tracking message friendlier Carlos Martín Nieto
2012-02-23 20:28 ` Junio C Hamano
2012-02-27 17:07   ` Carlos Martín Nieto
2012-02-27 22:06 ` Matthieu Moy
2012-02-29  3:57   ` Carlos Martín Nieto
2012-02-29  8:09     ` Matthieu Moy
2012-02-29 17:34       ` Carlos Martín Nieto
2012-02-29 18:41       ` [PATCH] Make git-{pull,rebase} message without tracking information friendlier Carlos Martín Nieto
2012-02-29 20:14         ` Junio C Hamano
2012-03-04  4:41           ` Carlos Martín Nieto
2012-03-05  7:49             ` Junio C Hamano

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.