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/t1010-mktree.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 / t1010-mktree.sh` 120 lines ยท 3460 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='git mktree' 4 5 . ./test-lib.sh 6 7 test_expect_success setup ' 8 for d in a a- a0 9 do 10 mkdir "$d" && echo "$d/one" >"$d/one" && 11 git add "$d" || return 1 12 done && 13 echo zero >one && 14 if test_have_prereq BROKEN_OBJECTS 15 then 16 git update-index --add --info-only one && 17 git write-tree --missing-ok >tree.missing && 18 git ls-tree $(cat tree.missing) >top.missing && 19 git ls-tree -r $(cat tree.missing) >all.missing 20 fi && 21 echo one >one && 22 git add one && 23 git write-tree >tree && 24 git ls-tree $(cat tree) >top && 25 git ls-tree -r $(cat tree) >all && 26 test_tick && 27 git commit -q -m one && 28 H=$(git rev-parse HEAD) && 29 git update-index --add --cacheinfo 160000 $H sub && 30 test_tick && 31 git commit -q -m two && 32 git rev-parse HEAD^{tree} >tree.withsub && 33 git ls-tree HEAD >top.withsub && 34 git ls-tree -r HEAD >all.withsub 35 ' 36 37 test_expect_success 'ls-tree piped to mktree (1)' ' 38 git mktree actual && 39 test_cmp tree actual 40 ' 41 42 test_expect_success 'ls-tree piped to mktree (2)' ' 43 git mktree actual && 44 test_cmp tree.withsub actual 45 ' 46 47 test_expect_success 'ls-tree output in wrong order given to mktree (1)' ' 48 sort -r actual && 50 test_cmp tree actual 51 ' 52 53 test_expect_success 'ls-tree output in wrong order given to mktree (2)' ' 54 sort -r actual && 56 test_cmp tree.withsub actual 57 ' 58 59 test_expect_success BROKEN_OBJECTS 'allow missing object with --missing' ' 60 git mktree --missing actual && 61 test_cmp tree.missing actual 62 ' 63 64 test_expect_success 'mktree refuses to read ls-tree -r output (1)' ' 65 test_must_fail git mktree pack-a && 81 echo "$b" | git pack-objects .git/objects/pack/pack >pack-b && 82 83 # Drop the loose copies so the blobs resolve only through the 84 # packs the multi-pack-index names. 85 git prune-packed && 86 git multi-pack-index write && 87 printf "100644 blob %s\ta\n" "$a" >tree-a && 88 printf "100644 blob %s\tb\n" "$b" >tree-b && 89 90 victim=".git/objects/pack/pack-$(cat pack-b)" && 91 mkfifo in out && 92 93 # mktree --batch stays resident, so its pack view predates the 94 # repack below; feed it one tree at a time over a fifo. The 95 # subshell exit closes the fifos, letting mktree see EOF and quit. 96 (git mktree --batch out 2>err &) && 97 exec 9>in && 98 exec 8&9 && echo >&9 && read tree_a <&8 && 102 103 # Mimic a concurrent repack: a replacement pack holds every 104 # object, and the pack for b loses its .idx (its .pack lingers), 105 # matching the order in which unlink_pack_path() removes files. 106 git cat-file --batch-all-objects --batch-check="%(objectname)" >oids && 107 git pack-objects .git/objects/pack/pack /dev/null && 108 rm -f "$victim.idx" && 109 110 # Resolving b used to fail, as its QUICK lookup accepted the 111 # miss; without QUICK the reader repreps and finds b in the 112 # replacement pack. 113 cat tree-b >&9 && echo >&9 && read tree_b <&8 && 114 exec 9>&- && 115 116 test -n "$tree_b" 117 ) 118 ' 119 120 test_done