summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-06-18 18:16:56 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-06-18 18:16:56 (GMT)
commit0f0169d153ddb40628075a5e752ac7fe87ddc958 (patch)
tree5b320dde036b253314c812f8b440553751db5b61
parent2ad6b143536273335be6e21f1500513911ea7315 (diff)
parentbffd750adf98c4a377571af73cf9a589f86495fb (diff)
downloadgit-0f0169d153ddb40628075a5e752ac7fe87ddc958.zip
git-0f0169d153ddb40628075a5e752ac7fe87ddc958.tar.gz
git-0f0169d153ddb40628075a5e752ac7fe87ddc958.tar.bz2
Merge branch 'jn/rebase-cmdline-fix'
* jn/rebase-cmdline-fix: rebase: improve error message when upstream argument is missing
-rwxr-xr-xgit-rebase.sh17
-rwxr-xr-xt/t3400-rebase.sh13
2 files changed, 20 insertions, 10 deletions
diff --git a/git-rebase.sh b/git-rebase.sh
index 44f5c65..ab4afa7 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano.
#
-USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--no-ff] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]'
+USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--no-ff] [--onto <newbase>] (<upstream>|--root) [<branch>] [--quiet | -q]'
LONG_USAGE='git-rebase replaces <branch> with a new branch of the
same name. When the --onto option is provided the new branch starts
out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>
@@ -198,14 +198,6 @@ test -f "$GIT_DIR"/rebase-apply/applying &&
is_interactive "$@" && exec git-rebase--interactive "$@"
-if test $# -eq 0
-then
- test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || usage
- test -d "$dotest" -o -f "$GIT_DIR"/rebase-apply/rebasing &&
- die 'A rebase is in progress, try --continue, --skip or --abort.'
- die "No arguments given and $GIT_DIR/rebase-apply already exists."
-fi
-
while test $# != 0
do
case "$1" in
@@ -370,6 +362,13 @@ do
done
test $# -gt 2 && usage
+if test $# -eq 0 && test -z "$rebase_root"
+then
+ test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || usage
+ test -d "$dotest" -o -f "$GIT_DIR"/rebase-apply/rebasing &&
+ die 'A rebase is in progress, try --continue, --skip or --abort.'
+fi
+
# Make sure we do not have $GIT_DIR/rebase-apply
if test -z "$do_merge"
then
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index dbf7dfb..e5691bc 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -126,9 +126,20 @@ test_expect_success 'Show verbose error when HEAD could not be detached' '
test_must_fail git rebase topic 2> output.err > output.out &&
grep "Untracked working tree file .B. would be overwritten" output.err
'
+rm -f B
+
+test_expect_success 'dump usage when upstream arg is missing' '
+ git checkout -b usage topic &&
+ test_must_fail git rebase 2>error1 &&
+ grep "[Uu]sage" error1 &&
+ test_must_fail git rebase --abort 2>error2 &&
+ grep "No rebase in progress" error2 &&
+ test_must_fail git rebase --onto master 2>error3 &&
+ grep "[Uu]sage" error3 &&
+ ! grep "can.t shift" error3
+'
test_expect_success 'rebase -q is quiet' '
- rm B &&
git checkout -b quiet topic &&
git rebase -q master > output.out 2>&1 &&
test ! -s output.out