Merge branch 'master' of git://github.com/git-l10n/git-po
[git/raj.git] / t / t5322-pack-objects-sparse.sh
blob7124b5581a0e3e31ae9b78b46aec9f059eeb7c1a
1 #!/bin/sh
3 test_description='pack-objects object selection using sparse algorithm'
4 . ./test-lib.sh
6 test_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)
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)
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
38 test_expect_success 'non-sparse pack-objects' '
39 git pack-objects --stdout --revs --no-sparse <packinput.txt >nonsparse.pack &&
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
45 test_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
52 test_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
66 test_expect_success 'non-sparse pack-objects' '
67 git pack-objects --stdout --revs --no-sparse <packinput.txt >nonsparse.pack &&
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
74 test_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
82 # Demonstrate that the algorithms differ when we copy a tree wholesale
83 # from one folder to another.
85 test_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
100 test_expect_success 'non-sparse pack-objects' '
101 git pack-objects --stdout --revs --no-sparse <packinput.txt >nonsparse.pack &&
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
108 test_expect_success 'sparse pack-objects' '
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 &&
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 &&
118 test_cmp expect_sparse_objects.txt sparse_objects.txt
121 test_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
129 test_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
136 test_done