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 'fork and fail to base a chain on a commit-graph file' '
94 test_when_finished rm -rf fork &&
98 rm .git/objects/info/commit-graph &&
99 echo "$(pwd)/../.git/objects" >.git/objects/info/alternates &&
100 test_commit new-commit &&
101 git commit-graph write --reachable --split &&
102 test_path_is_file $graphdir/commit-graph-chain &&
103 test_line_count = 1 $graphdir/commit-graph-chain &&
104 verify_chain_files_exist $graphdir
108 test_expect_success 'add three more commits, write a tip graph' '
109 git reset --hard commits/3 &&
111 git merge commits/5 &&
113 git branch merge/3 &&
114 git commit-graph write --reachable --split &&
115 test_path_is_missing $infodir/commit-graph &&
116 test_path_is_file $graphdir/commit-graph-chain &&
117 ls $graphdir/graph-*.graph >graph-files &&
118 test_line_count = 2 graph-files &&
119 verify_chain_files_exist $graphdir
122 graph_git_behavior 'split commit-graph: merge 3 vs 2' merge/3 merge/2
124 test_expect_success 'add one commit, write a tip graph' '
126 git branch commits/11 &&
127 git commit-graph write --reachable --split &&
128 test_path_is_missing $infodir/commit-graph &&
129 test_path_is_file $graphdir/commit-graph-chain &&
130 ls $graphdir/graph-*.graph >graph-files &&
131 test_line_count = 3 graph-files &&
132 verify_chain_files_exist $graphdir
135 graph_git_behavior 'three-layer commit-graph: commit 11 vs 6' commits/11 commits/6
137 test_expect_success 'add one commit, write a merged graph' '
139 git branch commits/12 &&
140 git commit-graph write --reachable --split &&
141 test_path_is_file $graphdir/commit-graph-chain &&
142 test_line_count = 2 $graphdir/commit-graph-chain &&
143 ls $graphdir/graph-*.graph >graph-files &&
144 test_line_count = 2 graph-files &&
145 verify_chain_files_exist $graphdir
148 graph_git_behavior 'merged commit-graph: commit 12 vs 6' commits/12 commits/6
150 test_expect_success 'create fork and chain across alternate' '
154 git config core.commitGraph true &&
156 echo "$(pwd)/../.git/objects" >.git/objects/info/alternates &&
158 git branch commits/13 &&
159 git commit-graph write --reachable --split &&
160 test_path_is_file $graphdir/commit-graph-chain &&
161 test_line_count = 3 $graphdir/commit-graph-chain &&
162 ls $graphdir/graph-*.graph >graph-files &&
163 test_line_count = 1 graph-files &&
164 git -c core.commitGraph=true rev-list HEAD >expect &&
165 git -c core.commitGraph=false rev-list HEAD >actual &&
166 test_cmp expect actual
170 graph_git_behavior 'alternate: commit 13 vs 6' commits/13 commits/6
172 test_expect_success 'test merge stragety constants' '
173 git clone . merge-2 &&
176 git config core.commitGraph true &&
177 test_line_count = 2 $graphdir/commit-graph-chain &&
179 git commit-graph write --reachable --split --size-multiple=2 &&
180 test_line_count = 3 $graphdir/commit-graph-chain
183 git clone . merge-10 &&
186 git config core.commitGraph true &&
187 test_line_count = 2 $graphdir/commit-graph-chain &&
189 git commit-graph write --reachable --split --size-multiple=10 &&
190 test_line_count = 1 $graphdir/commit-graph-chain &&
191 ls $graphdir/graph-*.graph >graph-files &&
192 test_line_count = 1 graph-files
194 git clone . merge-10-expire &&
196 cd merge-10-expire &&
197 git config core.commitGraph true &&
198 test_line_count = 2 $graphdir/commit-graph-chain &&
200 git commit-graph write --reachable --split --size-multiple=10 --expire-time=1980-01-01 &&
201 test_line_count = 1 $graphdir/commit-graph-chain &&
202 ls $graphdir/graph-*.graph >graph-files &&
203 test_line_count = 3 graph-files
205 git clone --no-hardlinks . max-commits &&
208 git config core.commitGraph true &&
209 test_line_count = 2 $graphdir/commit-graph-chain &&
212 git commit-graph write --reachable --split --max-commits=1 &&
213 test_line_count = 1 $graphdir/commit-graph-chain &&
214 ls $graphdir/graph-*.graph >graph-files &&
215 test_line_count = 1 graph-files