Skip to content

Commit

Permalink
rebase: stricter check of standalone sub command
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Martin von Zweigbergk authored and Junio C Hamano committed Feb 10, 2011
1 parent 3426232 commit 95135b0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions git-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ then
fi
test -n "$type" && in_progress=t

total_argc=$#
while test $# != 0
do
case "$1" in
Expand All @@ -239,9 +240,8 @@ do
OK_TO_SKIP_PRE_REBASE=
;;
--continue|--skip|--abort)
test $total_argc -eq 1 || usage
action=${1##--}
shift
break
;;
--onto)
test 2 -le "$#" || usage
Expand Down
5 changes: 5 additions & 0 deletions t/t3403-rebase-skip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ test_expect_success 'rebase with git am -3 (default)' '
test_must_fail git rebase master
'

test_expect_success 'rebase --skip can not be used with other options' '
test_must_fail git rebase -v --skip &&
test_must_fail git rebase --skip -v
'

test_expect_success 'rebase --skip with am -3' '
git rebase --skip
'
Expand Down
10 changes: 10 additions & 0 deletions t/t3407-rebase-abort.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ testrebase() {
test_cmp reflog_before reflog_after &&
rm reflog_before reflog_after
'

test_expect_success 'rebase --abort can not be used with other options' '
cd "$work_dir" &&
# Clean up the state from the previous one
git reset --hard pre-rebase &&
test_must_fail git rebase$type master &&
test_must_fail git rebase -v --abort &&
test_must_fail git rebase --abort -v &&
git rebase --abort
'
}

testrebase "" .git/rebase-apply
Expand Down
5 changes: 5 additions & 0 deletions t/t3418-rebase-continue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@ test_expect_success 'non-interactive rebase --continue works with touched file'
git rebase --continue
'

test_expect_success 'rebase --continue can not be used with other options' '
test_must_fail git rebase -v --continue &&
test_must_fail git rebase --continue -v
'

test_done

0 comments on commit 95135b0

Please sign in to comment.