Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t6007-rev-list-cherry-pick-file.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t6007-rev-list-cherry-pick-file.sh` 284 lines ยท 6965 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='test git rev-list --cherry-pick -- file' 4 5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 7 8 . ./test-lib.sh 9 10 # A---B---D---F 11 # \ 12 # \ 13 # C---E 14 # 15 # B changes a file foo.c, adding a line of text. C changes foo.c as 16 # well as bar.c, but the change in foo.c was identical to change B. 17 # D and C change bar in the same way, E and F differently. 18 19 test_expect_success setup ' 20 echo Hallo > foo && 21 git add foo && 22 test_tick && 23 git commit -m "A" && 24 git tag A && 25 git checkout -b branch && 26 echo Bello > foo && 27 echo Cello > bar && 28 git add foo bar && 29 test_tick && 30 git commit -m "C" && 31 git tag C && 32 echo Dello > bar && 33 git add bar && 34 test_tick && 35 git commit -m "E" && 36 git tag E && 37 git checkout main && 38 git checkout branch foo && 39 test_tick && 40 git commit -m "B" && 41 git tag B && 42 echo Cello > bar && 43 git add bar && 44 test_tick && 45 git commit -m "D" && 46 git tag D && 47 echo Nello > bar && 48 git add bar && 49 test_tick && 50 git commit -m "F" && 51 git tag F 52 ' 53 54 cat >expect <tags/C 57 EOF 58 59 test_expect_success '--left-right' ' 60 git rev-list --left-right B...C > actual && 61 git name-rev --annotate-stdin --name-only --refs="*tags/*" \ 62 < actual > actual.named && 63 test_cmp expect actual.named 64 ' 65 66 test_expect_success '--count' ' 67 git rev-list --count B...C > actual && 68 test "$(cat actual)" = 2 69 ' 70 71 test_expect_success '--cherry-pick foo comes up empty' ' 72 test -z "$(git rev-list --left-right --cherry-pick B...C -- foo)" 73 ' 74 75 cat >expect <tags/C 77 EOF 78 79 test_expect_success '--cherry-pick bar does not come up empty' ' 80 git rev-list --left-right --cherry-pick B...C -- bar > actual && 81 git name-rev --annotate-stdin --name-only --refs="*tags/*" \ 82 < actual > actual.named && 83 test_cmp expect actual.named 84 ' 85 86 test_expect_success 'bar does not come up empty' ' 87 git rev-list --left-right B...C -- bar > actual && 88 git name-rev --annotate-stdin --name-only --refs="*tags/*" \ 89 < actual > actual.named && 90 test_cmp expect actual.named 91 ' 92 93 cat >expect <tags/E 96 EOF 97 98 test_expect_success '--cherry-pick bar does not come up empty (II)' ' 99 git rev-list --left-right --cherry-pick F...E -- bar > actual && 100 git name-rev --annotate-stdin --name-only --refs="*tags/*" \ 101 < actual > actual.named && 102 test_cmp expect actual.named 103 ' 104 105 test_expect_success 'name-rev multiple --refs combine inclusive' ' 106 git rev-list --left-right --cherry-pick F...E -- bar >actual && 107 git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" \ 108 actual.named && 109 test_cmp expect actual.named 110 ' 111 112 cat >expect <>expect && 118 git rev-list --left-right --cherry-pick F...E -- bar >actual && 119 git name-rev --annotate-stdin --name-only --refs="*tags/F" \ 120 actual.named && 121 test_cmp expect actual.named 122 ' 123 124 cat >expect <>expect && 130 git rev-list --left-right --cherry-pick F...E -- bar >actual && 131 git name-rev --annotate-stdin --name-only --refs="*tags/*" --exclude="*E" \ 132 actual.named && 133 test_cmp expect actual.named 134 ' 135 136 test_expect_success 'name-rev --no-refs clears the refs list' ' 137 git rev-list --left-right --cherry-pick F...E -- bar >expect && 138 git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ 139 actual && 140 test_cmp expect actual 141 ' 142 143 cat >expect < actual && 152 git name-rev --annotate-stdin --name-only --refs="*tags/*" \ 153 < actual > actual.named && 154 test_cmp expect actual.named 155 ' 156 157 cat >expect <tags/E 161 =tags/C 162 EOF 163 164 test_expect_success '--cherry-mark --left-right' ' 165 git rev-list --cherry-mark --left-right F...E -- bar > actual && 166 git name-rev --annotate-stdin --name-only --refs="*tags/*" \ 167 < actual > actual.named && 168 test_cmp expect actual.named 169 ' 170 171 cat >expect < actual && 177 git name-rev --annotate-stdin --name-only --refs="*tags/*" \ 178 < actual > actual.named && 179 test_cmp expect actual.named 180 ' 181 182 test_expect_success '--cherry-pick --left-only' ' 183 git rev-list --cherry-pick --left-only E...F -- bar > actual && 184 git name-rev --annotate-stdin --name-only --refs="*tags/*" \ 185 < actual > actual.named && 186 test_cmp expect actual.named 187 ' 188 189 cat >expect < actual && 196 git name-rev --annotate-stdin --name-only --refs="*tags/*" \ 197 < actual > actual.named && 198 test_cmp expect actual.named 199 ' 200 201 cat >expect < actual && 207 test_cmp expect actual 208 ' 209 210 cat >expect < actual && 216 test_cmp expect actual 217 ' 218 219 cat >expect < actual && 225 test_cmp expect actual 226 ' 227 228 test_expect_success '--cherry-pick with independent, but identical branches' ' 229 git symbolic-ref HEAD refs/heads/independent && 230 rm .git/index && 231 echo Hallo > foo && 232 git add foo && 233 test_tick && 234 git commit -m "independent" && 235 echo Bello > foo && 236 test_tick && 237 git commit -m "independent, too" foo && 238 test -z "$(git rev-list --left-right --cherry-pick \ 239 HEAD...main -- foo)" 240 ' 241 242 cat >expect < actual && 248 test_cmp expect actual 249 ' 250 251 test_expect_success '--cherry-pick with duplicates on each side' ' 252 git checkout -b dup-orig && 253 test_commit dup-base && 254 git revert dup-base && 255 git cherry-pick dup-base && 256 git checkout -b dup-side HEAD~3 && 257 test_tick && 258 git cherry-pick -3 dup-orig && 259 git rev-list --cherry-pick dup-orig...dup-side >actual && 260 test_must_be_empty actual 261 ' 262 263 # Corrupt the object store deliberately to make sure 264 # the object is not even checked for its existence. 265 remove_loose_object () { 266 sha1="$(git rev-parse "$1")" && 267 remainder=${sha1#??} && 268 firsttwo=${sha1%$remainder} && 269 rm .git/objects/$firsttwo/$remainder 270 } 271 272 test_expect_success '--cherry-pick avoids looking at full diffs' ' 273 git checkout -b shy-diff && 274 test_commit dont-look-at-me && 275 echo Hello >dont-look-at-me.t && 276 test_tick && 277 git commit -m tip dont-look-at-me.t && 278 git checkout -b mainline HEAD^ && 279 test_commit to-cherry-pick && 280 remove_loose_object shy-diff^:dont-look-at-me.t && 281 git rev-list --cherry-pick ...shy-diff 282 ' 283 284 test_done