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 or recover from 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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Carlos Martín Nieto committed
Mar 4, 2012 at 05:41 UTC
3c02396adc0d8836bccc4fbc95edbb3ca8c1f508
4 files changed
+24
-29
git-parse-remote.sh
+20
-23
@@ -57,34 +57,31 @@ error_on_missing_default_upstream () {
57
op_prep="$3"
58
example="$4"
59
branch_name=$(git symbolic-ref -q HEAD)
60
+ # If there's only one remote, use that in the suggestion
61
+ remote="<remote>"
62
+ if test $(git remote | wc -l) = 1
63
+ then
64
+ remote=$(git remote)
65
+ fi
66
+
67
if test -z "$branch_name"
68
then
62
- echo "You are not currently on a branch, so I cannot use any
63
-'branch.<branchname>.merge' in your configuration file.
64
-Please specify which branch you want to $op_type $op_prep on the command
65
-line and try again (e.g. '$example').
66
-See git-${cmd}(1) for details."
69
+ echo "You are not currently on a branch. Please specify which
70
+branch you want to $op_type $op_prep. See git-${cmd}(1) for details.
71
+
72
+ $example
73
+"
74
else
68
- echo "You asked me to $cmd without telling me which branch you
69
-want to $op_type $op_prep, and 'branch.${branch_name#refs/heads/}.merge' in
70
-your configuration file does not tell me, either. Please
71
-specify which branch you want to use on the command line and
72
-try again (e.g. '$example').
73
-See git-${cmd}(1) for details.
75
+ echo "There is no tracking information for the current branch.
76
+Please specify which branch you want to $op_type $op_prep.
77
+See git-${cmd}(1) for details
78
+
79
+ $example
80
75
-If you often $op_type $op_prep the same branch, you may want to
76
-use something like the following in your configuration file:
77
- [branch \"${branch_name#refs/heads/}\"]
78
- remote = <nickname>
79
- merge = <remote-ref>"
80
- test rebase = "$op_type" &&
81
- echo " rebase = true"
82
- echo "
83
- [remote \"<nickname>\"]
84
- url = <url>
85
- fetch = <refspec>
81
+If you wish to set tracking information for this branch you can do so with:
82
87
-See git-config(1) for details."
83
+ git branch --set-upstream ${branch_name#refs/heads/} $remote/<branch>
84
+"
85
fi
86
exit 1
87
}
git-pull.sh
+1
-1
@@ -180,7 +180,7 @@ error_on_no_merge_candidates () {
180
elif [ -z "$curr_branch" -o -z "$upstream" ]; then
181
. git-parse-remote
182
error_on_missing_default_upstream "pull" $op_type $op_prep \
183
- "git pull <repository> <refspec>"
183
+ "git pull <remote> <branch>"
184
else
185
echo "Your configuration specifies to $op_type $op_prep the ref '${upstream#refs/heads/}'"
186
echo "from the remote, but no such ref was fetched."
git-rebase.sh
+1
-1
@@ -380,7 +380,7 @@ then
380
then
381
. git-parse-remote
382
error_on_missing_default_upstream "rebase" "rebase" \
383
- "against" "git rebase <upstream branch>"
383
+ "against" "git rebase <branch>"
384
fi
385
;;
386
*) upstream_name="$1"
t/t3400-rebase.sh
+2
-4
@@ -160,14 +160,12 @@ rm -f B
160
161
test_expect_success 'fail when upstream arg is missing and not on branch' '
162
git checkout topic &&
163
- test_must_fail git rebase >output.out &&
164
- grep "You are not currently on a branch" output.out
163
+ test_must_fail git rebase
164
'
165
166
test_expect_success 'fail when upstream arg is missing and not configured' '
167
git checkout -b no-config topic &&
169
- test_must_fail git rebase >output.out &&
170
- grep "branch.no-config.merge" output.out
168
+ test_must_fail git rebase
169
'
170
171
test_expect_success 'default to @{upstream} when upstream arg is missing' '