3 test_description='commit graph'
6 test_expect_success 'setup full repo' '
8 cd "$TRASH_DIRECTORY/full" &&
10 git config core.commitGraph true &&
14 test_expect_success 'write graph with no packs' '
15 cd "$TRASH_DIRECTORY/full" &&
16 git commit-graph write --object-dir . &&
17 test_path_is_file info/commit-graph
20 test_expect_success 'create commits and repack' '
21 cd "$TRASH_DIRECTORY/full" &&
22 for i in $(test_seq 3)
30 graph_git_two_modes() {
31 git -c core.graph=true $1 >output
32 git -c core.graph=false $1 >expect
33 test_cmp output expect
36 graph_git_behavior() {
41 test_expect_success "check normal git operations: $MSG" '
42 cd "$TRASH_DIRECTORY/$DIR" &&
43 graph_git_two_modes "log --oneline $BRANCH" &&
44 graph_git_two_modes "log --topo-order $BRANCH" &&
45 graph_git_two_modes "log --graph $COMPARE..$BRANCH" &&
46 graph_git_two_modes "branch -vv" &&
47 graph_git_two_modes "merge-base -a $BRANCH $COMPARE"
51 graph_git_behavior 'no graph' full commits/3 commits/1
59 NUM_CHUNKS=$((3 + $(echo "$2" | wc -w)))
62 header: 43475048 1 1 $NUM_CHUNKS 0
64 chunks: oid_fanout oid_lookup commit_metadata$OPTIONAL
66 git commit-graph read >output &&
67 test_cmp expect output
70 test_expect_success 'write graph' '
71 cd "$TRASH_DIRECTORY/full" &&
72 graph1=$(git commit-graph write) &&
73 test_path_is_file $objdir/info/commit-graph &&
77 graph_git_behavior 'graph exists' full commits/3 commits/1
79 test_expect_success 'Add more commits' '
80 cd "$TRASH_DIRECTORY/full" &&
81 git reset --hard commits/1 &&
82 for i in $(test_seq 4 5)
87 git reset --hard commits/2 &&
88 for i in $(test_seq 6 7)
93 git reset --hard commits/2 &&
94 git merge commits/4 &&
96 git reset --hard commits/4 &&
97 git merge commits/6 &&
99 git reset --hard commits/3 &&
100 git merge commits/5 commits/7 &&
101 git branch merge/3 &&
105 # Current graph structure:
115 test_expect_success 'write graph with merges' '
116 cd "$TRASH_DIRECTORY/full" &&
117 git commit-graph write &&
118 test_path_is_file $objdir/info/commit-graph &&
119 graph_read_expect "10" "large_edges"
122 graph_git_behavior 'merge 1 vs 2' full merge/1 merge/2
123 graph_git_behavior 'merge 1 vs 3' full merge/1 merge/3
124 graph_git_behavior 'merge 2 vs 3' full merge/2 merge/3
126 test_expect_success 'Add one more commit' '
127 cd "$TRASH_DIRECTORY/full" &&
129 git branch commits/8 &&
130 ls $objdir/pack | grep idx >existing-idx &&
132 ls $objdir/pack| grep idx | grep -v --file=existing-idx >new-idx
135 # Current graph structure:
147 graph_git_behavior 'mixed mode, commit 8 vs merge 1' full commits/8 merge/1
148 graph_git_behavior 'mixed mode, commit 8 vs merge 2' full commits/8 merge/2
150 test_expect_success 'write graph with new commit' '
151 cd "$TRASH_DIRECTORY/full" &&
152 git commit-graph write &&
153 test_path_is_file $objdir/info/commit-graph &&
154 graph_read_expect "11" "large_edges"
157 graph_git_behavior 'full graph, commit 8 vs merge 1' full commits/8 merge/1
158 graph_git_behavior 'full graph, commit 8 vs merge 2' full commits/8 merge/2
160 test_expect_success 'write graph with nothing new' '
161 cd "$TRASH_DIRECTORY/full" &&
162 git commit-graph write &&
163 test_path_is_file $objdir/info/commit-graph &&
164 graph_read_expect "11" "large_edges"
167 graph_git_behavior 'cleared graph, commit 8 vs merge 1' full commits/8 merge/1
168 graph_git_behavior 'cleared graph, commit 8 vs merge 2' full commits/8 merge/2
170 test_expect_success 'build graph from latest pack with closure' '
171 cd "$TRASH_DIRECTORY/full" &&
172 cat new-idx | git commit-graph write --stdin-packs &&
173 test_path_is_file $objdir/info/commit-graph &&
174 graph_read_expect "9" "large_edges"
177 graph_git_behavior 'graph from pack, commit 8 vs merge 1' full commits/8 merge/1
178 graph_git_behavior 'graph from pack, commit 8 vs merge 2' full commits/8 merge/2
180 test_expect_success 'build graph from commits with closure' '
181 cd "$TRASH_DIRECTORY/full" &&
182 git tag -a -m "merge" tag/merge merge/2 &&
183 git rev-parse tag/merge >commits-in &&
184 git rev-parse merge/1 >>commits-in &&
185 cat commits-in | git commit-graph write --stdin-commits &&
186 test_path_is_file $objdir/info/commit-graph &&
187 graph_read_expect "6"
190 graph_git_behavior 'graph from commits, commit 8 vs merge 1' full commits/8 merge/1
191 graph_git_behavior 'graph from commits, commit 8 vs merge 2' full commits/8 merge/2
193 test_expect_success 'build graph from commits with append' '
194 cd "$TRASH_DIRECTORY/full" &&
195 git rev-parse merge/3 | git commit-graph write --stdin-commits --append &&
196 test_path_is_file $objdir/info/commit-graph &&
197 graph_read_expect "10" "large_edges"
200 graph_git_behavior 'append graph, commit 8 vs merge 1' full commits/8 merge/1
201 graph_git_behavior 'append graph, commit 8 vs merge 2' full commits/8 merge/2
203 test_expect_success 'setup bare repo' '
204 cd "$TRASH_DIRECTORY" &&
205 git clone --bare --no-local full bare &&
207 git config core.commitGraph true &&
211 graph_git_behavior 'bare repo, commit 8 vs merge 1' bare commits/8 merge/1
212 graph_git_behavior 'bare repo, commit 8 vs merge 2' bare commits/8 merge/2
214 test_expect_success 'write graph in bare repo' '
215 cd "$TRASH_DIRECTORY/bare" &&
216 git commit-graph write &&
217 test_path_is_file $baredir/info/commit-graph &&
218 graph_read_expect "11" "large_edges"
221 graph_git_behavior 'bare repo with graph, commit 8 vs merge 1' bare commits/8 merge/1
222 graph_git_behavior 'bare repo with graph, commit 8 vs merge 2' bare commits/8 merge/2