t/gpg: simplify test for unknown key
[git/debian.git] / t / t5322-pack-objects-sparse.sh
blob61cb907a9035219aecde0d425bfe73a7c98083ae
1 #!/bin/sh
3 test_description='pack-objects object selection using sparse algorithm'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 . ./test-lib.sh
9 test_expect_success 'setup repo' '
10 test_commit initial &&
11 for i in $(test_seq 1 3)
13 mkdir f$i &&
14 for j in $(test_seq 1 3)
16 mkdir f$i/f$j &&
17 echo $j >f$i/f$j/data.txt
18 done
19 done &&
20 git add . &&
21 git commit -m "Initialized trees" &&
22 for i in $(test_seq 1 3)
24 git checkout -b topic$i main &&
25 echo change-$i >f$i/f$i/data.txt &&
26 git commit -a -m "Changed f$i/f$i/data.txt"
27 done &&
28 cat >packinput.txt <<-EOF &&
29 topic1
30 ^topic2
31 ^topic3
32 EOF
33 git rev-parse \
34 topic1 \
35 topic1^{tree} \
36 topic1:f1 \
37 topic1:f1/f1 \
38 topic1:f1/f1/data.txt | sort >expect_objects.txt
41 test_expect_success 'non-sparse pack-objects' '
42 git pack-objects --stdout --revs --no-sparse <packinput.txt >nonsparse.pack &&
43 git index-pack -o nonsparse.idx nonsparse.pack &&
44 git show-index <nonsparse.idx | awk "{print \$2}" >nonsparse_objects.txt &&
45 test_cmp expect_objects.txt nonsparse_objects.txt
48 test_expect_success 'sparse pack-objects' '
49 git pack-objects --stdout --revs --sparse <packinput.txt >sparse.pack &&
50 git index-pack -o sparse.idx sparse.pack &&
51 git show-index <sparse.idx | awk "{print \$2}" >sparse_objects.txt &&
52 test_cmp expect_objects.txt sparse_objects.txt
55 test_expect_success 'duplicate a folder from f3 and commit to topic1' '
56 git checkout topic1 &&
57 echo change-3 >f3/f3/data.txt &&
58 git commit -a -m "Changed f3/f3/data.txt" &&
59 git rev-parse \
60 topic1~1 \
61 topic1~1^{tree} \
62 topic1^{tree} \
63 topic1 \
64 topic1:f1 \
65 topic1:f1/f1 \
66 topic1:f1/f1/data.txt | sort >required_objects.txt
69 test_expect_success 'non-sparse pack-objects' '
70 git pack-objects --stdout --revs --no-sparse <packinput.txt >nonsparse.pack &&
71 git index-pack -o nonsparse.idx nonsparse.pack &&
72 git show-index <nonsparse.idx | awk "{print \$2}" >nonsparse_objects.txt &&
73 comm -1 -2 required_objects.txt nonsparse_objects.txt >nonsparse_required_objects.txt &&
74 test_cmp required_objects.txt nonsparse_required_objects.txt
77 test_expect_success 'sparse pack-objects' '
78 git pack-objects --stdout --revs --sparse <packinput.txt >sparse.pack &&
79 git index-pack -o sparse.idx sparse.pack &&
80 git show-index <sparse.idx | awk "{print \$2}" >sparse_objects.txt &&
81 comm -1 -2 required_objects.txt sparse_objects.txt >sparse_required_objects.txt &&
82 test_cmp required_objects.txt sparse_required_objects.txt
85 # Demonstrate that the algorithms differ when we copy a tree wholesale
86 # from one folder to another.
88 test_expect_success 'duplicate a folder from f1 into f3' '
89 mkdir f3/f4 &&
90 cp -r f1/f1/* f3/f4 &&
91 git add f3/f4 &&
92 git commit -m "Copied f1/f1 to f3/f4" &&
93 cat >packinput.txt <<-EOF &&
94 topic1
95 ^topic1~1
96 EOF
97 git rev-parse \
98 topic1 \
99 topic1^{tree} \
100 topic1:f3 | sort >required_objects.txt
103 test_expect_success 'non-sparse pack-objects' '
104 git pack-objects --stdout --revs --no-sparse <packinput.txt >nonsparse.pack &&
105 git index-pack -o nonsparse.idx nonsparse.pack &&
106 git show-index <nonsparse.idx | awk "{print \$2}" >nonsparse_objects.txt &&
107 comm -1 -2 required_objects.txt nonsparse_objects.txt >nonsparse_required_objects.txt &&
108 test_cmp required_objects.txt nonsparse_required_objects.txt
111 # --sparse is enabled by default by pack.useSparse
112 test_expect_success 'sparse pack-objects' '
113 GIT_TEST_PACK_SPARSE=-1 &&
114 git rev-parse \
115 topic1 \
116 topic1^{tree} \
117 topic1:f3 \
118 topic1:f3/f4 \
119 topic1:f3/f4/data.txt | sort >expect_sparse_objects.txt &&
120 git pack-objects --stdout --revs <packinput.txt >sparse.pack &&
121 git index-pack -o sparse.idx sparse.pack &&
122 git show-index <sparse.idx | awk "{print \$2}" >sparse_objects.txt &&
123 test_cmp expect_sparse_objects.txt sparse_objects.txt
126 test_expect_success 'pack.useSparse enables algorithm' '
127 git config pack.useSparse true &&
128 git pack-objects --stdout --revs <packinput.txt >sparse.pack &&
129 git index-pack -o sparse.idx sparse.pack &&
130 git show-index <sparse.idx | awk "{print \$2}" >sparse_objects.txt &&
131 test_cmp expect_sparse_objects.txt sparse_objects.txt
134 test_expect_success 'pack.useSparse overridden' '
135 git pack-objects --stdout --revs --no-sparse <packinput.txt >sparse.pack &&
136 git index-pack -o sparse.idx sparse.pack &&
137 git show-index <sparse.idx | awk "{print \$2}" >sparse_objects.txt &&
138 test_cmp required_objects.txt sparse_objects.txt
141 test_done