summaryrefslogtreecommitdiff
path: root/git-rebase.sh
diff options
context:
space:
mode:
authorMartin von Zweigbergk <martin.von.zweigbergk@gmail.com>2012-06-26 07:51:55 -0700
committerJunio C Hamano <gitster@pobox.com>2012-06-26 13:17:53 -0700
commitf2b6a19907ccb366790c7ec7b640f9111ac7ad32 (patch)
tree07f8d3448c7f9da81ecdf0d680fb1a51bdc5daec /git-rebase.sh
parent572a7c52bb12e22b3b8471133253b9884643a4e2 (diff)
downloadgit-f2b6a19907ccb366790c7ec7b640f9111ac7ad32.tar.gz
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 'git-rebase.sh')
-rwxr-xr-xgit-rebase.sh6
1 files changed, 5 insertions, 1 deletions
diff --git a/git-rebase.sh b/git-rebase.sh
index e616737444..6df06c4008 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -400,6 +400,7 @@ else
test -z "$onto" && die "You must specify --onto when using --root"
unset upstream_name
unset upstream
+ test $# -gt 1 && usage
upstream_arg=--root
fi
@@ -450,7 +451,7 @@ case "$#" in
die "fatal: no such branch: $1"
fi
;;
-*)
+0)
# Do not need to switch branches, we are already on it.
if branch_name=`git symbolic-ref -q HEAD`
then
@@ -462,6 +463,9 @@ case "$#" in
fi
orig_head=$(git rev-parse --verify "${branch_name}^0") || exit
;;
+*)
+ die "BUG: unexpected number of arguments left to parse"
+ ;;
esac
require_clean_work_tree "rebase" "Please commit or stash them."