commit-graph: check consistency of fanout table
[git.git] / t / t5324-split-commit-graph.sh
blob55b5765e2d4bf40d43ba97c9e40adffcee036098
1 #!/bin/sh
3 test_description='split commit graph'
4 . ./test-lib.sh
6 GIT_TEST_COMMIT_GRAPH=0
7 GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=0
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
19 base sha1:1408
20 base sha256:1528
22 oid_version sha1:1
23 oid_version sha256:2
24 EOM
27 graph_read_expect() {
28 NUM_BASE=0
29 if test ! -z $2
30 then
31 NUM_BASE=$2
33 OPTIONS=
34 if test -z "$3"
35 then
36 OPTIONS=" read_generation_data"
38 cat >expect <<- EOF
39 header: 43475048 1 $(test_oid oid_version) 4 $NUM_BASE
40 num_commits: $1
41 chunks: oid_fanout oid_lookup commit_metadata generation_data
42 options:$OPTIONS
43 EOF
44 test-tool read-graph >output &&
45 test_cmp expect output
48 test_expect_success POSIXPERM 'tweak umask for modebit tests' '
49 umask 022
52 test_expect_success 'create commits and write commit-graph' '
53 for i in $(test_seq 3)
55 test_commit $i &&
56 git branch commits/$i || return 1
57 done &&
58 git commit-graph write --reachable &&
59 test_path_is_file $infodir/commit-graph &&
60 graph_read_expect 3
63 graph_git_two_modes() {
64 git ${2:+ -C "$2"} -c core.commitGraph=true $1 >output &&
65 git ${2:+ -C "$2"} -c core.commitGraph=false $1 >expect &&
66 test_cmp expect output
69 graph_git_behavior() {
70 MSG=$1
71 BRANCH=$2
72 COMPARE=$3
73 DIR=$4
74 test_expect_success "check normal git operations: $MSG" '
75 graph_git_two_modes "log --oneline $BRANCH" "$DIR" &&
76 graph_git_two_modes "log --topo-order $BRANCH" "$DIR" &&
77 graph_git_two_modes "log --graph $COMPARE..$BRANCH" "$DIR" &&
78 graph_git_two_modes "branch -vv" "$DIR" &&
79 graph_git_two_modes "merge-base -a $BRANCH $COMPARE" "$DIR"
83 graph_git_behavior 'graph exists' commits/3 commits/1
85 verify_chain_files_exist() {
86 for hash in $(cat $1/commit-graph-chain)
88 test_path_is_file $1/graph-$hash.graph || return 1
89 done
92 test_expect_success 'add more commits, and write a new base graph' '
93 git reset --hard commits/1 &&
94 for i in $(test_seq 4 5)
96 test_commit $i &&
97 git branch commits/$i || return 1
98 done &&
99 git reset --hard commits/2 &&
100 for i in $(test_seq 6 10)
102 test_commit $i &&
103 git branch commits/$i || return 1
104 done &&
105 git reset --hard commits/2 &&
106 git merge commits/4 &&
107 git branch merge/1 &&
108 git reset --hard commits/4 &&
109 git merge commits/6 &&
110 git branch merge/2 &&
111 git commit-graph write --reachable &&
112 graph_read_expect 12
115 test_expect_success 'fork and fail to base a chain on a commit-graph file' '
116 test_when_finished rm -rf fork &&
117 git clone . fork &&
119 cd fork &&
120 rm .git/objects/info/commit-graph &&
121 echo "$(pwd)/../.git/objects" >.git/objects/info/alternates &&
122 test_commit new-commit &&
123 git commit-graph write --reachable --split &&
124 test_path_is_file $graphdir/commit-graph-chain &&
125 test_line_count = 1 $graphdir/commit-graph-chain &&
126 verify_chain_files_exist $graphdir
130 test_expect_success 'add three more commits, write a tip graph' '
131 git reset --hard commits/3 &&
132 git merge merge/1 &&
133 git merge commits/5 &&
134 git merge merge/2 &&
135 git branch merge/3 &&
136 git commit-graph write --reachable --split &&
137 test_path_is_missing $infodir/commit-graph &&
138 test_path_is_file $graphdir/commit-graph-chain &&
139 ls $graphdir/graph-*.graph >graph-files &&
140 test_line_count = 2 graph-files &&
141 verify_chain_files_exist $graphdir
144 graph_git_behavior 'split commit-graph: merge 3 vs 2' merge/3 merge/2
146 test_expect_success 'add one commit, write a tip graph' '
147 test_commit 11 &&
148 git branch commits/11 &&
149 git commit-graph write --reachable --split &&
150 test_path_is_missing $infodir/commit-graph &&
151 test_path_is_file $graphdir/commit-graph-chain &&
152 ls $graphdir/graph-*.graph >graph-files &&
153 test_line_count = 3 graph-files &&
154 verify_chain_files_exist $graphdir
157 graph_git_behavior 'three-layer commit-graph: commit 11 vs 6' commits/11 commits/6
159 test_expect_success 'add one commit, write a merged graph' '
160 test_commit 12 &&
161 git branch commits/12 &&
162 git commit-graph write --reachable --split &&
163 test_path_is_file $graphdir/commit-graph-chain &&
164 test_line_count = 2 $graphdir/commit-graph-chain &&
165 ls $graphdir/graph-*.graph >graph-files &&
166 test_line_count = 2 graph-files &&
167 verify_chain_files_exist $graphdir
170 graph_git_behavior 'merged commit-graph: commit 12 vs 6' commits/12 commits/6
172 test_expect_success 'create fork and chain across alternate' '
173 git clone . fork &&
175 cd fork &&
176 git config core.commitGraph true &&
177 rm -rf $graphdir &&
178 echo "$(pwd)/../.git/objects" >.git/objects/info/alternates &&
179 test_commit 13 &&
180 git branch commits/13 &&
181 git commit-graph write --reachable --split &&
182 test_path_is_file $graphdir/commit-graph-chain &&
183 test_line_count = 3 $graphdir/commit-graph-chain &&
184 ls $graphdir/graph-*.graph >graph-files &&
185 test_line_count = 1 graph-files &&
186 git -c core.commitGraph=true rev-list HEAD >expect &&
187 git -c core.commitGraph=false rev-list HEAD >actual &&
188 test_cmp expect actual &&
189 test_commit 14 &&
190 git commit-graph write --reachable --split --object-dir=.git/objects/ &&
191 test_line_count = 3 $graphdir/commit-graph-chain &&
192 ls $graphdir/graph-*.graph >graph-files &&
193 test_line_count = 1 graph-files
197 if test -d fork
198 then
199 graph_git_behavior 'alternate: commit 13 vs 6' commits/13 origin/commits/6 "fork"
202 test_expect_success 'test merge stragety constants' '
203 git clone . merge-2 &&
205 cd merge-2 &&
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=2 &&
210 test_line_count = 3 $graphdir/commit-graph-chain
212 ) &&
213 git clone . merge-10 &&
215 cd merge-10 &&
216 git config core.commitGraph true &&
217 test_line_count = 2 $graphdir/commit-graph-chain &&
218 test_commit 14 &&
219 git commit-graph write --reachable --split --size-multiple=10 &&
220 test_line_count = 1 $graphdir/commit-graph-chain &&
221 ls $graphdir/graph-*.graph >graph-files &&
222 test_line_count = 1 graph-files
223 ) &&
224 git clone . merge-10-expire &&
226 cd merge-10-expire &&
227 git config core.commitGraph true &&
228 test_line_count = 2 $graphdir/commit-graph-chain &&
229 test_commit 15 &&
230 touch $graphdir/to-delete.graph $graphdir/to-keep.graph &&
231 test-tool chmtime =1546362000 $graphdir/to-delete.graph &&
232 test-tool chmtime =1546362001 $graphdir/to-keep.graph &&
233 git commit-graph write --reachable --split --size-multiple=10 \
234 --expire-time="2019-01-01 12:00 -05:00" &&
235 test_line_count = 1 $graphdir/commit-graph-chain &&
236 test_path_is_missing $graphdir/to-delete.graph &&
237 test_path_is_file $graphdir/to-keep.graph &&
238 ls $graphdir/graph-*.graph >graph-files &&
239 test_line_count = 3 graph-files
240 ) &&
241 git clone --no-hardlinks . max-commits &&
243 cd max-commits &&
244 git config core.commitGraph true &&
245 test_line_count = 2 $graphdir/commit-graph-chain &&
246 test_commit 16 &&
247 test_commit 17 &&
248 git commit-graph write --reachable --split --max-commits=1 &&
249 test_line_count = 1 $graphdir/commit-graph-chain &&
250 ls $graphdir/graph-*.graph >graph-files &&
251 test_line_count = 1 graph-files
255 test_expect_success 'remove commit-graph-chain file after flattening' '
256 git clone . flatten &&
258 cd flatten &&
259 test_line_count = 2 $graphdir/commit-graph-chain &&
260 git commit-graph write --reachable &&
261 test_path_is_missing $graphdir/commit-graph-chain &&
262 ls $graphdir >graph-files &&
263 test_line_count = 0 graph-files
267 corrupt_file() {
268 file=$1
269 pos=$2
270 data="${3:-\0}"
271 chmod a+w "$file" &&
272 printf "$data" | dd of="$file" bs=1 seek="$pos" conv=notrunc
275 test_expect_success 'verify hashes along chain, even in shallow' '
276 git clone --no-hardlinks . verify &&
278 cd verify &&
279 git commit-graph verify &&
280 base_file=$graphdir/graph-$(head -n 1 $graphdir/commit-graph-chain).graph &&
281 corrupt_file "$base_file" $(test_oid shallow) "\01" &&
282 test_must_fail git commit-graph verify --shallow 2>test_err &&
283 grep -v "^+" test_err >err &&
284 test_i18ngrep "incorrect checksum" err
288 test_expect_success 'verify notices chain slice which is bogus (base)' '
289 git clone --no-hardlinks . verify-chain-bogus-base &&
291 cd verify-chain-bogus-base &&
292 git commit-graph verify &&
293 base_file=$graphdir/graph-$(sed -n 1p $graphdir/commit-graph-chain).graph &&
294 echo "garbage" >$base_file &&
295 test_must_fail git commit-graph verify 2>test_err &&
296 grep -v "^+" test_err >err &&
297 grep "commit-graph file is too small" err
301 test_expect_success 'verify notices chain slice which is bogus (tip)' '
302 git clone --no-hardlinks . verify-chain-bogus-tip &&
304 cd verify-chain-bogus-tip &&
305 git commit-graph verify &&
306 tip_file=$graphdir/graph-$(sed -n 2p $graphdir/commit-graph-chain).graph &&
307 echo "garbage" >$tip_file &&
308 test_must_fail git commit-graph verify 2>test_err &&
309 grep -v "^+" test_err >err &&
310 grep "commit-graph file is too small" err
314 test_expect_success 'verify --shallow does not check base contents' '
315 git clone --no-hardlinks . verify-shallow &&
317 cd verify-shallow &&
318 git commit-graph verify &&
319 base_file=$graphdir/graph-$(head -n 1 $graphdir/commit-graph-chain).graph &&
320 corrupt_file "$base_file" 1500 "\01" &&
321 git commit-graph verify --shallow &&
322 test_must_fail git commit-graph verify 2>test_err &&
323 grep -v "^+" test_err >err &&
324 test_i18ngrep "incorrect checksum" err
328 test_expect_success 'warn on base graph chunk incorrect' '
329 git clone --no-hardlinks . base-chunk &&
331 cd base-chunk &&
332 git commit-graph verify &&
333 base_file=$graphdir/graph-$(tail -n 1 $graphdir/commit-graph-chain).graph &&
334 corrupt_file "$base_file" $(test_oid base) "\01" &&
335 test_must_fail git commit-graph verify --shallow 2>test_err &&
336 grep -v "^+" test_err >err &&
337 test_i18ngrep "commit-graph chain does not match" err
341 test_expect_success 'verify after commit-graph-chain corruption (base)' '
342 git clone --no-hardlinks . verify-chain-base &&
344 cd verify-chain-base &&
345 corrupt_file "$graphdir/commit-graph-chain" 30 "G" &&
346 test_must_fail git commit-graph verify 2>test_err &&
347 grep -v "^+" test_err >err &&
348 test_i18ngrep "invalid commit-graph chain" err &&
349 corrupt_file "$graphdir/commit-graph-chain" 30 "A" &&
350 test_must_fail git commit-graph verify 2>test_err &&
351 grep -v "^+" test_err >err &&
352 test_i18ngrep "unable to find all commit-graph files" err
356 test_expect_success 'verify after commit-graph-chain corruption (tip)' '
357 git clone --no-hardlinks . verify-chain-tip &&
359 cd verify-chain-tip &&
360 corrupt_file "$graphdir/commit-graph-chain" 70 "G" &&
361 test_must_fail git commit-graph verify 2>test_err &&
362 grep -v "^+" test_err >err &&
363 test_i18ngrep "invalid commit-graph chain" err &&
364 corrupt_file "$graphdir/commit-graph-chain" 70 "A" &&
365 test_must_fail git commit-graph verify 2>test_err &&
366 grep -v "^+" test_err >err &&
367 test_i18ngrep "unable to find all commit-graph files" err
371 test_expect_success 'verify notices too-short chain file' '
372 git clone --no-hardlinks . verify-chain-short &&
374 cd verify-chain-short &&
375 git commit-graph verify &&
376 echo "garbage" >$graphdir/commit-graph-chain &&
377 test_must_fail git commit-graph verify 2>test_err &&
378 grep -v "^+" test_err >err &&
379 grep "commit-graph chain file too small" err
383 test_expect_success 'verify across alternates' '
384 git clone --no-hardlinks . verify-alt &&
386 cd verify-alt &&
387 rm -rf $graphdir &&
388 altdir="$(pwd)/../.git/objects" &&
389 echo "$altdir" >.git/objects/info/alternates &&
390 git commit-graph verify --object-dir="$altdir/" &&
391 test_commit extra &&
392 git commit-graph write --reachable --split &&
393 tip_file=$graphdir/graph-$(tail -n 1 $graphdir/commit-graph-chain).graph &&
394 corrupt_file "$tip_file" 1500 "\01" &&
395 test_must_fail git commit-graph verify --shallow 2>test_err &&
396 grep -v "^+" test_err >err &&
397 test_i18ngrep "incorrect checksum" err
401 test_expect_success 'add octopus merge' '
402 git reset --hard commits/10 &&
403 git merge commits/3 commits/4 &&
404 git branch merge/octopus &&
405 git commit-graph write --reachable --split &&
406 git commit-graph verify --progress 2>err &&
407 test_line_count = 1 err &&
408 grep "Verifying commits in commit graph: 100% (18/18)" err &&
409 test_i18ngrep ! warning err &&
410 test_line_count = 3 $graphdir/commit-graph-chain
413 graph_git_behavior 'graph exists' merge/octopus commits/12
415 test_expect_success 'split across alternate where alternate is not split' '
416 git commit-graph write --reachable &&
417 test_path_is_file .git/objects/info/commit-graph &&
418 cp .git/objects/info/commit-graph . &&
419 git clone --no-hardlinks . alt-split &&
421 cd alt-split &&
422 rm -f .git/objects/info/commit-graph &&
423 echo "$(pwd)"/../.git/objects >.git/objects/info/alternates &&
424 test_commit 18 &&
425 git commit-graph write --reachable --split &&
426 test_line_count = 1 $graphdir/commit-graph-chain
427 ) &&
428 test_cmp commit-graph .git/objects/info/commit-graph
431 test_expect_success '--split=no-merge always writes an incremental' '
432 test_when_finished rm -rf a b &&
433 rm -rf $graphdir $infodir/commit-graph &&
434 git reset --hard commits/2 &&
435 git rev-list HEAD~1 >a &&
436 git rev-list HEAD >b &&
437 git commit-graph write --split --stdin-commits <a &&
438 git commit-graph write --split=no-merge --stdin-commits <b &&
439 test_line_count = 2 $graphdir/commit-graph-chain
442 test_expect_success '--split=replace replaces the chain' '
443 rm -rf $graphdir $infodir/commit-graph &&
444 git reset --hard commits/3 &&
445 git rev-list -1 HEAD~2 >a &&
446 git rev-list -1 HEAD~1 >b &&
447 git rev-list -1 HEAD >c &&
448 git commit-graph write --split=no-merge --stdin-commits <a &&
449 git commit-graph write --split=no-merge --stdin-commits <b &&
450 git commit-graph write --split=no-merge --stdin-commits <c &&
451 test_line_count = 3 $graphdir/commit-graph-chain &&
452 git commit-graph write --stdin-commits --split=replace <b &&
453 test_path_is_missing $infodir/commit-graph &&
454 test_path_is_file $graphdir/commit-graph-chain &&
455 ls $graphdir/graph-*.graph >graph-files &&
456 test_line_count = 1 graph-files &&
457 verify_chain_files_exist $graphdir &&
458 graph_read_expect 2
461 test_expect_success ULIMIT_FILE_DESCRIPTORS 'handles file descriptor exhaustion' '
462 git init ulimit &&
464 cd ulimit &&
465 for i in $(test_seq 64)
467 test_commit $i &&
468 run_with_limited_open_files test_might_fail git commit-graph write \
469 --split=no-merge --reachable || return 1
470 done
474 while read mode modebits
476 test_expect_success POSIXPERM "split commit-graph respects core.sharedrepository $mode" '
477 rm -rf $graphdir $infodir/commit-graph &&
478 git reset --hard commits/1 &&
479 test_config core.sharedrepository "$mode" &&
480 git commit-graph write --split --reachable &&
481 ls $graphdir/graph-*.graph >graph-files &&
482 test_line_count = 1 graph-files &&
483 echo "$modebits" >expect &&
484 test_modebits $graphdir/graph-*.graph >actual &&
485 test_cmp expect actual &&
486 test_modebits $graphdir/commit-graph-chain >actual &&
487 test_cmp expect actual
489 done <<\EOF
490 0666 -r--r--r--
491 0600 -r--------
494 test_expect_success '--split=replace with partial Bloom data' '
495 rm -rf $graphdir $infodir/commit-graph &&
496 git reset --hard commits/3 &&
497 git rev-list -1 HEAD~2 >a &&
498 git rev-list -1 HEAD~1 >b &&
499 git commit-graph write --split=no-merge --stdin-commits --changed-paths <a &&
500 git commit-graph write --split=no-merge --stdin-commits <b &&
501 git commit-graph write --split=replace --stdin-commits --changed-paths <c &&
502 ls $graphdir/graph-*.graph >graph-files &&
503 test_line_count = 1 graph-files &&
504 verify_chain_files_exist $graphdir
507 test_expect_success 'prevent regression for duplicate commits across layers' '
508 git init dup &&
509 git -C dup commit --allow-empty -m one &&
510 git -C dup -c core.commitGraph=false commit-graph write --split=no-merge --reachable 2>err &&
511 test_i18ngrep "attempting to write a commit-graph" err &&
512 git -C dup commit-graph write --split=no-merge --reachable &&
513 git -C dup commit --allow-empty -m two &&
514 git -C dup commit-graph write --split=no-merge --reachable &&
515 git -C dup commit --allow-empty -m three &&
516 git -C dup commit-graph write --split --reachable &&
517 git -C dup commit-graph verify
520 NUM_FIRST_LAYER_COMMITS=64
521 NUM_SECOND_LAYER_COMMITS=16
522 NUM_THIRD_LAYER_COMMITS=7
523 NUM_FOURTH_LAYER_COMMITS=8
524 NUM_FIFTH_LAYER_COMMITS=16
525 SECOND_LAYER_SEQUENCE_START=$(($NUM_FIRST_LAYER_COMMITS + 1))
526 SECOND_LAYER_SEQUENCE_END=$(($SECOND_LAYER_SEQUENCE_START + $NUM_SECOND_LAYER_COMMITS - 1))
527 THIRD_LAYER_SEQUENCE_START=$(($SECOND_LAYER_SEQUENCE_END + 1))
528 THIRD_LAYER_SEQUENCE_END=$(($THIRD_LAYER_SEQUENCE_START + $NUM_THIRD_LAYER_COMMITS - 1))
529 FOURTH_LAYER_SEQUENCE_START=$(($THIRD_LAYER_SEQUENCE_END + 1))
530 FOURTH_LAYER_SEQUENCE_END=$(($FOURTH_LAYER_SEQUENCE_START + $NUM_FOURTH_LAYER_COMMITS - 1))
531 FIFTH_LAYER_SEQUENCE_START=$(($FOURTH_LAYER_SEQUENCE_END + 1))
532 FIFTH_LAYER_SEQUENCE_END=$(($FIFTH_LAYER_SEQUENCE_START + $NUM_FIFTH_LAYER_COMMITS - 1))
534 # Current split graph chain:
536 # 16 commits (No GDAT)
537 # ------------------------
538 # 64 commits (GDAT)
540 test_expect_success 'setup repo for mixed generation commit-graph-chain' '
541 graphdir=".git/objects/info/commit-graphs" &&
542 test_oid_cache <<-EOF &&
543 oid_version sha1:1
544 oid_version sha256:2
546 git init mixed &&
548 cd mixed &&
549 git config core.commitGraph true &&
550 git config gc.writeCommitGraph false &&
551 for i in $(test_seq $NUM_FIRST_LAYER_COMMITS)
553 test_commit $i &&
554 git branch commits/$i || return 1
555 done &&
556 git -c commitGraph.generationVersion=2 commit-graph write --reachable --split &&
557 graph_read_expect $NUM_FIRST_LAYER_COMMITS &&
558 test_line_count = 1 $graphdir/commit-graph-chain &&
559 for i in $(test_seq $SECOND_LAYER_SEQUENCE_START $SECOND_LAYER_SEQUENCE_END)
561 test_commit $i &&
562 git branch commits/$i || return 1
563 done &&
564 git -c commitGraph.generationVersion=1 commit-graph write --reachable --split=no-merge &&
565 test_line_count = 2 $graphdir/commit-graph-chain &&
566 test-tool read-graph >output &&
567 cat >expect <<-EOF &&
568 header: 43475048 1 $(test_oid oid_version) 4 1
569 num_commits: $NUM_SECOND_LAYER_COMMITS
570 chunks: oid_fanout oid_lookup commit_metadata
571 options:
573 test_cmp expect output &&
574 git commit-graph verify &&
575 cat $graphdir/commit-graph-chain
579 # The new layer will be added without generation data chunk as it was not
580 # present on the layer underneath it.
582 # 7 commits (No GDAT)
583 # ------------------------
584 # 16 commits (No GDAT)
585 # ------------------------
586 # 64 commits (GDAT)
588 test_expect_success 'do not write generation data chunk if not present on existing tip' '
589 git clone mixed mixed-no-gdat &&
591 cd mixed-no-gdat &&
592 for i in $(test_seq $THIRD_LAYER_SEQUENCE_START $THIRD_LAYER_SEQUENCE_END)
594 test_commit $i &&
595 git branch commits/$i || return 1
596 done &&
597 git commit-graph write --reachable --split=no-merge &&
598 test_line_count = 3 $graphdir/commit-graph-chain &&
599 test-tool read-graph >output &&
600 cat >expect <<-EOF &&
601 header: 43475048 1 $(test_oid oid_version) 4 2
602 num_commits: $NUM_THIRD_LAYER_COMMITS
603 chunks: oid_fanout oid_lookup commit_metadata
604 options:
606 test_cmp expect output &&
607 git commit-graph verify
611 # Number of commits in each layer of the split-commit graph before merge:
613 # 8 commits (No GDAT)
614 # ------------------------
615 # 7 commits (No GDAT)
616 # ------------------------
617 # 16 commits (No GDAT)
618 # ------------------------
619 # 64 commits (GDAT)
621 # The top two layers are merged and do not have generation data chunk as layer below them does
622 # not have generation data chunk.
624 # 15 commits (No GDAT)
625 # ------------------------
626 # 16 commits (No GDAT)
627 # ------------------------
628 # 64 commits (GDAT)
630 test_expect_success 'do not write generation data chunk if the topmost remaining layer does not have generation data chunk' '
631 git clone mixed-no-gdat mixed-merge-no-gdat &&
633 cd mixed-merge-no-gdat &&
634 for i in $(test_seq $FOURTH_LAYER_SEQUENCE_START $FOURTH_LAYER_SEQUENCE_END)
636 test_commit $i &&
637 git branch commits/$i || return 1
638 done &&
639 git commit-graph write --reachable --split --size-multiple 1 &&
640 test_line_count = 3 $graphdir/commit-graph-chain &&
641 test-tool read-graph >output &&
642 cat >expect <<-EOF &&
643 header: 43475048 1 $(test_oid oid_version) 4 2
644 num_commits: $(($NUM_THIRD_LAYER_COMMITS + $NUM_FOURTH_LAYER_COMMITS))
645 chunks: oid_fanout oid_lookup commit_metadata
646 options:
648 test_cmp expect output &&
649 git commit-graph verify
653 # Number of commits in each layer of the split-commit graph before merge:
655 # 16 commits (No GDAT)
656 # ------------------------
657 # 15 commits (No GDAT)
658 # ------------------------
659 # 16 commits (No GDAT)
660 # ------------------------
661 # 64 commits (GDAT)
663 # The top three layers are merged and has generation data chunk as the topmost remaining layer
664 # has generation data chunk.
666 # 47 commits (GDAT)
667 # ------------------------
668 # 64 commits (GDAT)
670 test_expect_success 'write generation data chunk if topmost remaining layer has generation data chunk' '
671 git clone mixed-merge-no-gdat mixed-merge-gdat &&
673 cd mixed-merge-gdat &&
674 for i in $(test_seq $FIFTH_LAYER_SEQUENCE_START $FIFTH_LAYER_SEQUENCE_END)
676 test_commit $i &&
677 git branch commits/$i || return 1
678 done &&
679 git commit-graph write --reachable --split --size-multiple 1 &&
680 test_line_count = 2 $graphdir/commit-graph-chain &&
681 test-tool read-graph >output &&
682 cat >expect <<-EOF &&
683 header: 43475048 1 $(test_oid oid_version) 5 1
684 num_commits: $(($NUM_SECOND_LAYER_COMMITS + $NUM_THIRD_LAYER_COMMITS + $NUM_FOURTH_LAYER_COMMITS + $NUM_FIFTH_LAYER_COMMITS))
685 chunks: oid_fanout oid_lookup commit_metadata generation_data
686 options: read_generation_data
688 test_cmp expect output
692 test_expect_success 'write generation data chunk when commit-graph chain is replaced' '
693 git clone mixed mixed-replace &&
695 cd mixed-replace &&
696 git commit-graph write --reachable --split=replace &&
697 test_path_is_file $graphdir/commit-graph-chain &&
698 test_line_count = 1 $graphdir/commit-graph-chain &&
699 verify_chain_files_exist $graphdir &&
700 graph_read_expect $(($NUM_FIRST_LAYER_COMMITS + $NUM_SECOND_LAYER_COMMITS)) &&
701 git commit-graph verify
705 test_done