t/lib-credential.sh: drop shebang line
[git/raj.git] / t / t3424-rebase-empty.sh
blobe1e30517ea646c56f6653c70b41968ca8c6222ed
1 #!/bin/sh
3 test_description='git rebase of commits that start or become empty'
5 . ./test-lib.sh
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 &&
13 git branch upstream &&
14 git branch localmods &&
16 git checkout upstream &&
17 test_write_lines A B C D E >letters &&
18 git add letters &&
19 git commit -m B &&
21 test_write_lines 1 2 3 4 five 6 7 8 9 ten >numbers &&
22 git add numbers &&
23 git commit -m C &&
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 &&
30 git commit --allow-empty -m D &&
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"
37 test_expect_failure 'rebase (apply-backend)' '
38 test_when_finished "git rebase --abort" &&
39 git checkout -B testing localmods &&
40 # rebase (--apply) should not drop commits that start empty
41 git rebase --apply upstream &&
43 test_write_lines D C B A >expect &&
44 git log --format=%s >actual &&
45 test_cmp expect actual
48 test_expect_success 'rebase --merge --empty=drop' '
49 git checkout -B testing localmods &&
50 git rebase --merge --empty=drop upstream &&
52 test_write_lines D C B A >expect &&
53 git log --format=%s >actual &&
54 test_cmp expect actual
57 test_expect_success 'rebase --merge uses default of --empty=drop' '
58 git checkout -B testing localmods &&
59 git rebase --merge upstream &&
61 test_write_lines D C B A >expect &&
62 git log --format=%s >actual &&
63 test_cmp expect actual
66 test_expect_success 'rebase --merge --empty=keep' '
67 git checkout -B testing localmods &&
68 git rebase --merge --empty=keep upstream &&
70 test_write_lines D C2 C B A >expect &&
71 git log --format=%s >actual &&
72 test_cmp expect actual
75 test_expect_success 'rebase --merge --empty=ask' '
76 git checkout -B testing localmods &&
77 test_must_fail git rebase --merge --empty=ask upstream &&
79 git rebase --skip &&
81 test_write_lines D C B A >expect &&
82 git log --format=%s >actual &&
83 test_cmp expect actual
86 test_expect_success 'rebase --interactive --empty=drop' '
87 git checkout -B testing localmods &&
88 git rebase --interactive --empty=drop upstream &&
90 test_write_lines D C B A >expect &&
91 git log --format=%s >actual &&
92 test_cmp expect actual
95 test_expect_success 'rebase --interactive --empty=keep' '
96 git checkout -B testing localmods &&
97 git rebase --interactive --empty=keep upstream &&
99 test_write_lines D C2 C B A >expect &&
100 git log --format=%s >actual &&
101 test_cmp expect actual
104 test_expect_success 'rebase --interactive --empty=ask' '
105 git checkout -B testing localmods &&
106 test_must_fail git rebase --interactive --empty=ask upstream &&
108 git rebase --skip &&
110 test_write_lines D C B A >expect &&
111 git log --format=%s >actual &&
112 test_cmp expect actual
115 test_expect_success 'rebase --interactive uses default of --empty=ask' '
116 git checkout -B testing localmods &&
117 test_must_fail git rebase --interactive upstream &&
119 git rebase --skip &&
121 test_write_lines D C B A >expect &&
122 git log --format=%s >actual &&
123 test_cmp expect actual
126 test_expect_success 'rebase --merge does not leave state laying around' '
127 git checkout -B testing localmods~2 &&
128 git rebase --merge upstream &&
130 test_path_is_missing .git/CHERRY_PICK_HEAD &&
131 test_path_is_missing .git/MERGE_MSG
134 test_done