Skip to content

Commit 0f0169d

Browse files
committed
Merge branch 'jn/rebase-cmdline-fix'
* jn/rebase-cmdline-fix: rebase: improve error message when upstream argument is missing
2 parents 2ad6b14 + bffd750 commit 0f0169d

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

git-rebase.sh

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright (c) 2005 Junio C Hamano.
44
#
55

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]'
77
LONG_USAGE='git-rebase replaces <branch> with a new branch of the
88
same name. When the --onto option is provided the new branch starts
99
out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>
@@ -198,14 +198,6 @@ test -f "$GIT_DIR"/rebase-apply/applying &&
198198

199199
is_interactive "$@" && exec git-rebase--interactive "$@"
200200

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-
209201
while test $# != 0
210202
do
211203
case "$1" in
@@ -370,6 +362,13 @@ do
370362
done
371363
test $# -gt 2 && usage
372364

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+
373372
# Make sure we do not have $GIT_DIR/rebase-apply
374373
if test -z "$do_merge"
375374
then

t/t3400-rebase.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,20 @@ test_expect_success 'Show verbose error when HEAD could not be detached' '
126126
test_must_fail git rebase topic 2> output.err > output.out &&
127127
grep "Untracked working tree file .B. would be overwritten" output.err
128128
'
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+
'
129141

130142
test_expect_success 'rebase -q is quiet' '
131-
rm B &&
132143
git checkout -b quiet topic &&
133144
git rebase -q master > output.out 2>&1 &&
134145
test ! -s output.out

0 commit comments

Comments
 (0)