rebase: improve error message when upstream argument is missing
Strip out options before checking for a missing upstream argument. Before: $ git rebase -m shift: 426: can't shift that many After: $ git rebase -m Usage: git rebase ... While at it, fix the usage message to explain that the upstream argument is mandatory. Reported-by: Jon Dowland <jmtd@debian.org> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Nieder committed
May 31, 2010 at 17:51 UTC
bffd750adf98c4a377571af73cf9a589f86495fb
2 files changed
+20
-10
git-rebase.sh
+8
-9
@@ -3,7 +3,7 @@
3
# Copyright (c) 2005 Junio C Hamano.
4
#
5
6
-USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--no-ff] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]'
6
+USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--no-ff] [--onto <newbase>] (<upstream>|--root) [<branch>] [--quiet | -q]'
7
LONG_USAGE='git-rebase replaces <branch> with a new branch of the
8
same name. When the --onto option is provided the new branch starts
9
out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>
@@ -198,14 +198,6 @@ test -f "$GIT_DIR"/rebase-apply/applying &&
198
199
is_interactive "$@" && exec git-rebase--interactive "$@"
200
201
-if test $# -eq 0
202
-then
203
- test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || usage
204
- test -d "$dotest" -o -f "$GIT_DIR"/rebase-apply/rebasing &&
205
- die 'A rebase is in progress, try --continue, --skip or --abort.'
206
- die "No arguments given and $GIT_DIR/rebase-apply already exists."
207
-fi
208
-
201
while test $# != 0
202
do
203
case "$1" in
@@ -370,6 +362,13 @@ do
362
done
363
test $# -gt 2 && usage
364
365
+if test $# -eq 0 && test -z "$rebase_root"
366
+then
367
+ test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || usage
368
+ test -d "$dotest" -o -f "$GIT_DIR"/rebase-apply/rebasing &&
369
+ die 'A rebase is in progress, try --continue, --skip or --abort.'
370
+fi
371
+
372
# Make sure we do not have $GIT_DIR/rebase-apply
373
if test -z "$do_merge"
374
then
t/t3400-rebase.sh
+12
-1
@@ -126,9 +126,20 @@ test_expect_success 'Show verbose error when HEAD could not be detached' '
126
test_must_fail git rebase topic 2> output.err > output.out &&
127
grep "Untracked working tree file .B. would be overwritten" output.err
128
'
129
+rm -f B
130
+
131
+test_expect_success 'dump usage when upstream arg is missing' '
132
+ git checkout -b usage topic &&
133
+ test_must_fail git rebase 2>error1 &&
134
+ grep "[Uu]sage" error1 &&
135
+ test_must_fail git rebase --abort 2>error2 &&
136
+ grep "No rebase in progress" error2 &&
137
+ test_must_fail git rebase --onto master 2>error3 &&
138
+ grep "[Uu]sage" error3 &&
139
+ ! grep "can.t shift" error3
140
+'
141
142
test_expect_success 'rebase -q is quiet' '
131
- rm B &&
143
git checkout -b quiet topic &&
144
git rebase -q master > output.out 2>&1 &&
145
test ! -s output.out