Skip to content

Commit 95135b0

Browse files
Martin von Zweigbergkgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3426232 commit 95135b0

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

git-rebase.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ then
229229
fi
230230
test -n "$type" && in_progress=t
231231

232+
total_argc=$#
232233
while test $# != 0
233234
do
234235
case "$1" in
@@ -239,9 +240,8 @@ do
239240
OK_TO_SKIP_PRE_REBASE=
240241
;;
241242
--continue|--skip|--abort)
243+
test $total_argc -eq 1 || usage
242244
action=${1##--}
243-
shift
244-
break
245245
;;
246246
--onto)
247247
test 2 -le "$#" || usage

t/t3403-rebase-skip.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ test_expect_success 'rebase with git am -3 (default)' '
3535
test_must_fail git rebase master
3636
'
3737

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+
3843
test_expect_success 'rebase --skip with am -3' '
3944
git rebase --skip
4045
'

t/t3407-rebase-abort.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ testrebase() {
8484
test_cmp reflog_before reflog_after &&
8585
rm reflog_before reflog_after
8686
'
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+
'
8797
}
8898

8999
testrebase "" .git/rebase-apply

t/t3418-rebase-continue.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,9 @@ test_expect_success 'non-interactive rebase --continue works with touched file'
4040
git rebase --continue
4141
'
4242

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+
4348
test_done

0 commit comments

Comments
 (0)