1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-13 19:16:28 +02:00
git/t/t3424-rebase-empty.sh
Brian Lyles c282eba2d5 rebase: update `--empty=ask` to `--empty=stop`
When git-am(1) got its own `--empty` option in 7c096b8d61 (am: support
--empty=<option> to handle empty patches, 2021-12-09), `stop` was used
instead of `ask`. `stop` is a more accurate term for describing what
really happens, and consistency is good.

Update git-rebase(1) to also use `stop`, while keeping `ask` as a
deprecated synonym. Update the tests to primarily use `stop`, but also
ensure that `ask` is still allowed.

In a future commit, we'll be adding a new `--empty` option for
git-cherry-pick(1) as well, making the consistency even more relevant.

Reported-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Brian Lyles <brianmlyles@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-25 16:45:40 -07:00

220 lines
5.6 KiB
Bash
Executable File

#!/bin/sh
test_description='git rebase of commits that start or become empty'
. ./test-lib.sh
test_expect_success 'setup test repository' '
test_write_lines 1 2 3 4 5 6 7 8 9 10 >numbers &&
test_write_lines A B C D E F G H I J >letters &&
git add numbers letters &&
git commit -m A &&
git branch upstream &&
git branch localmods &&
git checkout upstream &&
test_write_lines A B C D E >letters &&
git add letters &&
git commit -m B &&
test_write_lines 1 2 3 4 five 6 7 8 9 ten >numbers &&
git add numbers &&
git commit -m C &&
git checkout localmods &&
test_write_lines 1 2 3 4 five 6 7 8 9 10 >numbers &&
git add numbers &&
git commit -m C2 &&
git commit --allow-empty -m D &&
test_write_lines A B C D E >letters &&
git add letters &&
git commit -m "Five letters ought to be enough for anybody"
'
test_expect_failure 'rebase (apply-backend)' '
test_when_finished "git rebase --abort" &&
git checkout -B testing localmods &&
# rebase (--apply) should not drop commits that start empty
git rebase --apply upstream &&
test_write_lines D C B A >expect &&
git log --format=%s >actual &&
test_cmp expect actual
'
test_expect_success 'rebase --merge --empty=drop' '
git checkout -B testing localmods &&
git rebase --merge --empty=drop upstream &&
test_write_lines D C B A >expect &&
git log --format=%s >actual &&
test_cmp expect actual
'
test_expect_success 'rebase --merge uses default of --empty=drop' '
git checkout -B testing localmods &&
git rebase --merge upstream &&
test_write_lines D C B A >expect &&
git log --format=%s >actual &&
test_cmp expect actual
'
test_expect_success 'rebase --merge --empty=keep' '
git checkout -B testing localmods &&
git rebase --merge --empty=keep upstream &&
test_write_lines D C2 C B A >expect &&
git log --format=%s >actual &&
test_cmp expect actual
'
test_expect_success 'rebase --merge --empty=stop' '
git checkout -B testing localmods &&
test_must_fail git rebase --merge --empty=stop upstream &&
git rebase --skip &&
test_write_lines D C B A >expect &&
git log --format=%s >actual &&
test_cmp expect actual
'
test_expect_success 'rebase --merge --empty=ask' '
git checkout -B testing localmods &&
test_must_fail git rebase --merge --empty=ask upstream &&
git rebase --skip &&
test_write_lines D C B A >expect &&
git log --format=%s >actual &&
test_cmp expect actual
'
test_expect_success 'rebase --interactive --empty=drop' '
git checkout -B testing localmods &&
git rebase --interactive --empty=drop upstream &&
test_write_lines D C B A >expect &&
git log --format=%s >actual &&
test_cmp expect actual
'
test_expect_success 'rebase --interactive --empty=keep' '
git checkout -B testing localmods &&
git rebase --interactive --empty=keep upstream &&
test_write_lines D C2 C B A >expect &&
git log --format=%s >actual &&
test_cmp expect actual
'
test_expect_success 'rebase --interactive --empty=stop' '
git checkout -B testing localmods &&
test_must_fail git rebase --interactive --empty=stop upstream &&
git rebase --skip &&
test_write_lines D C B A >expect &&
git log --format=%s >actual &&
test_cmp expect actual
'
test_expect_success 'rebase --interactive uses default of --empty=stop' '
git checkout -B testing localmods &&
test_must_fail git rebase --interactive upstream &&
git rebase --skip &&
test_write_lines D C B A >expect &&
git log --format=%s >actual &&
test_cmp expect actual
'
test_expect_success 'rebase --merge --empty=drop --keep-empty' '
git checkout -B testing localmods &&
git rebase --merge --empty=drop --keep-empty upstream &&
test_write_lines D C B A >expect &&
git log --format=%s >actual &&
test_cmp expect actual
'
test_expect_success 'rebase --merge --empty=drop --no-keep-empty' '
git checkout -B testing localmods &&
git rebase --merge --empty=drop --no-keep-empty upstream &&
test_write_lines C B A >expect &&
git log --format=%s >actual &&
test_cmp expect actual
'
test_expect_success 'rebase --merge --empty=keep --keep-empty' '
git checkout -B testing localmods &&
git rebase --merge --empty=keep --keep-empty upstream &&
test_write_lines D C2 C B A >expect &&
git log --format=%s >actual &&
test_cmp expect actual
'
test_expect_success 'rebase --merge --empty=keep --no-keep-empty' '
git checkout -B testing localmods &&
git rebase --merge --empty=keep --no-keep-empty upstream &&
test_write_lines C2 C B A >expect &&
git log --format=%s >actual &&
test_cmp expect actual
'
test_expect_success 'rebase --merge does not leave state laying around' '
git checkout -B testing localmods~2 &&
git rebase --merge upstream &&
test_path_is_missing .git/CHERRY_PICK_HEAD &&
test_path_is_missing .git/MERGE_MSG
'
test_expect_success 'rebase --exec --empty=drop' '
git checkout -B testing localmods &&
git rebase --exec "true" --empty=drop upstream &&
test_write_lines D C B A >expect &&
git log --format=%s >actual &&
test_cmp expect actual
'
test_expect_success 'rebase --exec --empty=keep' '
git checkout -B testing localmods &&
git rebase --exec "true" --empty=keep upstream &&
test_write_lines D C2 C B A >expect &&
git log --format=%s >actual &&
test_cmp expect actual
'
test_expect_success 'rebase --exec uses default of --empty=keep' '
git checkout -B testing localmods &&
git rebase --exec "true" upstream &&
test_write_lines D C2 C B A >expect &&
git log --format=%s >actual &&
test_cmp expect actual
'
test_expect_success 'rebase --exec --empty=stop' '
git checkout -B testing localmods &&
test_must_fail git rebase --exec "true" --empty=stop upstream &&
git rebase --skip &&
test_write_lines D C B A >expect &&
git log --format=%s >actual &&
test_cmp expect actual
'
test_done