Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin von Zweigbergk <martin.von.zweigbergk@gmail.com>2012-06-26 18:51:55 +0400
committerJunio C Hamano <gitster@pobox.com>2012-06-27 00:17:53 +0400
commitf2b6a19907ccb366790c7ec7b640f9111ac7ad32 (patch)
tree07f8d3448c7f9da81ecdf0d680fb1a51bdc5daec /t/t3412-rebase-root.sh
parent572a7c52bb12e22b3b8471133253b9884643a4e2 (diff)
rebase --root: print usage on too many args
Just like git rebase --onto newbase upstream branch error displays the usage message, so should clearly git rebase --onto newbase --root branch error , but it doesn't. Instead, it ignores both "branch" and "error" and rebases the current HEAD. This is because we try to match the number of remainging arguments "$#", which fails to match "1" argument and matches the "*" that really should have been a "0". Make sure we display usage information when too many arguments are given. Also fail-fast in case of similar bugs in the future by matching on exactly 0 arguments and failing on unknown numbers. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3412-rebase-root.sh')
-rwxr-xr-xt/t3412-rebase-root.sh8
1 files changed, 7 insertions, 1 deletions
diff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh
index 086c91c7b4..1e9d1a737c 100755
--- a/t/t3412-rebase-root.sh
+++ b/t/t3412-rebase-root.sh
@@ -23,9 +23,15 @@ test_expect_success 'prepare repository' '
'
test_expect_success 'rebase --root expects --onto' '
+ git checkout -B fail other &&
test_must_fail git rebase --root
'
+test_expect_success 'rebase --root fails with too many args' '
+ git checkout -B fail other &&
+ test_must_fail git rebase --onto master --root fail fail
+'
+
test_expect_success 'setup pre-rebase hook' '
mkdir -p .git/hooks &&
cat >.git/hooks/pre-rebase <<EOF &&
@@ -42,7 +48,7 @@ cat > expect <<EOF
EOF
test_expect_success 'rebase --root --onto <newbase>' '
- git checkout -b work &&
+ git checkout -b work other &&
git rebase --root --onto master &&
git log --pretty=tformat:"%s" > rebased &&
test_cmp expect rebased