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/t6000-rev-list-misc.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 / t6000-rev-list-misc.sh` 297 lines ยท 7700 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='miscellaneous rev-list tests' 4 5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 7 8 . ./test-lib.sh 9 10 test_expect_success setup ' 11 echo content1 >wanted_file && 12 echo content2 >unwanted_file && 13 git add wanted_file unwanted_file && 14 test_tick && 15 git commit -m one 16 ' 17 18 test_expect_success 'rev-list --objects heeds pathspecs' ' 19 git rev-list --objects HEAD -- wanted_file >output && 20 test_grep wanted_file output && 21 test_grep ! unwanted_file output 22 ' 23 24 test_expect_success 'rev-list --objects with pathspecs and deeper paths' ' 25 mkdir foo && 26 >foo/file && 27 git add foo/file && 28 test_tick && 29 git commit -m two && 30 31 git rev-list --objects HEAD -- foo >output && 32 test_grep foo/file output && 33 34 git rev-list --objects HEAD -- foo/file >output && 35 test_grep foo/file output && 36 test_grep ! unwanted_file output 37 ' 38 39 test_expect_success 'rev-list --objects with pathspecs and copied files' ' 40 git checkout --orphan junio-testcase && 41 git rm -rf . && 42 43 mkdir two && 44 echo frotz >one && 45 cp one two/three && 46 git add one two/three && 47 test_tick && 48 git commit -m that && 49 50 ONE=$(git rev-parse HEAD:one) && 51 git rev-list --objects HEAD two >output && 52 test_grep "$ONE two/three" output && 53 test_grep ! one output 54 ' 55 56 test_expect_success 'rev-list --objects --no-object-names has no space/names' ' 57 git rev-list --objects --no-object-names HEAD >output && 58 test_grep ! wanted_file output && 59 test_grep ! unwanted_file output && 60 test_grep ! " " output 61 ' 62 63 test_expect_success 'rev-list --objects --no-object-names works with cat-file' ' 64 git rev-list --objects --no-object-names --all >list-output && 65 git cat-file --batch-check cat-output && 66 test_grep ! missing cat-output 67 ' 68 69 test_expect_success '--no-object-names and --object-names are last-one-wins' ' 70 git rev-list --objects --no-object-names --object-names --all >output && 71 test_grep wanted_file output && 72 git rev-list --objects --object-names --no-object-names --all >output && 73 test_grep ! wanted_file output 74 ' 75 76 test_expect_success 'rev-list A..B and rev-list ^A B are the same' ' 77 test_tick && 78 git commit --allow-empty -m another && 79 git tag -a -m "annotated" v1.0 && 80 git rev-list --objects ^v1.0^ v1.0 >expect && 81 git rev-list --objects v1.0^..v1.0 >actual && 82 test_cmp expect actual 83 ' 84 85 test_expect_success 'propagate uninteresting flag down correctly' ' 86 git rev-list --objects ^HEAD^{tree} HEAD^{tree} >actual && 87 test_must_be_empty actual 88 ' 89 90 test_expect_success 'symleft flag bit is propagated down from tag' ' 91 git log --format="%m %s" --left-right v1.0...main >actual && 92 cat >expect <<-\EOF && 93 < another 94 < that 95 > two 96 > one 97 EOF 98 test_cmp expect actual 99 ' 100 101 test_expect_success 'rev-list can show index objects' ' 102 # Of the blobs and trees in the index, note: 103 # 104 # - we do not show two/three, because it is the 105 # same blob as "one", and we show objects only once 106 # 107 # - we do show the tree "two", because it has a valid cache tree 108 # from the last commit 109 # 110 # - we do not show the root tree; since we updated the index, it 111 # does not have a valid cache tree 112 # 113 echo only-in-index >only-in-index && 114 test_when_finished "git reset --hard" && 115 rev1=$(git rev-parse HEAD:one) && 116 rev2=$(git rev-parse HEAD:two) && 117 revi=$(git hash-object only-in-index) && 118 cat >expect <<-EOF && 119 $rev1 one 120 $revi only-in-index 121 $rev2 two 122 EOF 123 git add only-in-index && 124 git rev-list --objects --indexed-objects >actual && 125 test_cmp expect actual 126 ' 127 128 test_expect_success 'rev-list can negate index objects' ' 129 git rev-parse HEAD >expect && 130 git rev-list -1 --objects HEAD --not --indexed-objects >actual && 131 test_cmp expect actual 132 ' 133 134 test_expect_success '--bisect and --first-parent can be combined' ' 135 git rev-list --bisect --first-parent HEAD 136 ' 137 138 test_expect_success '--header shows a NUL after each commit' ' 139 # We know that there is no Q in the true payload; names and 140 # addresses of the authors and the committers do not have 141 # any, and object names or header names do not, either. 142 git rev-list --header --max-count=2 HEAD | 143 nul_to_q | 144 grep "^Q" >actual && 145 cat >expect <<-EOF && 146 Q$(git rev-parse HEAD~1) 147 Q 148 EOF 149 test_cmp expect actual 150 ' 151 152 test_expect_success 'rev-list --end-of-options' ' 153 git update-ref refs/heads/--output=yikes HEAD && 154 git rev-list --end-of-options --output=yikes >actual && 155 test_path_is_missing yikes && 156 git rev-list HEAD >expect && 157 test_cmp expect actual 158 ' 159 160 test_expect_success 'rev-list --count' ' 161 count=$(git rev-list --count HEAD) && 162 git rev-list HEAD >actual && 163 test_line_count = $count actual 164 ' 165 166 test_expect_success 'rev-list --count --objects' ' 167 count=$(git rev-list --count --objects HEAD) && 168 git rev-list --objects HEAD >actual && 169 test_line_count = $count actual 170 ' 171 172 test_expect_success 'rev-list --unpacked' ' 173 git repack -ad && 174 test_commit unpacked && 175 176 git rev-list --objects --no-object-names unpacked^.. >expect.raw && 177 sort expect.raw >expect && 178 179 git rev-list --all --objects --unpacked --no-object-names >actual.raw && 180 sort actual.raw >actual && 181 182 test_cmp expect actual 183 ' 184 185 test_expect_success 'rev-list one-sided unrelated symmetric diff' ' 186 test_tick && 187 git commit --allow-empty -m xyz && 188 git branch cmp && 189 git rebase --force-rebase --root && 190 191 git rev-list --left-only HEAD...cmp >head && 192 git rev-list --right-only HEAD...cmp >cmp && 193 194 sort head >head.sorted && 195 sort cmp >cmp.sorted && 196 comm -12 head.sorted cmp.sorted >actual && 197 test_line_count = 0 actual 198 ' 199 200 test_expect_success 'rev-list -z' ' 201 test_when_finished rm -rf repo && 202 203 git init repo && 204 test_commit -C repo 1 && 205 test_commit -C repo 2 && 206 207 oid1=$(git -C repo rev-parse HEAD~) && 208 oid2=$(git -C repo rev-parse HEAD) && 209 210 printf "%s\0%s\0" "$oid2" "$oid1" >expect && 211 git -C repo rev-list -z HEAD >actual && 212 213 test_cmp expect actual 214 ' 215 216 test_expect_success 'rev-list -z --objects' ' 217 test_when_finished rm -rf repo && 218 219 git init repo && 220 test_commit -C repo 1 && 221 test_commit -C repo 2 && 222 223 oid1=$(git -C repo rev-parse HEAD:1.t) && 224 oid2=$(git -C repo rev-parse HEAD:2.t) && 225 path1=1.t && 226 path2=2.t && 227 228 printf "%s\0path=%s\0%s\0path=%s\0" "$oid1" "$path1" "$oid2" "$path2" \ 229 >expect && 230 git -C repo rev-list -z --objects HEAD:1.t HEAD:2.t >actual && 231 232 test_cmp expect actual 233 ' 234 235 test_expect_success 'rev-list -z --boundary' ' 236 test_when_finished rm -rf repo && 237 238 git init repo && 239 test_commit -C repo 1 && 240 test_commit -C repo 2 && 241 242 oid1=$(git -C repo rev-parse HEAD~) && 243 oid2=$(git -C repo rev-parse HEAD) && 244 245 printf "%s\0%s\0boundary=yes\0" "$oid2" "$oid1" >expect && 246 git -C repo rev-list -z --boundary HEAD~.. >actual && 247 248 test_cmp expect actual 249 ' 250 251 test_expect_success 'rev-list --boundary incompatible with --maximal-only' ' 252 test_when_finished rm -rf repo && 253 254 git init repo && 255 test_commit -C repo 1 && 256 test_commit -C repo 2 && 257 258 oid1=$(git -C repo rev-parse HEAD~) && 259 oid2=$(git -C repo rev-parse HEAD) && 260 261 test_must_fail git -C repo rev-list --boundary --maximal-only \ 262 HEAD~1..HEAD 2>err && 263 test_grep "cannot be used together" err 264 ' 265 266 test_expect_success 'rev-list --maximal-only and --pretty' ' 267 test_when_finished rm -rf repo && 268 269 git init repo && 270 test_commit -C repo 1 && 271 oid1=$(git -C repo rev-parse HEAD) && 272 test_commit -C repo 2 && 273 oid2=$(git -C repo rev-parse HEAD) && 274 git -C repo checkout --detach HEAD~1 && 275 test_commit -C repo 3 && 276 oid3=$(git -C repo rev-parse HEAD) && 277 278 cat >expect <<-EOF && 279 commit $oid3 280 $oid3 281 commit $oid2 282 $oid2 283 EOF 284 285 git -C repo rev-list --pretty="%H" --maximal-only $oid1 $oid2 $oid3 >out && 286 test_cmp expect out && 287 288 cat >expect <<-EOF && 289 $oid3 290 $oid2 291 EOF 292 293 git -C repo log --pretty="%H" --maximal-only $oid1 $oid2 $oid3 >out && 294 test_cmp expect out 295 ' 296 297 test_done