refs/files: skip creation of "refs/{heads,tags}" for worktrees
[git.git] / t / t5324-split-commit-graph.sh
blob281266f7883b35cbc4dd2c631d645d0d5b430d0c
1 #!/bin/sh
3 test_description='split commit graph'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7 . "$TEST_DIRECTORY"/lib-chunk.sh
9 GIT_TEST_COMMIT_GRAPH=0
10 GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=0
12 test_expect_success 'setup repo' '
13 git init &&
14 git config core.commitGraph true &&
15 git config gc.writeCommitGraph false &&
16 infodir=".git/objects/info" &&
17 graphdir="$infodir/commit-graphs" &&
18 test_oid_cache <<-EOM
19 shallow sha1:2132
20 shallow sha256:2436
22 base sha1:1408
23 base sha256:1528
25 oid_version sha1:1
26 oid_version sha256:2
27 EOM
30 graph_read_expect() {
31 NUM_BASE=0
32 if test ! -z $2
33 then
34 NUM_BASE=$2
36 OPTIONS=
37 if test -z "$3"
38 then
39 OPTIONS=" read_generation_data"
41 cat >expect <<- EOF
42 header: 43475048 1 $(test_oid oid_version) 4 $NUM_BASE
43 num_commits: $1
44 chunks: oid_fanout oid_lookup commit_metadata generation_data
45 options:$OPTIONS
46 EOF
47 test-tool read-graph >output &&
48 test_cmp expect output
51 test_expect_success POSIXPERM 'tweak umask for modebit tests' '
52 umask 022
55 test_expect_success 'create commits and write commit-graph' '
56 for i in $(test_seq 3)
58 test_commit $i &&
59 git branch commits/$i || return 1
60 done &&
61 git commit-graph write --reachable &&
62 test_path_is_file $infodir/commit-graph &&
63 graph_read_expect 3
66 graph_git_two_modes() {
67 git ${2:+ -C "$2"} -c core.commitGraph=true $1 >output &&
68 git ${2:+ -C "$2"} -c core.commitGraph=false $1 >expect &&
69 test_cmp expect output
72 graph_git_behavior() {
73 MSG=$1
74 BRANCH=$2
75 COMPARE=$3
76 DIR=$4
77 test_expect_success "check normal git operations: $MSG" '
78 graph_git_two_modes "log --oneline $BRANCH" "$DIR" &&
79 graph_git_two_modes "log --topo-order $BRANCH" "$DIR" &&
80 graph_git_two_modes "log --graph $COMPARE..$BRANCH" "$DIR" &&
81 graph_git_two_modes "branch -vv" "$DIR" &&
82 graph_git_two_modes "merge-base -a $BRANCH $COMPARE" "$DIR"
86 graph_git_behavior 'graph exists' commits/3 commits/1
88 verify_chain_files_exist() {
89 for hash in $(cat $1/commit-graph-chain)
91 test_path_is_file $1/graph-$hash.graph || return 1
92 done
95 test_expect_success 'add more commits, and write a new base graph' '
96 git reset --hard commits/1 &&
97 for i in $(test_seq 4 5)
99 test_commit $i &&
100 git branch commits/$i || return 1
101 done &&
102 git reset --hard commits/2 &&
103 for i in $(test_seq 6 10)
105 test_commit $i &&
106 git branch commits/$i || return 1
107 done &&
108 git reset --hard commits/2 &&
109 git merge commits/4 &&
110 git branch merge/1 &&
111 git reset --hard commits/4 &&
112 git merge commits/6 &&
113 git branch merge/2 &&
114 git commit-graph write --reachable &&
115 graph_read_expect 12
118 test_expect_success 'fork and fail to base a chain on a commit-graph file' '
119 test_when_finished rm -rf fork &&
120 git clone . fork &&
122 cd fork &&
123 rm .git/objects/info/commit-graph &&
124 echo "$(pwd)/../.git/objects" >.git/objects/info/alternates &&
125 test_commit new-commit &&
126 git commit-graph write --reachable --split &&
127 test_path_is_file $graphdir/commit-graph-chain &&
128 test_line_count = 1 $graphdir/commit-graph-chain &&
129 verify_chain_files_exist $graphdir
133 test_expect_success 'add three more commits, write a tip graph' '
134 git reset --hard commits/3 &&
135 git merge merge/1 &&
136 git merge commits/5 &&
137 git merge merge/2 &&
138 git branch merge/3 &&
139 git commit-graph write --reachable --split &&
140 test_path_is_missing $infodir/commit-graph &&
141 test_path_is_file $graphdir/commit-graph-chain &&
142 ls $graphdir/graph-*.graph >graph-files &&
143 test_line_count = 2 graph-files &&
144 verify_chain_files_exist $graphdir
147 graph_git_behavior 'split commit-graph: merge 3 vs 2' merge/3 merge/2
149 test_expect_success 'add one commit, write a tip graph' '
150 test_commit 11 &&
151 git branch commits/11 &&
152 git commit-graph write --reachable --split &&
153 test_path_is_missing $infodir/commit-graph &&
154 test_path_is_file $graphdir/commit-graph-chain &&
155 ls $graphdir/graph-*.graph >graph-files &&
156 test_line_count = 3 graph-files &&
157 verify_chain_files_exist $graphdir
160 graph_git_behavior 'three-layer commit-graph: commit 11 vs 6' commits/11 commits/6
162 test_expect_success 'add one commit, write a merged graph' '
163 test_commit 12 &&
164 git branch commits/12 &&
165 git commit-graph write --reachable --split &&
166 test_path_is_file $graphdir/commit-graph-chain &&
167 test_line_count = 2 $graphdir/commit-graph-chain &&
168 ls $graphdir/graph-*.graph >graph-files &&
169 test_line_count = 2 graph-files &&
170 verify_chain_files_exist $graphdir
173 graph_git_behavior 'merged commit-graph: commit 12 vs 6' commits/12 commits/6
175 test_expect_success 'create fork and chain across alternate' '
176 git clone . fork &&
178 cd fork &&
179 git config core.commitGraph true &&
180 rm -rf $graphdir &&
181 echo "$(pwd)/../.git/objects" >.git/objects/info/alternates &&
182 test_commit 13 &&
183 git branch commits/13 &&
184 git commit-graph write --reachable --split &&
185 test_path_is_file $graphdir/commit-graph-chain &&
186 test_line_count = 3 $graphdir/commit-graph-chain &&
187 ls $graphdir/graph-*.graph >graph-files &&
188 test_line_count = 1 graph-files &&
189 git -c core.commitGraph=true rev-list HEAD >expect &&
190 git -c core.commitGraph=false rev-list HEAD >actual &&
191 test_cmp expect actual &&
192 test_commit 14 &&
193 git commit-graph write --reachable --split --object-dir=.git/objects/ &&
194 test_line_count = 3 $graphdir/commit-graph-chain &&
195 ls $graphdir/graph-*.graph >graph-files &&
196 test_line_count = 1 graph-files
200 if test -d fork
201 then
202 graph_git_behavior 'alternate: commit 13 vs 6' commits/13 origin/commits/6 "fork"
205 test_expect_success 'test merge stragety constants' '
206 git clone . merge-2 &&
208 cd merge-2 &&
209 git config core.commitGraph true &&
210 test_line_count = 2 $graphdir/commit-graph-chain &&
211 test_commit 14 &&
212 git commit-graph write --reachable --split --size-multiple=2 &&
213 test_line_count = 3 $graphdir/commit-graph-chain
215 ) &&
216 git clone . merge-10 &&
218 cd merge-10 &&
219 git config core.commitGraph true &&
220 test_line_count = 2 $graphdir/commit-graph-chain &&
221 test_commit 14 &&
222 git commit-graph write --reachable --split --size-multiple=10 &&
223 test_line_count = 1 $graphdir/commit-graph-chain &&
224 ls $graphdir/graph-*.graph >graph-files &&
225 test_line_count = 1 graph-files
226 ) &&
227 git clone . merge-10-expire &&
229 cd merge-10-expire &&
230 git config core.commitGraph true &&
231 test_line_count = 2 $graphdir/commit-graph-chain &&
232 test_commit 15 &&
233 touch $graphdir/to-delete.graph $graphdir/to-keep.graph &&
234 test-tool chmtime =1546362000 $graphdir/to-delete.graph &&
235 test-tool chmtime =1546362001 $graphdir/to-keep.graph &&
236 git commit-graph write --reachable --split --size-multiple=10 \
237 --expire-time="2019-01-01 12:00 -05:00" &&
238 test_line_count = 1 $graphdir/commit-graph-chain &&
239 test_path_is_missing $graphdir/to-delete.graph &&
240 test_path_is_file $graphdir/to-keep.graph &&
241 ls $graphdir/graph-*.graph >graph-files &&
242 test_line_count = 3 graph-files
243 ) &&
244 git clone --no-hardlinks . max-commits &&
246 cd max-commits &&
247 git config core.commitGraph true &&
248 test_line_count = 2 $graphdir/commit-graph-chain &&
249 test_commit 16 &&
250 test_commit 17 &&
251 git commit-graph write --reachable --split --max-commits=1 &&
252 test_line_count = 1 $graphdir/commit-graph-chain &&
253 ls $graphdir/graph-*.graph >graph-files &&
254 test_line_count = 1 graph-files
258 test_expect_success 'remove commit-graph-chain file after flattening' '
259 git clone . flatten &&
261 cd flatten &&
262 test_line_count = 2 $graphdir/commit-graph-chain &&
263 git commit-graph write --reachable &&
264 test_path_is_missing $graphdir/commit-graph-chain &&
265 ls $graphdir >graph-files &&
266 test_line_count = 0 graph-files
270 corrupt_file() {
271 file=$1
272 pos=$2
273 data="${3:-\0}"
274 chmod a+w "$file" &&
275 printf "$data" | dd of="$file" bs=1 seek="$pos" conv=notrunc
278 test_expect_success 'verify hashes along chain, even in shallow' '
279 git clone --no-hardlinks . verify &&
281 cd verify &&
282 git commit-graph verify &&
283 base_file=$graphdir/graph-$(head -n 1 $graphdir/commit-graph-chain).graph &&
284 corrupt_file "$base_file" $(test_oid shallow) "\01" &&
285 test_must_fail git commit-graph verify --shallow 2>test_err &&
286 grep -v "^+" test_err >err &&
287 test_grep "incorrect checksum" err
291 test_expect_success 'verify notices chain slice which is bogus (base)' '
292 git clone --no-hardlinks . verify-chain-bogus-base &&
294 cd verify-chain-bogus-base &&
295 git commit-graph verify &&
296 base_file=$graphdir/graph-$(sed -n 1p $graphdir/commit-graph-chain).graph &&
297 echo "garbage" >$base_file &&
298 test_must_fail git commit-graph verify 2>test_err &&
299 grep -v "^+" test_err >err &&
300 grep "commit-graph file is too small" err
304 test_expect_success 'verify notices chain slice which is bogus (tip)' '
305 git clone --no-hardlinks . verify-chain-bogus-tip &&
307 cd verify-chain-bogus-tip &&
308 git commit-graph verify &&
309 tip_file=$graphdir/graph-$(sed -n 2p $graphdir/commit-graph-chain).graph &&
310 echo "garbage" >$tip_file &&
311 test_must_fail git commit-graph verify 2>test_err &&
312 grep -v "^+" test_err >err &&
313 grep "commit-graph file is too small" err
317 test_expect_success 'verify --shallow does not check base contents' '
318 git clone --no-hardlinks . verify-shallow &&
320 cd verify-shallow &&
321 git commit-graph verify &&
322 base_file=$graphdir/graph-$(head -n 1 $graphdir/commit-graph-chain).graph &&
323 corrupt_file "$base_file" 1500 "\01" &&
324 git commit-graph verify --shallow &&
325 test_must_fail git commit-graph verify 2>test_err &&
326 grep -v "^+" test_err >err &&
327 test_grep "incorrect checksum" err
331 test_expect_success 'warn on base graph chunk incorrect' '
332 git clone --no-hardlinks . base-chunk &&
334 cd base-chunk &&
335 git commit-graph verify &&
336 base_file=$graphdir/graph-$(tail -n 1 $graphdir/commit-graph-chain).graph &&
337 corrupt_file "$base_file" $(test_oid base) "\01" &&
338 test_must_fail git commit-graph verify --shallow 2>test_err &&
339 grep -v "^+" test_err >err &&
340 test_grep "commit-graph chain does not match" err
344 test_expect_success 'verify after commit-graph-chain corruption (base)' '
345 git clone --no-hardlinks . verify-chain-base &&
347 cd verify-chain-base &&
348 corrupt_file "$graphdir/commit-graph-chain" 30 "G" &&
349 test_must_fail git commit-graph verify 2>test_err &&
350 grep -v "^+" test_err >err &&
351 test_grep "invalid commit-graph chain" err &&
352 corrupt_file "$graphdir/commit-graph-chain" 30 "A" &&
353 test_must_fail git commit-graph verify 2>test_err &&
354 grep -v "^+" test_err >err &&
355 test_grep "unable to find all commit-graph files" err
359 test_expect_success 'verify after commit-graph-chain corruption (tip)' '
360 git clone --no-hardlinks . verify-chain-tip &&
362 cd verify-chain-tip &&
363 corrupt_file "$graphdir/commit-graph-chain" 70 "G" &&
364 test_must_fail git commit-graph verify 2>test_err &&
365 grep -v "^+" test_err >err &&
366 test_grep "invalid commit-graph chain" err &&
367 corrupt_file "$graphdir/commit-graph-chain" 70 "A" &&
368 test_must_fail git commit-graph verify 2>test_err &&
369 grep -v "^+" test_err >err &&
370 test_grep "unable to find all commit-graph files" err
374 test_expect_success 'verify notices too-short chain file' '
375 git clone --no-hardlinks . verify-chain-short &&
377 cd verify-chain-short &&
378 git commit-graph verify &&
379 echo "garbage" >$graphdir/commit-graph-chain &&
380 test_must_fail git commit-graph verify 2>test_err &&
381 grep -v "^+" test_err >err &&
382 grep "commit-graph chain file too small" err
386 test_expect_success 'verify across alternates' '
387 git clone --no-hardlinks . verify-alt &&
389 cd verify-alt &&
390 rm -rf $graphdir &&
391 altdir="$(pwd)/../.git/objects" &&
392 echo "$altdir" >.git/objects/info/alternates &&
393 git commit-graph verify --object-dir="$altdir/" &&
394 test_commit extra &&
395 git commit-graph write --reachable --split &&
396 tip_file=$graphdir/graph-$(tail -n 1 $graphdir/commit-graph-chain).graph &&
397 corrupt_file "$tip_file" 1500 "\01" &&
398 test_must_fail git commit-graph verify --shallow 2>test_err &&
399 grep -v "^+" test_err >err &&
400 test_grep "incorrect checksum" err
404 test_expect_success 'reader bounds-checks base-graph chunk' '
405 git clone --no-hardlinks . corrupt-base-chunk &&
407 cd corrupt-base-chunk &&
408 tip_file=$graphdir/graph-$(tail -n 1 $graphdir/commit-graph-chain).graph &&
409 corrupt_chunk_file "$tip_file" BASE clear 01020304 &&
410 git -c core.commitGraph=false log >expect.out &&
411 git -c core.commitGraph=true log >out 2>err &&
412 test_cmp expect.out out &&
413 grep "commit-graph base graphs chunk is too small" err
417 test_expect_success 'add octopus merge' '
418 git reset --hard commits/10 &&
419 git merge commits/3 commits/4 &&
420 git branch merge/octopus &&
421 git commit-graph write --reachable --split &&
422 git commit-graph verify --progress 2>err &&
423 test_line_count = 1 err &&
424 grep "Verifying commits in commit graph: 100% (18/18)" err &&
425 test_grep ! warning err &&
426 test_line_count = 3 $graphdir/commit-graph-chain
429 graph_git_behavior 'graph exists' merge/octopus commits/12
431 test_expect_success 'split across alternate where alternate is not split' '
432 git commit-graph write --reachable &&
433 test_path_is_file .git/objects/info/commit-graph &&
434 cp .git/objects/info/commit-graph . &&
435 git clone --no-hardlinks . alt-split &&
437 cd alt-split &&
438 rm -f .git/objects/info/commit-graph &&
439 echo "$(pwd)"/../.git/objects >.git/objects/info/alternates &&
440 test_commit 18 &&
441 git commit-graph write --reachable --split &&
442 test_line_count = 1 $graphdir/commit-graph-chain
443 ) &&
444 test_cmp commit-graph .git/objects/info/commit-graph
447 test_expect_success '--split=no-merge always writes an incremental' '
448 test_when_finished rm -rf a b &&
449 rm -rf $graphdir $infodir/commit-graph &&
450 git reset --hard commits/2 &&
451 git rev-list HEAD~1 >a &&
452 git rev-list HEAD >b &&
453 git commit-graph write --split --stdin-commits <a &&
454 git commit-graph write --split=no-merge --stdin-commits <b &&
455 test_line_count = 2 $graphdir/commit-graph-chain
458 test_expect_success '--split=replace replaces the chain' '
459 rm -rf $graphdir $infodir/commit-graph &&
460 git reset --hard commits/3 &&
461 git rev-list -1 HEAD~2 >a &&
462 git rev-list -1 HEAD~1 >b &&
463 git rev-list -1 HEAD >c &&
464 git commit-graph write --split=no-merge --stdin-commits <a &&
465 git commit-graph write --split=no-merge --stdin-commits <b &&
466 git commit-graph write --split=no-merge --stdin-commits <c &&
467 test_line_count = 3 $graphdir/commit-graph-chain &&
468 git commit-graph write --stdin-commits --split=replace <b &&
469 test_path_is_missing $infodir/commit-graph &&
470 test_path_is_file $graphdir/commit-graph-chain &&
471 ls $graphdir/graph-*.graph >graph-files &&
472 test_line_count = 1 graph-files &&
473 verify_chain_files_exist $graphdir &&
474 graph_read_expect 2
477 test_expect_success ULIMIT_FILE_DESCRIPTORS 'handles file descriptor exhaustion' '
478 git init ulimit &&
480 cd ulimit &&
481 for i in $(test_seq 64)
483 test_commit $i &&
484 run_with_limited_open_files test_might_fail git commit-graph write \
485 --split=no-merge --reachable || return 1
486 done
490 while read mode modebits
492 test_expect_success POSIXPERM "split commit-graph respects core.sharedrepository $mode" '
493 rm -rf $graphdir $infodir/commit-graph &&
494 git reset --hard commits/1 &&
495 test_config core.sharedrepository "$mode" &&
496 git commit-graph write --split --reachable &&
497 ls $graphdir/graph-*.graph >graph-files &&
498 test_line_count = 1 graph-files &&
499 echo "$modebits" >expect &&
500 test_modebits $graphdir/graph-*.graph >actual &&
501 test_cmp expect actual &&
502 test_modebits $graphdir/commit-graph-chain >actual &&
503 test_cmp expect actual
505 done <<\EOF
506 0666 -r--r--r--
507 0600 -r--------
510 test_expect_success '--split=replace with partial Bloom data' '
511 rm -rf $graphdir $infodir/commit-graph &&
512 git reset --hard commits/3 &&
513 git rev-list -1 HEAD~2 >a &&
514 git rev-list -1 HEAD~1 >b &&
515 git commit-graph write --split=no-merge --stdin-commits --changed-paths <a &&
516 git commit-graph write --split=no-merge --stdin-commits <b &&
517 git commit-graph write --split=replace --stdin-commits --changed-paths <c &&
518 ls $graphdir/graph-*.graph >graph-files &&
519 test_line_count = 1 graph-files &&
520 verify_chain_files_exist $graphdir
523 test_expect_success 'prevent regression for duplicate commits across layers' '
524 git init dup &&
525 git -C dup commit --allow-empty -m one &&
526 git -C dup -c core.commitGraph=false commit-graph write --split=no-merge --reachable 2>err &&
527 test_grep "attempting to write a commit-graph" err &&
528 git -C dup commit-graph write --split=no-merge --reachable &&
529 git -C dup commit --allow-empty -m two &&
530 git -C dup commit-graph write --split=no-merge --reachable &&
531 git -C dup commit --allow-empty -m three &&
532 git -C dup commit-graph write --split --reachable &&
533 git -C dup commit-graph verify
536 NUM_FIRST_LAYER_COMMITS=64
537 NUM_SECOND_LAYER_COMMITS=16
538 NUM_THIRD_LAYER_COMMITS=7
539 NUM_FOURTH_LAYER_COMMITS=8
540 NUM_FIFTH_LAYER_COMMITS=16
541 SECOND_LAYER_SEQUENCE_START=$(($NUM_FIRST_LAYER_COMMITS + 1))
542 SECOND_LAYER_SEQUENCE_END=$(($SECOND_LAYER_SEQUENCE_START + $NUM_SECOND_LAYER_COMMITS - 1))
543 THIRD_LAYER_SEQUENCE_START=$(($SECOND_LAYER_SEQUENCE_END + 1))
544 THIRD_LAYER_SEQUENCE_END=$(($THIRD_LAYER_SEQUENCE_START + $NUM_THIRD_LAYER_COMMITS - 1))
545 FOURTH_LAYER_SEQUENCE_START=$(($THIRD_LAYER_SEQUENCE_END + 1))
546 FOURTH_LAYER_SEQUENCE_END=$(($FOURTH_LAYER_SEQUENCE_START + $NUM_FOURTH_LAYER_COMMITS - 1))
547 FIFTH_LAYER_SEQUENCE_START=$(($FOURTH_LAYER_SEQUENCE_END + 1))
548 FIFTH_LAYER_SEQUENCE_END=$(($FIFTH_LAYER_SEQUENCE_START + $NUM_FIFTH_LAYER_COMMITS - 1))
550 # Current split graph chain:
552 # 16 commits (No GDAT)
553 # ------------------------
554 # 64 commits (GDAT)
556 test_expect_success 'setup repo for mixed generation commit-graph-chain' '
557 graphdir=".git/objects/info/commit-graphs" &&
558 test_oid_cache <<-EOF &&
559 oid_version sha1:1
560 oid_version sha256:2
562 git init mixed &&
564 cd mixed &&
565 git config core.commitGraph true &&
566 git config gc.writeCommitGraph false &&
567 for i in $(test_seq $NUM_FIRST_LAYER_COMMITS)
569 test_commit $i &&
570 git branch commits/$i || return 1
571 done &&
572 git -c commitGraph.generationVersion=2 commit-graph write --reachable --split &&
573 graph_read_expect $NUM_FIRST_LAYER_COMMITS &&
574 test_line_count = 1 $graphdir/commit-graph-chain &&
575 for i in $(test_seq $SECOND_LAYER_SEQUENCE_START $SECOND_LAYER_SEQUENCE_END)
577 test_commit $i &&
578 git branch commits/$i || return 1
579 done &&
580 git -c commitGraph.generationVersion=1 commit-graph write --reachable --split=no-merge &&
581 test_line_count = 2 $graphdir/commit-graph-chain &&
582 test-tool read-graph >output &&
583 cat >expect <<-EOF &&
584 header: 43475048 1 $(test_oid oid_version) 4 1
585 num_commits: $NUM_SECOND_LAYER_COMMITS
586 chunks: oid_fanout oid_lookup commit_metadata
587 options:
589 test_cmp expect output &&
590 git commit-graph verify &&
591 cat $graphdir/commit-graph-chain
595 # The new layer will be added without generation data chunk as it was not
596 # present on the layer underneath it.
598 # 7 commits (No GDAT)
599 # ------------------------
600 # 16 commits (No GDAT)
601 # ------------------------
602 # 64 commits (GDAT)
604 test_expect_success 'do not write generation data chunk if not present on existing tip' '
605 git clone mixed mixed-no-gdat &&
607 cd mixed-no-gdat &&
608 for i in $(test_seq $THIRD_LAYER_SEQUENCE_START $THIRD_LAYER_SEQUENCE_END)
610 test_commit $i &&
611 git branch commits/$i || return 1
612 done &&
613 git commit-graph write --reachable --split=no-merge &&
614 test_line_count = 3 $graphdir/commit-graph-chain &&
615 test-tool read-graph >output &&
616 cat >expect <<-EOF &&
617 header: 43475048 1 $(test_oid oid_version) 4 2
618 num_commits: $NUM_THIRD_LAYER_COMMITS
619 chunks: oid_fanout oid_lookup commit_metadata
620 options:
622 test_cmp expect output &&
623 git commit-graph verify
627 # Number of commits in each layer of the split-commit graph before merge:
629 # 8 commits (No GDAT)
630 # ------------------------
631 # 7 commits (No GDAT)
632 # ------------------------
633 # 16 commits (No GDAT)
634 # ------------------------
635 # 64 commits (GDAT)
637 # The top two layers are merged and do not have generation data chunk as layer below them does
638 # not have generation data chunk.
640 # 15 commits (No GDAT)
641 # ------------------------
642 # 16 commits (No GDAT)
643 # ------------------------
644 # 64 commits (GDAT)
646 test_expect_success 'do not write generation data chunk if the topmost remaining layer does not have generation data chunk' '
647 git clone mixed-no-gdat mixed-merge-no-gdat &&
649 cd mixed-merge-no-gdat &&
650 for i in $(test_seq $FOURTH_LAYER_SEQUENCE_START $FOURTH_LAYER_SEQUENCE_END)
652 test_commit $i &&
653 git branch commits/$i || return 1
654 done &&
655 git commit-graph write --reachable --split --size-multiple 1 &&
656 test_line_count = 3 $graphdir/commit-graph-chain &&
657 test-tool read-graph >output &&
658 cat >expect <<-EOF &&
659 header: 43475048 1 $(test_oid oid_version) 4 2
660 num_commits: $(($NUM_THIRD_LAYER_COMMITS + $NUM_FOURTH_LAYER_COMMITS))
661 chunks: oid_fanout oid_lookup commit_metadata
662 options:
664 test_cmp expect output &&
665 git commit-graph verify
669 # Number of commits in each layer of the split-commit graph before merge:
671 # 16 commits (No GDAT)
672 # ------------------------
673 # 15 commits (No GDAT)
674 # ------------------------
675 # 16 commits (No GDAT)
676 # ------------------------
677 # 64 commits (GDAT)
679 # The top three layers are merged and has generation data chunk as the topmost remaining layer
680 # has generation data chunk.
682 # 47 commits (GDAT)
683 # ------------------------
684 # 64 commits (GDAT)
686 test_expect_success 'write generation data chunk if topmost remaining layer has generation data chunk' '
687 git clone mixed-merge-no-gdat mixed-merge-gdat &&
689 cd mixed-merge-gdat &&
690 for i in $(test_seq $FIFTH_LAYER_SEQUENCE_START $FIFTH_LAYER_SEQUENCE_END)
692 test_commit $i &&
693 git branch commits/$i || return 1
694 done &&
695 git commit-graph write --reachable --split --size-multiple 1 &&
696 test_line_count = 2 $graphdir/commit-graph-chain &&
697 test-tool read-graph >output &&
698 cat >expect <<-EOF &&
699 header: 43475048 1 $(test_oid oid_version) 5 1
700 num_commits: $(($NUM_SECOND_LAYER_COMMITS + $NUM_THIRD_LAYER_COMMITS + $NUM_FOURTH_LAYER_COMMITS + $NUM_FIFTH_LAYER_COMMITS))
701 chunks: oid_fanout oid_lookup commit_metadata generation_data
702 options: read_generation_data
704 test_cmp expect output
708 test_expect_success 'write generation data chunk when commit-graph chain is replaced' '
709 git clone mixed mixed-replace &&
711 cd mixed-replace &&
712 git commit-graph write --reachable --split=replace &&
713 test_path_is_file $graphdir/commit-graph-chain &&
714 test_line_count = 1 $graphdir/commit-graph-chain &&
715 verify_chain_files_exist $graphdir &&
716 graph_read_expect $(($NUM_FIRST_LAYER_COMMITS + $NUM_SECOND_LAYER_COMMITS)) &&
717 git commit-graph verify
721 test_done