3 test_description
='reftable write options'
5 GIT_TEST_DEFAULT_REF_FORMAT
=reftable
6 export GIT_TEST_DEFAULT_REF_FORMAT
7 # Disable auto-compaction for all tests as we explicitly control repacking of
9 GIT_TEST_REFTABLE_AUTOCOMPACTION
=false
10 export GIT_TEST_REFTABLE_AUTOCOMPACTION
11 # Block sizes depend on the hash function, so we force SHA1 here.
12 GIT_TEST_DEFAULT_HASH
=sha1
13 export GIT_TEST_DEFAULT_HASH
14 # Block sizes also depend on the actual refs we write, so we force "master" to
15 # be the default initial branch name.
16 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=master
17 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
19 TEST_PASSES_SANITIZE_LEAK
=true
22 test_expect_success
'default write options' '
23 test_when_finished "rm -rf repo" &&
27 test_commit initial &&
39 test-tool dump-reftable -b .git/reftable/*.ref >actual &&
40 test_cmp expect actual
44 test_expect_success
'disabled reflog writes no log blocks' '
45 test_config_global core.logAllRefUpdates false &&
46 test_when_finished "rm -rf repo" &&
50 test_commit initial &&
59 test-tool dump-reftable -b .git/reftable/*.ref >actual &&
60 test_cmp expect actual
64 test_expect_success
'many refs results in multiple blocks' '
65 test_when_finished "rm -rf repo" &&
69 test_commit initial &&
70 for i in $(test_seq 200)
72 printf "update refs/heads/branch-%d HEAD\n" "$i" ||
75 git update-ref --stdin <input &&
98 test-tool dump-reftable -b .git/reftable/*.ref >actual &&
99 test_cmp expect actual
103 test_expect_success
'tiny block size leads to error' '
104 test_when_finished "rm -rf repo" &&
108 test_commit initial &&
109 cat >expect <<-EOF &&
110 error: unable to compact stack: entry too large
112 test_must_fail git -c reftable.blockSize=50 pack-refs 2>err &&
117 test_expect_success
'small block size leads to multiple ref blocks' '
118 test_config_global core.logAllRefUpdates false &&
119 test_when_finished "rm -rf repo" &&
125 git -c reftable.blockSize=100 pack-refs &&
127 cat >expect <<-EOF &&
138 test-tool dump-reftable -b .git/reftable/*.ref >actual &&
139 test_cmp expect actual
143 test_expect_success
'small block size fails with large reflog message' '
144 test_when_finished "rm -rf repo" &&
149 perl -e "print \"a\" x 500" >logmsg &&
150 cat >expect <<-EOF &&
151 fatal: update_ref failed for ref ${SQ}refs/heads/logme${SQ}: reftable: transaction failure: entry too large
153 test_must_fail git -c reftable.blockSize=100 \
154 update-ref -m "$(cat logmsg)" refs/heads/logme HEAD 2>err &&
159 test_expect_success
'block size exceeding maximum supported size' '
160 test_config_global core.logAllRefUpdates false &&
161 test_when_finished "rm -rf repo" &&
167 cat >expect <<-EOF &&
168 fatal: reftable block size cannot exceed 16MB
170 test_must_fail git -c reftable.blockSize=16777216 pack-refs 2>err &&
175 test_expect_success
'restart interval at every single record' '
176 test_when_finished "rm -rf repo" &&
180 test_commit initial &&
181 for i in $(test_seq 10)
183 printf "update refs/heads/branch-%d HEAD\n" "$i" ||
186 git update-ref --stdin <input &&
187 git -c reftable.restartInterval=1 pack-refs &&
189 cat >expect <<-EOF &&
199 test-tool dump-reftable -b .git/reftable/*.ref >actual &&
200 test_cmp expect actual
204 test_expect_success
'restart interval exceeding maximum supported interval' '
205 test_when_finished "rm -rf repo" &&
209 test_commit initial &&
210 cat >expect <<-EOF &&
211 fatal: reftable block size cannot exceed 65535
213 test_must_fail git -c reftable.restartInterval=65536 pack-refs 2>err &&
218 test_expect_success
'object index gets written by default with ref index' '
219 test_config_global core.logAllRefUpdates false &&
220 test_when_finished "rm -rf repo" &&
224 test_commit initial &&
225 for i in $(test_seq 5)
227 printf "update refs/heads/branch-%d HEAD\n" "$i" ||
230 git update-ref --stdin <input &&
231 git -c reftable.blockSize=100 pack-refs &&
233 cat >expect <<-EOF &&
249 test-tool dump-reftable -b .git/reftable/*.ref >actual &&
250 test_cmp expect actual
254 test_expect_success
'object index can be disabled' '
255 test_config_global core.logAllRefUpdates false &&
256 test_when_finished "rm -rf repo" &&
260 test_commit initial &&
261 for i in $(test_seq 5)
263 printf "update refs/heads/branch-%d HEAD\n" "$i" ||
266 git update-ref --stdin <input &&
267 git -c reftable.blockSize=100 -c reftable.indexObjects=false pack-refs &&
269 cat >expect <<-EOF &&
282 test-tool dump-reftable -b .git/reftable/*.ref >actual &&
283 test_cmp expect actual