rebase (interactive-backend): make --keep-empty the default
[git] / t / t3424-rebase-empty.sh
1 #!/bin/sh
2
3 test_description='git rebase of commits that start or become empty'
4
5 . ./test-lib.sh
6
7 test_expect_success 'setup test repository' '
8         test_write_lines 1 2 3 4 5 6 7 8 9 10 >numbers &&
9         test_write_lines A B C D E F G H I J >letters &&
10         git add numbers letters &&
11         git commit -m A &&
12
13         git branch upstream &&
14         git branch localmods &&
15
16         git checkout upstream &&
17         test_write_lines A B C D E >letters &&
18         git add letters &&
19         git commit -m B &&
20
21         test_write_lines 1 2 3 4 five 6 7 8 9 ten >numbers &&
22         git add numbers &&
23         git commit -m C &&
24
25         git checkout localmods &&
26         test_write_lines 1 2 3 4 five 6 7 8 9 10 >numbers &&
27         git add numbers &&
28         git commit -m C2 &&
29
30         git commit --allow-empty -m D &&
31
32         test_write_lines A B C D E >letters &&
33         git add letters &&
34         git commit -m "Five letters ought to be enough for anybody"
35 '
36
37 test_expect_failure 'rebase (am-backend) with a variety of empty commits' '
38         test_when_finished "git rebase --abort" &&
39         git checkout -B testing localmods &&
40         # rebase (--am) should not drop commits that start empty
41         git rebase upstream &&
42
43         test_write_lines D C B A >expect &&
44         git log --format=%s >actual &&
45         test_cmp expect actual
46 '
47
48 test_expect_failure 'rebase --merge with a variety of empty commits' '
49         test_when_finished "git rebase --abort" &&
50         git checkout -B testing localmods &&
51         # rebase --merge should not halt on the commit that becomes empty
52         git rebase --merge upstream &&
53
54         test_write_lines D C B A >expect &&
55         git log --format=%s >actual &&
56         test_cmp expect actual
57 '
58
59 test_expect_success 'rebase --interactive with a variety of empty commits' '
60         git checkout -B testing localmods &&
61         test_must_fail git rebase --interactive upstream &&
62
63         git rebase --skip &&
64
65         test_write_lines D C B A >expect &&
66         git log --format=%s >actual &&
67         test_cmp expect actual
68 '
69
70 test_done