]>
Commit | Line | Data |
---|---|---|
212f2ffb JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='exercise basic bitmap functionality' | |
4 | . ./test-lib.sh | |
5 | ||
2db1a43f VM |
6 | objpath () { |
7 | echo ".git/objects/$(echo "$1" | sed -e 's|\(..\)|\1/|')" | |
8 | } | |
9 | ||
212f2ffb JK |
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 && | |
71d76cb4 | 21 | git config repack.writebitmaps true && |
ae4f07fb | 22 | git config pack.writebitmaphashcache true |
212f2ffb JK |
23 | ' |
24 | ||
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 | |
29 | ' | |
30 | ||
31 | test_expect_success 'rev-list --test-bitmap verifies bitmaps' ' | |
32 | git rev-list --test-bitmap HEAD | |
33 | ' | |
34 | ||
35 | rev_list_tests() { | |
36 | state=$1 | |
37 | ||
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 | |
42 | ' | |
43 | ||
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 | |
48 | ' | |
49 | ||
50 | test_expect_success "counting non-linear history ($state)" ' | |
51 | git rev-list --count other...master >expect && | |
52 | git rev-list --use-bitmap-index --count other...master >actual && | |
53 | test_cmp expect actual | |
54 | ' | |
55 | ||
56 | test_expect_success "enumerate --objects ($state)" ' | |
57 | git rev-list --objects --use-bitmap-index HEAD >tmp && | |
58 | cut -d" " -f1 <tmp >tmp2 && | |
59 | sort <tmp2 >actual && | |
60 | git rev-list --objects HEAD >tmp && | |
61 | cut -d" " -f1 <tmp >tmp2 && | |
62 | sort <tmp2 >expect && | |
63 | test_cmp expect actual | |
64 | ' | |
65 | ||
66 | test_expect_success "bitmap --objects handles non-commit objects ($state)" ' | |
67 | git rev-list --objects --use-bitmap-index HEAD tagged-blob >actual && | |
68 | grep $blob actual | |
69 | ' | |
70 | } | |
71 | ||
72 | rev_list_tests 'full bitmap' | |
73 | ||
74 | test_expect_success 'clone from bitmapped repository' ' | |
75 | git clone --no-local --bare . clone.git && | |
76 | git rev-parse HEAD >expect && | |
77 | git --git-dir=clone.git rev-parse HEAD >actual && | |
78 | test_cmp expect actual | |
79 | ' | |
80 | ||
81 | test_expect_success 'setup further non-bitmapped commits' ' | |
82 | for i in $(test_seq 1 10); do | |
83 | test_commit further-$i | |
84 | done | |
85 | ' | |
86 | ||
87 | rev_list_tests 'partial bitmap' | |
88 | ||
89 | test_expect_success 'fetch (partial bitmap)' ' | |
90 | git --git-dir=clone.git fetch origin master:master && | |
91 | git rev-parse HEAD >expect && | |
92 | git --git-dir=clone.git rev-parse HEAD >actual && | |
93 | test_cmp expect actual | |
94 | ' | |
95 | ||
96 | test_expect_success 'incremental repack cannot create bitmaps' ' | |
97 | test_commit more-1 && | |
373c67da JK |
98 | find .git/objects/pack -name "*.bitmap" >expect && |
99 | git repack -d && | |
100 | find .git/objects/pack -name "*.bitmap" >actual && | |
101 | test_cmp expect actual | |
212f2ffb JK |
102 | ' |
103 | ||
104 | test_expect_success 'incremental repack can disable bitmaps' ' | |
105 | test_commit more-2 && | |
106 | git repack -d --no-write-bitmap-index | |
107 | ' | |
108 | ||
109 | test_expect_success 'full repack, reusing previous bitmaps' ' | |
110 | git repack -ad && | |
111 | ls .git/objects/pack/ | grep bitmap >output && | |
112 | test_line_count = 1 output | |
113 | ' | |
114 | ||
115 | test_expect_success 'fetch (full bitmap)' ' | |
116 | git --git-dir=clone.git fetch origin master:master && | |
117 | git rev-parse HEAD >expect && | |
118 | git --git-dir=clone.git rev-parse HEAD >actual && | |
119 | test_cmp expect actual | |
120 | ' | |
121 | ||
2db1a43f VM |
122 | test_expect_success 'create objects for missing-HAVE tests' ' |
123 | blob=$(echo "missing have" | git hash-object -w --stdin) && | |
124 | tree=$(printf "100644 blob $blob\tfile\n" | git mktree) && | |
125 | parent=$(echo parent | git commit-tree $tree) && | |
126 | commit=$(echo commit | git commit-tree $tree -p $parent) && | |
127 | cat >revs <<-EOF | |
128 | HEAD | |
129 | ^HEAD^ | |
130 | ^$commit | |
131 | EOF | |
132 | ' | |
133 | ||
134 | test_expect_success 'pack with missing blob' ' | |
135 | rm $(objpath $blob) && | |
136 | git pack-objects --stdout --revs <revs >/dev/null | |
137 | ' | |
138 | ||
139 | test_expect_success 'pack with missing tree' ' | |
140 | rm $(objpath $tree) && | |
141 | git pack-objects --stdout --revs <revs >/dev/null | |
142 | ' | |
143 | ||
144 | test_expect_success 'pack with missing parent' ' | |
145 | rm $(objpath $parent) && | |
146 | git pack-objects --stdout --revs <revs >/dev/null | |
147 | ' | |
148 | ||
212f2ffb JK |
149 | test_lazy_prereq JGIT ' |
150 | type jgit | |
151 | ' | |
152 | ||
153 | test_expect_success JGIT 'we can read jgit bitmaps' ' | |
154 | git clone . compat-jgit && | |
155 | ( | |
156 | cd compat-jgit && | |
157 | rm -f .git/objects/pack/*.bitmap && | |
158 | jgit gc && | |
159 | git rev-list --test-bitmap HEAD | |
160 | ) | |
161 | ' | |
162 | ||
163 | test_expect_success JGIT 'jgit can read our bitmaps' ' | |
164 | git clone . compat-us && | |
165 | ( | |
166 | cd compat-us && | |
167 | git repack -adb && | |
168 | # jgit gc will barf if it does not like our bitmaps | |
169 | jgit gc | |
170 | ) | |
171 | ' | |
172 | ||
21134714 JK |
173 | test_expect_success 'splitting packs does not generate bogus bitmaps' ' |
174 | test-genrandom foo $((1024 * 1024)) >rand && | |
175 | git add rand && | |
176 | git commit -m "commit with big file" && | |
177 | git -c pack.packSizeLimit=500k repack -adb && | |
178 | git init --bare no-bitmaps.git && | |
179 | git -C no-bitmaps.git fetch .. HEAD | |
180 | ' | |
181 | ||
212f2ffb | 182 | test_done |