]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5322-pack-objects-sparse.sh
path.c: don't call the match function without value in trie_find()
[thirdparty/git.git] / t / t5322-pack-objects-sparse.sh
CommitLineData
4f6d26b1
DS
1#!/bin/sh
2
3test_description='pack-objects object selection using sparse algorithm'
4. ./test-lib.sh
5
6test_expect_success 'setup repo' '
7 test_commit initial &&
8 for i in $(test_seq 1 3)
9 do
10 mkdir f$i &&
11 for j in $(test_seq 1 3)
12 do
13 mkdir f$i/f$j &&
14 echo $j >f$i/f$j/data.txt
15 done
16 done &&
17 git add . &&
18 git commit -m "Initialized trees" &&
19 for i in $(test_seq 1 3)
20 do
21 git checkout -b topic$i master &&
22 echo change-$i >f$i/f$i/data.txt &&
23 git commit -a -m "Changed f$i/f$i/data.txt"
24 done &&
25 cat >packinput.txt <<-EOF &&
26 topic1
27 ^topic2
28 ^topic3
29 EOF
30 git rev-parse \
31 topic1 \
32 topic1^{tree} \
33 topic1:f1 \
34 topic1:f1/f1 \
35 topic1:f1/f1/data.txt | sort >expect_objects.txt
36'
37
38test_expect_success 'non-sparse pack-objects' '
99dbbfa8 39 git pack-objects --stdout --revs --no-sparse <packinput.txt >nonsparse.pack &&
4f6d26b1
DS
40 git index-pack -o nonsparse.idx nonsparse.pack &&
41 git show-index <nonsparse.idx | awk "{print \$2}" >nonsparse_objects.txt &&
42 test_cmp expect_objects.txt nonsparse_objects.txt
43'
44
45test_expect_success 'sparse pack-objects' '
46 git pack-objects --stdout --revs --sparse <packinput.txt >sparse.pack &&
47 git index-pack -o sparse.idx sparse.pack &&
48 git show-index <sparse.idx | awk "{print \$2}" >sparse_objects.txt &&
49 test_cmp expect_objects.txt sparse_objects.txt
50'
51
52test_expect_success 'duplicate a folder from f3 and commit to topic1' '
53 git checkout topic1 &&
54 echo change-3 >f3/f3/data.txt &&
55 git commit -a -m "Changed f3/f3/data.txt" &&
56 git rev-parse \
57 topic1~1 \
58 topic1~1^{tree} \
59 topic1^{tree} \
60 topic1 \
61 topic1:f1 \
62 topic1:f1/f1 \
63 topic1:f1/f1/data.txt | sort >required_objects.txt
64'
65
66test_expect_success 'non-sparse pack-objects' '
99dbbfa8 67 git pack-objects --stdout --revs --no-sparse <packinput.txt >nonsparse.pack &&
4f6d26b1
DS
68 git index-pack -o nonsparse.idx nonsparse.pack &&
69 git show-index <nonsparse.idx | awk "{print \$2}" >nonsparse_objects.txt &&
70 comm -1 -2 required_objects.txt nonsparse_objects.txt >nonsparse_required_objects.txt &&
71 test_cmp required_objects.txt nonsparse_required_objects.txt
72'
73
74test_expect_success 'sparse pack-objects' '
75 git pack-objects --stdout --revs --sparse <packinput.txt >sparse.pack &&
76 git index-pack -o sparse.idx sparse.pack &&
77 git show-index <sparse.idx | awk "{print \$2}" >sparse_objects.txt &&
78 comm -1 -2 required_objects.txt sparse_objects.txt >sparse_required_objects.txt &&
79 test_cmp required_objects.txt sparse_required_objects.txt
80'
81
d5d2e935
DS
82# Demonstrate that the algorithms differ when we copy a tree wholesale
83# from one folder to another.
84
4f6d26b1
DS
85test_expect_success 'duplicate a folder from f1 into f3' '
86 mkdir f3/f4 &&
87 cp -r f1/f1/* f3/f4 &&
88 git add f3/f4 &&
89 git commit -m "Copied f1/f1 to f3/f4" &&
90 cat >packinput.txt <<-EOF &&
91 topic1
92 ^topic1~1
93 EOF
94 git rev-parse \
95 topic1 \
96 topic1^{tree} \
97 topic1:f3 | sort >required_objects.txt
98'
99
100test_expect_success 'non-sparse pack-objects' '
d5d2e935 101 git pack-objects --stdout --revs --no-sparse <packinput.txt >nonsparse.pack &&
4f6d26b1
DS
102 git index-pack -o nonsparse.idx nonsparse.pack &&
103 git show-index <nonsparse.idx | awk "{print \$2}" >nonsparse_objects.txt &&
104 comm -1 -2 required_objects.txt nonsparse_objects.txt >nonsparse_required_objects.txt &&
105 test_cmp required_objects.txt nonsparse_required_objects.txt
106'
107
108test_expect_success 'sparse pack-objects' '
d5d2e935
DS
109 git rev-parse \
110 topic1 \
111 topic1^{tree} \
112 topic1:f3 \
113 topic1:f3/f4 \
114 topic1:f3/f4/data.txt | sort >expect_sparse_objects.txt &&
4f6d26b1
DS
115 git pack-objects --stdout --revs --sparse <packinput.txt >sparse.pack &&
116 git index-pack -o sparse.idx sparse.pack &&
117 git show-index <sparse.idx | awk "{print \$2}" >sparse_objects.txt &&
d5d2e935 118 test_cmp expect_sparse_objects.txt sparse_objects.txt
4f6d26b1
DS
119'
120
3d036eb0
DS
121test_expect_success 'pack.useSparse enables algorithm' '
122 git config pack.useSparse true &&
123 git pack-objects --stdout --revs <packinput.txt >sparse.pack &&
124 git index-pack -o sparse.idx sparse.pack &&
125 git show-index <sparse.idx | awk "{print \$2}" >sparse_objects.txt &&
126 test_cmp expect_sparse_objects.txt sparse_objects.txt
127'
128
129test_expect_success 'pack.useSparse overridden' '
130 git pack-objects --stdout --revs --no-sparse <packinput.txt >sparse.pack &&
131 git index-pack -o sparse.idx sparse.pack &&
132 git show-index <sparse.idx | awk "{print \$2}" >sparse_objects.txt &&
133 test_cmp required_objects.txt sparse_objects.txt
134'
135
4f6d26b1 136test_done