]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5324-split-commit-graph.sh
Merge branch 'jx/t5411-unique-filenames'
[thirdparty/git.git] / t / t5324-split-commit-graph.sh
1 #!/bin/sh
2
3 test_description='split commit graph'
4 . ./test-lib.sh
5
6 GIT_TEST_COMMIT_GRAPH=0
7 GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=0
8
9 test_expect_success 'setup repo' '
10 git init &&
11 git config core.commitGraph true &&
12 git config gc.writeCommitGraph false &&
13 infodir=".git/objects/info" &&
14 graphdir="$infodir/commit-graphs" &&
15 test_oid_cache <<-EOM
16 shallow sha1:2132
17 shallow sha256:2436
18
19 base sha1:1408
20 base sha256:1528
21
22 oid_version sha1:1
23 oid_version sha256:2
24 EOM
25 '
26
27 graph_read_expect() {
28 NUM_BASE=0
29 if test ! -z $2
30 then
31 NUM_BASE=$2
32 fi
33 cat >expect <<- EOF
34 header: 43475048 1 $(test_oid oid_version) 4 $NUM_BASE
35 num_commits: $1
36 chunks: oid_fanout oid_lookup commit_metadata generation_data
37 EOF
38 test-tool read-graph >output &&
39 test_cmp expect output
40 }
41
42 test_expect_success POSIXPERM 'tweak umask for modebit tests' '
43 umask 022
44 '
45
46 test_expect_success 'create commits and write commit-graph' '
47 for i in $(test_seq 3)
48 do
49 test_commit $i &&
50 git branch commits/$i || return 1
51 done &&
52 git commit-graph write --reachable &&
53 test_path_is_file $infodir/commit-graph &&
54 graph_read_expect 3
55 '
56
57 graph_git_two_modes() {
58 git -c core.commitGraph=true $1 >output
59 git -c core.commitGraph=false $1 >expect
60 test_cmp expect output
61 }
62
63 graph_git_behavior() {
64 MSG=$1
65 BRANCH=$2
66 COMPARE=$3
67 test_expect_success "check normal git operations: $MSG" '
68 graph_git_two_modes "log --oneline $BRANCH" &&
69 graph_git_two_modes "log --topo-order $BRANCH" &&
70 graph_git_two_modes "log --graph $COMPARE..$BRANCH" &&
71 graph_git_two_modes "branch -vv" &&
72 graph_git_two_modes "merge-base -a $BRANCH $COMPARE"
73 '
74 }
75
76 graph_git_behavior 'graph exists' commits/3 commits/1
77
78 verify_chain_files_exist() {
79 for hash in $(cat $1/commit-graph-chain)
80 do
81 test_path_is_file $1/graph-$hash.graph || return 1
82 done
83 }
84
85 test_expect_success 'add more commits, and write a new base graph' '
86 git reset --hard commits/1 &&
87 for i in $(test_seq 4 5)
88 do
89 test_commit $i &&
90 git branch commits/$i || return 1
91 done &&
92 git reset --hard commits/2 &&
93 for i in $(test_seq 6 10)
94 do
95 test_commit $i &&
96 git branch commits/$i || return 1
97 done &&
98 git reset --hard commits/2 &&
99 git merge commits/4 &&
100 git branch merge/1 &&
101 git reset --hard commits/4 &&
102 git merge commits/6 &&
103 git branch merge/2 &&
104 git commit-graph write --reachable &&
105 graph_read_expect 12
106 '
107
108 test_expect_success 'fork and fail to base a chain on a commit-graph file' '
109 test_when_finished rm -rf fork &&
110 git clone . fork &&
111 (
112 cd fork &&
113 rm .git/objects/info/commit-graph &&
114 echo "$(pwd)/../.git/objects" >.git/objects/info/alternates &&
115 test_commit new-commit &&
116 git commit-graph write --reachable --split &&
117 test_path_is_file $graphdir/commit-graph-chain &&
118 test_line_count = 1 $graphdir/commit-graph-chain &&
119 verify_chain_files_exist $graphdir
120 )
121 '
122
123 test_expect_success 'add three more commits, write a tip graph' '
124 git reset --hard commits/3 &&
125 git merge merge/1 &&
126 git merge commits/5 &&
127 git merge merge/2 &&
128 git branch merge/3 &&
129 git commit-graph write --reachable --split &&
130 test_path_is_missing $infodir/commit-graph &&
131 test_path_is_file $graphdir/commit-graph-chain &&
132 ls $graphdir/graph-*.graph >graph-files &&
133 test_line_count = 2 graph-files &&
134 verify_chain_files_exist $graphdir
135 '
136
137 graph_git_behavior 'split commit-graph: merge 3 vs 2' merge/3 merge/2
138
139 test_expect_success 'add one commit, write a tip graph' '
140 test_commit 11 &&
141 git branch commits/11 &&
142 git commit-graph write --reachable --split &&
143 test_path_is_missing $infodir/commit-graph &&
144 test_path_is_file $graphdir/commit-graph-chain &&
145 ls $graphdir/graph-*.graph >graph-files &&
146 test_line_count = 3 graph-files &&
147 verify_chain_files_exist $graphdir
148 '
149
150 graph_git_behavior 'three-layer commit-graph: commit 11 vs 6' commits/11 commits/6
151
152 test_expect_success 'add one commit, write a merged graph' '
153 test_commit 12 &&
154 git branch commits/12 &&
155 git commit-graph write --reachable --split &&
156 test_path_is_file $graphdir/commit-graph-chain &&
157 test_line_count = 2 $graphdir/commit-graph-chain &&
158 ls $graphdir/graph-*.graph >graph-files &&
159 test_line_count = 2 graph-files &&
160 verify_chain_files_exist $graphdir
161 '
162
163 graph_git_behavior 'merged commit-graph: commit 12 vs 6' commits/12 commits/6
164
165 test_expect_success 'create fork and chain across alternate' '
166 git clone . fork &&
167 (
168 cd fork &&
169 git config core.commitGraph true &&
170 rm -rf $graphdir &&
171 echo "$(pwd)/../.git/objects" >.git/objects/info/alternates &&
172 test_commit 13 &&
173 git branch commits/13 &&
174 git commit-graph write --reachable --split &&
175 test_path_is_file $graphdir/commit-graph-chain &&
176 test_line_count = 3 $graphdir/commit-graph-chain &&
177 ls $graphdir/graph-*.graph >graph-files &&
178 test_line_count = 1 graph-files &&
179 git -c core.commitGraph=true rev-list HEAD >expect &&
180 git -c core.commitGraph=false rev-list HEAD >actual &&
181 test_cmp expect actual &&
182 test_commit 14 &&
183 git commit-graph write --reachable --split --object-dir=.git/objects/ &&
184 test_line_count = 3 $graphdir/commit-graph-chain &&
185 ls $graphdir/graph-*.graph >graph-files &&
186 test_line_count = 1 graph-files
187 )
188 '
189
190 graph_git_behavior 'alternate: commit 13 vs 6' commits/13 commits/6
191
192 test_expect_success 'test merge stragety constants' '
193 git clone . merge-2 &&
194 (
195 cd merge-2 &&
196 git config core.commitGraph true &&
197 test_line_count = 2 $graphdir/commit-graph-chain &&
198 test_commit 14 &&
199 git commit-graph write --reachable --split --size-multiple=2 &&
200 test_line_count = 3 $graphdir/commit-graph-chain
201
202 ) &&
203 git clone . merge-10 &&
204 (
205 cd merge-10 &&
206 git config core.commitGraph true &&
207 test_line_count = 2 $graphdir/commit-graph-chain &&
208 test_commit 14 &&
209 git commit-graph write --reachable --split --size-multiple=10 &&
210 test_line_count = 1 $graphdir/commit-graph-chain &&
211 ls $graphdir/graph-*.graph >graph-files &&
212 test_line_count = 1 graph-files
213 ) &&
214 git clone . merge-10-expire &&
215 (
216 cd merge-10-expire &&
217 git config core.commitGraph true &&
218 test_line_count = 2 $graphdir/commit-graph-chain &&
219 test_commit 15 &&
220 touch $graphdir/to-delete.graph $graphdir/to-keep.graph &&
221 test-tool chmtime =1546362000 $graphdir/to-delete.graph &&
222 test-tool chmtime =1546362001 $graphdir/to-keep.graph &&
223 git commit-graph write --reachable --split --size-multiple=10 \
224 --expire-time="2019-01-01 12:00 -05:00" &&
225 test_line_count = 1 $graphdir/commit-graph-chain &&
226 test_path_is_missing $graphdir/to-delete.graph &&
227 test_path_is_file $graphdir/to-keep.graph &&
228 ls $graphdir/graph-*.graph >graph-files &&
229 test_line_count = 3 graph-files
230 ) &&
231 git clone --no-hardlinks . max-commits &&
232 (
233 cd max-commits &&
234 git config core.commitGraph true &&
235 test_line_count = 2 $graphdir/commit-graph-chain &&
236 test_commit 16 &&
237 test_commit 17 &&
238 git commit-graph write --reachable --split --max-commits=1 &&
239 test_line_count = 1 $graphdir/commit-graph-chain &&
240 ls $graphdir/graph-*.graph >graph-files &&
241 test_line_count = 1 graph-files
242 )
243 '
244
245 test_expect_success 'remove commit-graph-chain file after flattening' '
246 git clone . flatten &&
247 (
248 cd flatten &&
249 test_line_count = 2 $graphdir/commit-graph-chain &&
250 git commit-graph write --reachable &&
251 test_path_is_missing $graphdir/commit-graph-chain &&
252 ls $graphdir >graph-files &&
253 test_line_count = 0 graph-files
254 )
255 '
256
257 corrupt_file() {
258 file=$1
259 pos=$2
260 data="${3:-\0}"
261 chmod a+w "$file" &&
262 printf "$data" | dd of="$file" bs=1 seek="$pos" conv=notrunc
263 }
264
265 test_expect_success 'verify hashes along chain, even in shallow' '
266 git clone --no-hardlinks . verify &&
267 (
268 cd verify &&
269 git commit-graph verify &&
270 base_file=$graphdir/graph-$(head -n 1 $graphdir/commit-graph-chain).graph &&
271 corrupt_file "$base_file" $(test_oid shallow) "\01" &&
272 test_must_fail git commit-graph verify --shallow 2>test_err &&
273 grep -v "^+" test_err >err &&
274 test_i18ngrep "incorrect checksum" err
275 )
276 '
277
278 test_expect_success 'verify --shallow does not check base contents' '
279 git clone --no-hardlinks . verify-shallow &&
280 (
281 cd verify-shallow &&
282 git commit-graph verify &&
283 base_file=$graphdir/graph-$(head -n 1 $graphdir/commit-graph-chain).graph &&
284 corrupt_file "$base_file" 1000 "\01" &&
285 git commit-graph verify --shallow &&
286 test_must_fail git commit-graph verify 2>test_err &&
287 grep -v "^+" test_err >err &&
288 test_i18ngrep "incorrect checksum" err
289 )
290 '
291
292 test_expect_success 'warn on base graph chunk incorrect' '
293 git clone --no-hardlinks . base-chunk &&
294 (
295 cd base-chunk &&
296 git commit-graph verify &&
297 base_file=$graphdir/graph-$(tail -n 1 $graphdir/commit-graph-chain).graph &&
298 corrupt_file "$base_file" $(test_oid base) "\01" &&
299 git commit-graph verify --shallow 2>test_err &&
300 grep -v "^+" test_err >err &&
301 test_i18ngrep "commit-graph chain does not match" err
302 )
303 '
304
305 test_expect_success 'verify after commit-graph-chain corruption' '
306 git clone --no-hardlinks . verify-chain &&
307 (
308 cd verify-chain &&
309 corrupt_file "$graphdir/commit-graph-chain" 60 "G" &&
310 git commit-graph verify 2>test_err &&
311 grep -v "^+" test_err >err &&
312 test_i18ngrep "invalid commit-graph chain" err &&
313 corrupt_file "$graphdir/commit-graph-chain" 60 "A" &&
314 git commit-graph verify 2>test_err &&
315 grep -v "^+" test_err >err &&
316 test_i18ngrep "unable to find all commit-graph files" err
317 )
318 '
319
320 test_expect_success 'verify across alternates' '
321 git clone --no-hardlinks . verify-alt &&
322 (
323 cd verify-alt &&
324 rm -rf $graphdir &&
325 altdir="$(pwd)/../.git/objects" &&
326 echo "$altdir" >.git/objects/info/alternates &&
327 git commit-graph verify --object-dir="$altdir/" &&
328 test_commit extra &&
329 git commit-graph write --reachable --split &&
330 tip_file=$graphdir/graph-$(tail -n 1 $graphdir/commit-graph-chain).graph &&
331 corrupt_file "$tip_file" 100 "\01" &&
332 test_must_fail git commit-graph verify --shallow 2>test_err &&
333 grep -v "^+" test_err >err &&
334 test_i18ngrep "commit-graph has incorrect fanout value" err
335 )
336 '
337
338 test_expect_success 'add octopus merge' '
339 git reset --hard commits/10 &&
340 git merge commits/3 commits/4 &&
341 git branch merge/octopus &&
342 git commit-graph write --reachable --split &&
343 git commit-graph verify --progress 2>err &&
344 test_line_count = 3 err &&
345 test_i18ngrep ! warning err &&
346 test_line_count = 3 $graphdir/commit-graph-chain
347 '
348
349 graph_git_behavior 'graph exists' merge/octopus commits/12
350
351 test_expect_success 'split across alternate where alternate is not split' '
352 git commit-graph write --reachable &&
353 test_path_is_file .git/objects/info/commit-graph &&
354 cp .git/objects/info/commit-graph . &&
355 git clone --no-hardlinks . alt-split &&
356 (
357 cd alt-split &&
358 rm -f .git/objects/info/commit-graph &&
359 echo "$(pwd)"/../.git/objects >.git/objects/info/alternates &&
360 test_commit 18 &&
361 git commit-graph write --reachable --split &&
362 test_line_count = 1 $graphdir/commit-graph-chain
363 ) &&
364 test_cmp commit-graph .git/objects/info/commit-graph
365 '
366
367 test_expect_success '--split=no-merge always writes an incremental' '
368 test_when_finished rm -rf a b &&
369 rm -rf $graphdir $infodir/commit-graph &&
370 git reset --hard commits/2 &&
371 git rev-list HEAD~1 >a &&
372 git rev-list HEAD >b &&
373 git commit-graph write --split --stdin-commits <a &&
374 git commit-graph write --split=no-merge --stdin-commits <b &&
375 test_line_count = 2 $graphdir/commit-graph-chain
376 '
377
378 test_expect_success '--split=replace replaces the chain' '
379 rm -rf $graphdir $infodir/commit-graph &&
380 git reset --hard commits/3 &&
381 git rev-list -1 HEAD~2 >a &&
382 git rev-list -1 HEAD~1 >b &&
383 git rev-list -1 HEAD >c &&
384 git commit-graph write --split=no-merge --stdin-commits <a &&
385 git commit-graph write --split=no-merge --stdin-commits <b &&
386 git commit-graph write --split=no-merge --stdin-commits <c &&
387 test_line_count = 3 $graphdir/commit-graph-chain &&
388 git commit-graph write --stdin-commits --split=replace <b &&
389 test_path_is_missing $infodir/commit-graph &&
390 test_path_is_file $graphdir/commit-graph-chain &&
391 ls $graphdir/graph-*.graph >graph-files &&
392 test_line_count = 1 graph-files &&
393 verify_chain_files_exist $graphdir &&
394 graph_read_expect 2
395 '
396
397 test_expect_success ULIMIT_FILE_DESCRIPTORS 'handles file descriptor exhaustion' '
398 git init ulimit &&
399 (
400 cd ulimit &&
401 for i in $(test_seq 64)
402 do
403 test_commit $i &&
404 run_with_limited_open_files test_might_fail git commit-graph write \
405 --split=no-merge --reachable || return 1
406 done
407 )
408 '
409
410 while read mode modebits
411 do
412 test_expect_success POSIXPERM "split commit-graph respects core.sharedrepository $mode" '
413 rm -rf $graphdir $infodir/commit-graph &&
414 git reset --hard commits/1 &&
415 test_config core.sharedrepository "$mode" &&
416 git commit-graph write --split --reachable &&
417 ls $graphdir/graph-*.graph >graph-files &&
418 test_line_count = 1 graph-files &&
419 echo "$modebits" >expect &&
420 test_modebits $graphdir/graph-*.graph >actual &&
421 test_cmp expect actual &&
422 test_modebits $graphdir/commit-graph-chain >actual &&
423 test_cmp expect actual
424 '
425 done <<\EOF
426 0666 -r--r--r--
427 0600 -r--------
428 EOF
429
430 test_expect_success '--split=replace with partial Bloom data' '
431 rm -rf $graphdir $infodir/commit-graph &&
432 git reset --hard commits/3 &&
433 git rev-list -1 HEAD~2 >a &&
434 git rev-list -1 HEAD~1 >b &&
435 git commit-graph write --split=no-merge --stdin-commits --changed-paths <a &&
436 git commit-graph write --split=no-merge --stdin-commits <b &&
437 git commit-graph write --split=replace --stdin-commits --changed-paths <c &&
438 ls $graphdir/graph-*.graph >graph-files &&
439 test_line_count = 1 graph-files &&
440 verify_chain_files_exist $graphdir
441 '
442
443 test_expect_success 'prevent regression for duplicate commits across layers' '
444 git init dup &&
445 git -C dup commit --allow-empty -m one &&
446 git -C dup -c core.commitGraph=false commit-graph write --split=no-merge --reachable 2>err &&
447 test_i18ngrep "attempting to write a commit-graph" err &&
448 git -C dup commit-graph write --split=no-merge --reachable &&
449 git -C dup commit --allow-empty -m two &&
450 git -C dup commit-graph write --split=no-merge --reachable &&
451 git -C dup commit --allow-empty -m three &&
452 git -C dup commit-graph write --split --reachable &&
453 git -C dup commit-graph verify
454 '
455
456 NUM_FIRST_LAYER_COMMITS=64
457 NUM_SECOND_LAYER_COMMITS=16
458 NUM_THIRD_LAYER_COMMITS=7
459 NUM_FOURTH_LAYER_COMMITS=8
460 NUM_FIFTH_LAYER_COMMITS=16
461 SECOND_LAYER_SEQUENCE_START=$(($NUM_FIRST_LAYER_COMMITS + 1))
462 SECOND_LAYER_SEQUENCE_END=$(($SECOND_LAYER_SEQUENCE_START + $NUM_SECOND_LAYER_COMMITS - 1))
463 THIRD_LAYER_SEQUENCE_START=$(($SECOND_LAYER_SEQUENCE_END + 1))
464 THIRD_LAYER_SEQUENCE_END=$(($THIRD_LAYER_SEQUENCE_START + $NUM_THIRD_LAYER_COMMITS - 1))
465 FOURTH_LAYER_SEQUENCE_START=$(($THIRD_LAYER_SEQUENCE_END + 1))
466 FOURTH_LAYER_SEQUENCE_END=$(($FOURTH_LAYER_SEQUENCE_START + $NUM_FOURTH_LAYER_COMMITS - 1))
467 FIFTH_LAYER_SEQUENCE_START=$(($FOURTH_LAYER_SEQUENCE_END + 1))
468 FIFTH_LAYER_SEQUENCE_END=$(($FIFTH_LAYER_SEQUENCE_START + $NUM_FIFTH_LAYER_COMMITS - 1))
469
470 # Current split graph chain:
471 #
472 # 16 commits (No GDAT)
473 # ------------------------
474 # 64 commits (GDAT)
475 #
476 test_expect_success 'setup repo for mixed generation commit-graph-chain' '
477 graphdir=".git/objects/info/commit-graphs" &&
478 test_oid_cache <<-EOF &&
479 oid_version sha1:1
480 oid_version sha256:2
481 EOF
482 git init mixed &&
483 (
484 cd mixed &&
485 git config core.commitGraph true &&
486 git config gc.writeCommitGraph false &&
487 for i in $(test_seq $NUM_FIRST_LAYER_COMMITS)
488 do
489 test_commit $i &&
490 git branch commits/$i || return 1
491 done &&
492 git commit-graph write --reachable --split &&
493 graph_read_expect $NUM_FIRST_LAYER_COMMITS &&
494 test_line_count = 1 $graphdir/commit-graph-chain &&
495 for i in $(test_seq $SECOND_LAYER_SEQUENCE_START $SECOND_LAYER_SEQUENCE_END)
496 do
497 test_commit $i &&
498 git branch commits/$i || return 1
499 done &&
500 GIT_TEST_COMMIT_GRAPH_NO_GDAT=1 git commit-graph write --reachable --split=no-merge &&
501 test_line_count = 2 $graphdir/commit-graph-chain &&
502 test-tool read-graph >output &&
503 cat >expect <<-EOF &&
504 header: 43475048 1 $(test_oid oid_version) 4 1
505 num_commits: $NUM_SECOND_LAYER_COMMITS
506 chunks: oid_fanout oid_lookup commit_metadata
507 EOF
508 test_cmp expect output &&
509 git commit-graph verify &&
510 cat $graphdir/commit-graph-chain
511 )
512 '
513
514 # The new layer will be added without generation data chunk as it was not
515 # present on the layer underneath it.
516 #
517 # 7 commits (No GDAT)
518 # ------------------------
519 # 16 commits (No GDAT)
520 # ------------------------
521 # 64 commits (GDAT)
522 #
523 test_expect_success 'do not write generation data chunk if not present on existing tip' '
524 git clone mixed mixed-no-gdat &&
525 (
526 cd mixed-no-gdat &&
527 for i in $(test_seq $THIRD_LAYER_SEQUENCE_START $THIRD_LAYER_SEQUENCE_END)
528 do
529 test_commit $i &&
530 git branch commits/$i || return 1
531 done &&
532 git commit-graph write --reachable --split=no-merge &&
533 test_line_count = 3 $graphdir/commit-graph-chain &&
534 test-tool read-graph >output &&
535 cat >expect <<-EOF &&
536 header: 43475048 1 $(test_oid oid_version) 4 2
537 num_commits: $NUM_THIRD_LAYER_COMMITS
538 chunks: oid_fanout oid_lookup commit_metadata
539 EOF
540 test_cmp expect output &&
541 git commit-graph verify
542 )
543 '
544
545 # Number of commits in each layer of the split-commit graph before merge:
546 #
547 # 8 commits (No GDAT)
548 # ------------------------
549 # 7 commits (No GDAT)
550 # ------------------------
551 # 16 commits (No GDAT)
552 # ------------------------
553 # 64 commits (GDAT)
554 #
555 # The top two layers are merged and do not have generation data chunk as layer below them does
556 # not have generation data chunk.
557 #
558 # 15 commits (No GDAT)
559 # ------------------------
560 # 16 commits (No GDAT)
561 # ------------------------
562 # 64 commits (GDAT)
563 #
564 test_expect_success 'do not write generation data chunk if the topmost remaining layer does not have generation data chunk' '
565 git clone mixed-no-gdat mixed-merge-no-gdat &&
566 (
567 cd mixed-merge-no-gdat &&
568 for i in $(test_seq $FOURTH_LAYER_SEQUENCE_START $FOURTH_LAYER_SEQUENCE_END)
569 do
570 test_commit $i &&
571 git branch commits/$i || return 1
572 done &&
573 git commit-graph write --reachable --split --size-multiple 1 &&
574 test_line_count = 3 $graphdir/commit-graph-chain &&
575 test-tool read-graph >output &&
576 cat >expect <<-EOF &&
577 header: 43475048 1 $(test_oid oid_version) 4 2
578 num_commits: $(($NUM_THIRD_LAYER_COMMITS + $NUM_FOURTH_LAYER_COMMITS))
579 chunks: oid_fanout oid_lookup commit_metadata
580 EOF
581 test_cmp expect output &&
582 git commit-graph verify
583 )
584 '
585
586 # Number of commits in each layer of the split-commit graph before merge:
587 #
588 # 16 commits (No GDAT)
589 # ------------------------
590 # 15 commits (No GDAT)
591 # ------------------------
592 # 16 commits (No GDAT)
593 # ------------------------
594 # 64 commits (GDAT)
595 #
596 # The top three layers are merged and has generation data chunk as the topmost remaining layer
597 # has generation data chunk.
598 #
599 # 47 commits (GDAT)
600 # ------------------------
601 # 64 commits (GDAT)
602 #
603 test_expect_success 'write generation data chunk if topmost remaining layer has generation data chunk' '
604 git clone mixed-merge-no-gdat mixed-merge-gdat &&
605 (
606 cd mixed-merge-gdat &&
607 for i in $(test_seq $FIFTH_LAYER_SEQUENCE_START $FIFTH_LAYER_SEQUENCE_END)
608 do
609 test_commit $i &&
610 git branch commits/$i || return 1
611 done &&
612 git commit-graph write --reachable --split --size-multiple 1 &&
613 test_line_count = 2 $graphdir/commit-graph-chain &&
614 test-tool read-graph >output &&
615 cat >expect <<-EOF &&
616 header: 43475048 1 $(test_oid oid_version) 5 1
617 num_commits: $(($NUM_SECOND_LAYER_COMMITS + $NUM_THIRD_LAYER_COMMITS + $NUM_FOURTH_LAYER_COMMITS + $NUM_FIFTH_LAYER_COMMITS))
618 chunks: oid_fanout oid_lookup commit_metadata generation_data
619 EOF
620 test_cmp expect output
621 )
622 '
623
624 test_expect_success 'write generation data chunk when commit-graph chain is replaced' '
625 git clone mixed mixed-replace &&
626 (
627 cd mixed-replace &&
628 git commit-graph write --reachable --split=replace &&
629 test_path_is_file $graphdir/commit-graph-chain &&
630 test_line_count = 1 $graphdir/commit-graph-chain &&
631 verify_chain_files_exist $graphdir &&
632 graph_read_expect $(($NUM_FIRST_LAYER_COMMITS + $NUM_SECOND_LAYER_COMMITS)) &&
633 git commit-graph verify
634 )
635 '
636
637 test_done