3 test_description='split commit graph'
6 GIT_TEST_COMMIT_GRAPH=0
8 test_expect_success 'setup repo' '
10 git config core.commitGraph true &&
11 infodir=".git/objects/info" &&
12 graphdir="$infodir/commit-graphs" &&
23 header: 43475048 1 1 3 $NUM_BASE
25 chunks: oid_fanout oid_lookup commit_metadata
27 git commit-graph read >output &&
28 test_cmp expect output
31 test_expect_success 'create commits and write commit-graph' '
32 for i in $(test_seq 3)
35 git branch commits/$i || return 1
37 git commit-graph write --reachable &&
38 test_path_is_file $infodir/commit-graph &&
42 graph_git_two_modes() {
43 git -c core.commitGraph=true $1 >output
44 git -c core.commitGraph=false $1 >expect
45 test_cmp expect output
48 graph_git_behavior() {
52 test_expect_success "check normal git operations: $MSG" '
53 graph_git_two_modes "log --oneline $BRANCH" &&
54 graph_git_two_modes "log --topo-order $BRANCH" &&
55 graph_git_two_modes "log --graph $COMPARE..$BRANCH" &&
56 graph_git_two_modes "branch -vv" &&
57 graph_git_two_modes "merge-base -a $BRANCH $COMPARE"
61 graph_git_behavior 'graph exists' commits/3 commits/1
63 verify_chain_files_exist() {
64 for hash in $(cat $1/commit-graph-chain)
66 test_path_is_file $1/graph-$hash.graph || return 1
70 test_expect_success 'add more commits, and write a new base graph' '
71 git reset --hard commits/1 &&
72 for i in $(test_seq 4 5)
75 git branch commits/$i || return 1
77 git reset --hard commits/2 &&
78 for i in $(test_seq 6 10)
81 git branch commits/$i || return 1
83 git reset --hard commits/2 &&
84 git merge commits/4 &&
86 git reset --hard commits/4 &&
87 git merge commits/6 &&
89 git commit-graph write --reachable &&
93 test_expect_success 'add three more commits, write a tip graph' '
94 git reset --hard commits/3 &&
96 git merge commits/5 &&
99 git commit-graph write --reachable --split &&
100 test_path_is_missing $infodir/commit-graph &&
101 test_path_is_file $graphdir/commit-graph-chain &&
102 ls $graphdir/graph-*.graph >graph-files &&
103 test_line_count = 2 graph-files &&
104 verify_chain_files_exist $graphdir
107 graph_git_behavior 'split commit-graph: merge 3 vs 2' merge/3 merge/2
109 test_expect_success 'add one commit, write a tip graph' '
111 git branch commits/11 &&
112 git commit-graph write --reachable --split &&
113 test_path_is_missing $infodir/commit-graph &&
114 test_path_is_file $graphdir/commit-graph-chain &&
115 ls $graphdir/graph-*.graph >graph-files &&
116 test_line_count = 3 graph-files &&
117 verify_chain_files_exist $graphdir
120 graph_git_behavior 'three-layer commit-graph: commit 11 vs 6' commits/11 commits/6