Git fork
at reftables-rust 219 lines 5.7 kB view raw
1#!/bin/sh 2 3test_description='git rebase of commits that start or become empty' 4 5. ./test-lib.sh 6 7test_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 37test_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 && 42 43 test_write_lines D C B A >expect && 44 git log --format=%s >actual && 45 test_cmp expect actual 46' 47 48test_expect_success 'rebase --merge --empty=drop' ' 49 git checkout -B testing localmods && 50 git rebase --merge --empty=drop upstream && 51 52 test_write_lines D C B A >expect && 53 git log --format=%s >actual && 54 test_cmp expect actual 55' 56 57test_expect_success 'rebase --merge uses default of --empty=drop' ' 58 git checkout -B testing localmods && 59 git rebase --merge upstream && 60 61 test_write_lines D C B A >expect && 62 git log --format=%s >actual && 63 test_cmp expect actual 64' 65 66test_expect_success 'rebase --merge --empty=keep' ' 67 git checkout -B testing localmods && 68 git rebase --merge --empty=keep upstream && 69 70 test_write_lines D C2 C B A >expect && 71 git log --format=%s >actual && 72 test_cmp expect actual 73' 74 75test_expect_success 'rebase --merge --empty=stop' ' 76 git checkout -B testing localmods && 77 test_must_fail git rebase --merge --empty=stop upstream && 78 79 git rebase --skip && 80 81 test_write_lines D C B A >expect && 82 git log --format=%s >actual && 83 test_cmp expect actual 84' 85 86test_expect_success 'rebase --merge --empty=ask' ' 87 git checkout -B testing localmods && 88 test_must_fail git rebase --merge --empty=ask upstream && 89 90 git rebase --skip && 91 92 test_write_lines D C B A >expect && 93 git log --format=%s >actual && 94 test_cmp expect actual 95' 96 97test_expect_success 'rebase --interactive --empty=drop' ' 98 git checkout -B testing localmods && 99 git rebase --interactive --empty=drop upstream && 100 101 test_write_lines D C B A >expect && 102 git log --format=%s >actual && 103 test_cmp expect actual 104' 105 106test_expect_success 'rebase --interactive --empty=keep' ' 107 git checkout -B testing localmods && 108 git rebase --interactive --empty=keep upstream && 109 110 test_write_lines D C2 C B A >expect && 111 git log --format=%s >actual && 112 test_cmp expect actual 113' 114 115test_expect_success 'rebase --interactive --empty=stop' ' 116 git checkout -B testing localmods && 117 test_must_fail git rebase --interactive --empty=stop upstream && 118 119 git rebase --skip && 120 121 test_write_lines D C B A >expect && 122 git log --format=%s >actual && 123 test_cmp expect actual 124' 125 126test_expect_success 'rebase --interactive uses default of --empty=stop' ' 127 git checkout -B testing localmods && 128 test_must_fail git rebase --interactive upstream && 129 130 git rebase --skip && 131 132 test_write_lines D C B A >expect && 133 git log --format=%s >actual && 134 test_cmp expect actual 135' 136 137test_expect_success 'rebase --merge --empty=drop --keep-empty' ' 138 git checkout -B testing localmods && 139 git rebase --merge --empty=drop --keep-empty upstream && 140 141 test_write_lines D C B A >expect && 142 git log --format=%s >actual && 143 test_cmp expect actual 144' 145 146test_expect_success 'rebase --merge --empty=drop --no-keep-empty' ' 147 git checkout -B testing localmods && 148 git rebase --merge --empty=drop --no-keep-empty upstream && 149 150 test_write_lines C B A >expect && 151 git log --format=%s >actual && 152 test_cmp expect actual 153' 154 155test_expect_success 'rebase --merge --empty=keep --keep-empty' ' 156 git checkout -B testing localmods && 157 git rebase --merge --empty=keep --keep-empty upstream && 158 159 test_write_lines D C2 C B A >expect && 160 git log --format=%s >actual && 161 test_cmp expect actual 162' 163 164test_expect_success 'rebase --merge --empty=keep --no-keep-empty' ' 165 git checkout -B testing localmods && 166 git rebase --merge --empty=keep --no-keep-empty upstream && 167 168 test_write_lines C2 C B A >expect && 169 git log --format=%s >actual && 170 test_cmp expect actual 171' 172 173test_expect_success 'rebase --merge does not leave state laying around' ' 174 git checkout -B testing localmods~2 && 175 git rebase --merge upstream && 176 177 test_path_is_missing .git/CHERRY_PICK_HEAD && 178 test_path_is_missing .git/MERGE_MSG 179' 180 181test_expect_success 'rebase --exec --empty=drop' ' 182 git checkout -B testing localmods && 183 git rebase --exec "true" --empty=drop upstream && 184 185 test_write_lines D C B A >expect && 186 git log --format=%s >actual && 187 test_cmp expect actual 188' 189 190test_expect_success 'rebase --exec --empty=keep' ' 191 git checkout -B testing localmods && 192 git rebase --exec "true" --empty=keep upstream && 193 194 test_write_lines D C2 C B A >expect && 195 git log --format=%s >actual && 196 test_cmp expect actual 197' 198 199test_expect_success 'rebase --exec uses default of --empty=keep' ' 200 git checkout -B testing localmods && 201 git rebase --exec "true" upstream && 202 203 test_write_lines D C2 C B A >expect && 204 git log --format=%s >actual && 205 test_cmp expect actual 206' 207 208test_expect_success 'rebase --exec --empty=stop' ' 209 git checkout -B testing localmods && 210 test_must_fail git rebase --exec "true" --empty=stop upstream && 211 212 git rebase --skip && 213 214 test_write_lines D C B A >expect && 215 git log --format=%s >actual && 216 test_cmp expect actual 217' 218 219test_done