@matheusbsbs / matheus-bagliano / commits / 95135b06fe
Fork 0

rebase: stricter check of standalone sub command

The sub commands '--continue', '--skip' or '--abort' may only be used standalone according to the documentation. Other options following the sub command are currently not accepted, but options preceeding them are. For example, 'git rebase --continue -v' is not accepted, while 'git rebase -v --continue' is. Tighten up the check and allow no other options when one of these sub commands are used. Only check that it is standalone for non-interactive rebase for now. Once the command line processing for interactive rebase has been replaced by the command line processing in git-rebase.sh, this check will also apply to interactive rebase. Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Martin von Zweigbergk committed Feb 6, 2011 at 13:43 UTC 95135b06fe5f44f1efaeac729021a350b52652e5
4 files changed +22 -2
git-rebase.sh
+2 -2
@@ -229,6 +229,7 @@ then
229 fi
230 test -n "$type" && in_progress=t
231
232 +total_argc=$#
233 while test $# != 0
234 do
235 case "$1" in
@@ -239,9 +240,8 @@ do
240 OK_TO_SKIP_PRE_REBASE=
241 ;;
242 --continue|--skip|--abort)
243 + test $total_argc -eq 1 || usage
244 action=${1##--}
243 - shift
244 - break
245 ;;
246 --onto)
247 test 2 -le "$#" || usage
t/t3403-rebase-skip.sh
+5
@@ -35,6 +35,11 @@ test_expect_success 'rebase with git am -3 (default)' '
35 test_must_fail git rebase master
36 '
37
38 +test_expect_success 'rebase --skip can not be used with other options' '
39 + test_must_fail git rebase -v --skip &&
40 + test_must_fail git rebase --skip -v
41 +'
42 +
43 test_expect_success 'rebase --skip with am -3' '
44 git rebase --skip
45 '
t/t3407-rebase-abort.sh
+10
@@ -84,6 +84,16 @@ testrebase() {
84 test_cmp reflog_before reflog_after &&
85 rm reflog_before reflog_after
86 '
87 +
88 + test_expect_success 'rebase --abort can not be used with other options' '
89 + cd "$work_dir" &&
90 + # Clean up the state from the previous one
91 + git reset --hard pre-rebase &&
92 + test_must_fail git rebase$type master &&
93 + test_must_fail git rebase -v --abort &&
94 + test_must_fail git rebase --abort -v &&
95 + git rebase --abort
96 + '
97 }
98
99 testrebase "" .git/rebase-apply
t/t3418-rebase-continue.sh
+5
@@ -40,4 +40,9 @@ test_expect_success 'non-interactive rebase --continue works with touched file'
40 git rebase --continue
41 '
42
43 +test_expect_success 'rebase --continue can not be used with other options' '
44 + test_must_fail git rebase -v --continue &&
45 + test_must_fail git rebase --continue -v
46 +'
47 +
48 test_done