http-backend: buffer headers before sending
[git/debian.git] / t / t5310-pack-bitmaps.sh
blob3893afd687986ec7ec9102658c8dc332c61d25fa
1 #!/bin/sh
3 test_description='exercise basic bitmap functionality'
4 . ./test-lib.sh
6 objpath () {
7 echo ".git/objects/$(echo "$1" | sed -e 's|\(..\)|\1/|')"
10 test_expect_success 'setup repo with moderate-sized history' '
11 for i in $(test_seq 1 10); do
12 test_commit $i
13 done &&
14 git checkout -b other HEAD~5 &&
15 for i in $(test_seq 1 10); do
16 test_commit side-$i
17 done &&
18 git checkout master &&
19 blob=$(echo tagged-blob | git hash-object -w --stdin) &&
20 git tag tagged-blob $blob &&
21 git config repack.writebitmaps true &&
22 git config pack.writebitmaphashcache true
25 test_expect_success 'full repack creates bitmaps' '
26 git repack -ad &&
27 ls .git/objects/pack/ | grep bitmap >output &&
28 test_line_count = 1 output
31 test_expect_success 'rev-list --test-bitmap verifies bitmaps' '
32 git rev-list --test-bitmap HEAD
35 rev_list_tests() {
36 state=$1
38 test_expect_success "counting commits via bitmap ($state)" '
39 git rev-list --count HEAD >expect &&
40 git rev-list --use-bitmap-index --count HEAD >actual &&
41 test_cmp expect actual
44 test_expect_success "counting partial commits via bitmap ($state)" '
45 git rev-list --count HEAD~5..HEAD >expect &&
46 git rev-list --use-bitmap-index --count HEAD~5..HEAD >actual &&
47 test_cmp expect actual
50 test_expect_success "counting commits with limit ($state)" '
51 git rev-list --count -n 1 HEAD >expect &&
52 git rev-list --use-bitmap-index --count -n 1 HEAD >actual &&
53 test_cmp expect actual
56 test_expect_success "counting non-linear history ($state)" '
57 git rev-list --count other...master >expect &&
58 git rev-list --use-bitmap-index --count other...master >actual &&
59 test_cmp expect actual
62 test_expect_success "counting commits with limiting ($state)" '
63 git rev-list --count HEAD -- 1.t >expect &&
64 git rev-list --use-bitmap-index --count HEAD -- 1.t >actual &&
65 test_cmp expect actual
68 test_expect_success "enumerate --objects ($state)" '
69 git rev-list --objects --use-bitmap-index HEAD >tmp &&
70 cut -d" " -f1 <tmp >tmp2 &&
71 sort <tmp2 >actual &&
72 git rev-list --objects HEAD >tmp &&
73 cut -d" " -f1 <tmp >tmp2 &&
74 sort <tmp2 >expect &&
75 test_cmp expect actual
78 test_expect_success "bitmap --objects handles non-commit objects ($state)" '
79 git rev-list --objects --use-bitmap-index HEAD tagged-blob >actual &&
80 grep $blob actual
84 rev_list_tests 'full bitmap'
86 test_expect_success 'clone from bitmapped repository' '
87 git clone --no-local --bare . clone.git &&
88 git rev-parse HEAD >expect &&
89 git --git-dir=clone.git rev-parse HEAD >actual &&
90 test_cmp expect actual
93 test_expect_success 'setup further non-bitmapped commits' '
94 for i in $(test_seq 1 10); do
95 test_commit further-$i
96 done
99 rev_list_tests 'partial bitmap'
101 test_expect_success 'fetch (partial bitmap)' '
102 git --git-dir=clone.git fetch origin master:master &&
103 git rev-parse HEAD >expect &&
104 git --git-dir=clone.git rev-parse HEAD >actual &&
105 test_cmp expect actual
108 test_expect_success 'incremental repack cannot create bitmaps' '
109 test_commit more-1 &&
110 find .git/objects/pack -name "*.bitmap" >expect &&
111 git repack -d &&
112 find .git/objects/pack -name "*.bitmap" >actual &&
113 test_cmp expect actual
116 test_expect_success 'incremental repack can disable bitmaps' '
117 test_commit more-2 &&
118 git repack -d --no-write-bitmap-index
121 test_expect_success 'full repack, reusing previous bitmaps' '
122 git repack -ad &&
123 ls .git/objects/pack/ | grep bitmap >output &&
124 test_line_count = 1 output
127 test_expect_success 'fetch (full bitmap)' '
128 git --git-dir=clone.git fetch origin master:master &&
129 git rev-parse HEAD >expect &&
130 git --git-dir=clone.git rev-parse HEAD >actual &&
131 test_cmp expect actual
134 test_expect_success 'create objects for missing-HAVE tests' '
135 blob=$(echo "missing have" | git hash-object -w --stdin) &&
136 tree=$(printf "100644 blob $blob\tfile\n" | git mktree) &&
137 parent=$(echo parent | git commit-tree $tree) &&
138 commit=$(echo commit | git commit-tree $tree -p $parent) &&
139 cat >revs <<-EOF
140 HEAD
141 ^HEAD^
142 ^$commit
146 test_expect_success 'pack with missing blob' '
147 rm $(objpath $blob) &&
148 git pack-objects --stdout --revs <revs >/dev/null
151 test_expect_success 'pack with missing tree' '
152 rm $(objpath $tree) &&
153 git pack-objects --stdout --revs <revs >/dev/null
156 test_expect_success 'pack with missing parent' '
157 rm $(objpath $parent) &&
158 git pack-objects --stdout --revs <revs >/dev/null
161 test_lazy_prereq JGIT '
162 type jgit
165 test_expect_success JGIT 'we can read jgit bitmaps' '
166 git clone . compat-jgit &&
168 cd compat-jgit &&
169 rm -f .git/objects/pack/*.bitmap &&
170 jgit gc &&
171 git rev-list --test-bitmap HEAD
175 test_expect_success JGIT 'jgit can read our bitmaps' '
176 git clone . compat-us &&
178 cd compat-us &&
179 git repack -adb &&
180 # jgit gc will barf if it does not like our bitmaps
181 jgit gc
185 test_expect_success 'splitting packs does not generate bogus bitmaps' '
186 test-genrandom foo $((1024 * 1024)) >rand &&
187 git add rand &&
188 git commit -m "commit with big file" &&
189 git -c pack.packSizeLimit=500k repack -adb &&
190 git init --bare no-bitmaps.git &&
191 git -C no-bitmaps.git fetch .. HEAD
194 test_done