Skip to content

Commit b82299e

Browse files
committed
Merge branch 'ab/ignore-replace-while-working-on-commit-graph'
Teach "git commit-graph" command not to allow using replace objects at all, as we do not use the commit-graph at runtime when we see object replacement. * ab/ignore-replace-while-working-on-commit-graph: commit-graph: don't consider "replace" objects with "verify" commit-graph tests: fix another graph_git_two_modes() helper commit-graph tests: fix error-hiding graph_git_two_modes() helper
2 parents b93d720 + 095d112 commit b82299e

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

builtin/commit-graph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ static int graph_write(int argc, const char **argv)
263263
git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))
264264
flags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;
265265

266-
read_replace_refs = 0;
267266
odb = find_odb(the_repository, opts.obj_dir);
268267

269268
if (opts.reachable) {
@@ -318,6 +317,7 @@ int cmd_commit_graph(int argc, const char **argv, const char *prefix)
318317
if (!argc)
319318
goto usage;
320319

320+
read_replace_refs = 0;
321321
save_commit_buffer = 0;
322322

323323
if (!strcmp(argv[0], "verify"))

t/t5318-commit-graph.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ test_expect_success 'create commits and repack' '
7070
'
7171

7272
graph_git_two_modes() {
73-
git -c core.commitGraph=true $1 >output
74-
git -c core.commitGraph=false $1 >expect
73+
git -c core.commitGraph=true $1 >output &&
74+
git -c core.commitGraph=false $1 >expect &&
7575
test_cmp expect output
7676
}
7777

@@ -385,6 +385,7 @@ test_expect_success 'replace-objects invalidates commit-graph' '
385385
git commit-graph write --reachable &&
386386
test_path_is_file .git/objects/info/commit-graph &&
387387
git replace HEAD~1 HEAD~2 &&
388+
graph_git_two_modes "commit-graph verify" &&
388389
git -c core.commitGraph=false log >expect &&
389390
git -c core.commitGraph=true log >actual &&
390391
test_cmp expect actual &&

t/t5324-split-commit-graph.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,22 @@ test_expect_success 'create commits and write commit-graph' '
5555
'
5656

5757
graph_git_two_modes() {
58-
git -c core.commitGraph=true $1 >output
59-
git -c core.commitGraph=false $1 >expect
58+
git ${2:+ -C "$2"} -c core.commitGraph=true $1 >output &&
59+
git ${2:+ -C "$2"} -c core.commitGraph=false $1 >expect &&
6060
test_cmp expect output
6161
}
6262

6363
graph_git_behavior() {
6464
MSG=$1
6565
BRANCH=$2
6666
COMPARE=$3
67+
DIR=$4
6768
test_expect_success "check normal git operations: $MSG" '
68-
graph_git_two_modes "log --oneline $BRANCH" &&
69-
graph_git_two_modes "log --topo-order $BRANCH" &&
70-
graph_git_two_modes "log --graph $COMPARE..$BRANCH" &&
71-
graph_git_two_modes "branch -vv" &&
72-
graph_git_two_modes "merge-base -a $BRANCH $COMPARE"
69+
graph_git_two_modes "log --oneline $BRANCH" "$DIR" &&
70+
graph_git_two_modes "log --topo-order $BRANCH" "$DIR" &&
71+
graph_git_two_modes "log --graph $COMPARE..$BRANCH" "$DIR" &&
72+
graph_git_two_modes "branch -vv" "$DIR" &&
73+
graph_git_two_modes "merge-base -a $BRANCH $COMPARE" "$DIR"
7374
'
7475
}
7576

@@ -187,7 +188,10 @@ test_expect_success 'create fork and chain across alternate' '
187188
)
188189
'
189190

190-
graph_git_behavior 'alternate: commit 13 vs 6' commits/13 commits/6
191+
if test -d fork
192+
then
193+
graph_git_behavior 'alternate: commit 13 vs 6' commits/13 origin/commits/6 "fork"
194+
fi
191195

192196
test_expect_success 'test merge stragety constants' '
193197
git clone . merge-2 &&

0 commit comments

Comments
 (0)