Skip to content

Commit 66685e8

Browse files
committed
Merge branch 'ps/commit-graph-less-paranoid'
Earlier we stopped relying on commit-graph that (still) records information about commits that are lost from the object store, which has negative performance implications. The default has been flipped to disable this pessimization. * ps/commit-graph-less-paranoid: commit-graph: disable GIT_COMMIT_GRAPH_PARANOIA by default
2 parents 02230b7 + b1df3b3 commit 66685e8

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

Documentation/git.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -917,9 +917,9 @@ for full details.
917917
avoid issues with stale commit-graphs that contain references to
918918
already-deleted commits, but comes with a performance penalty.
919919
+
920-
The default is "true", which enables the aforementioned behavior.
921-
Setting this to "false" disables the existence check. This can lead to
922-
a performance improvement at the cost of consistency.
920+
The default is "false", which disables the aforementioned behavior.
921+
Setting this to "true" enables the existence check so that stale commits
922+
will never be returned from the commit-graph at the cost of performance.
923923

924924
`GIT_ALLOW_PROTOCOL`::
925925
If set to a colon-separated list of protocols, behave as if

commit-graph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ struct commit *lookup_commit_in_graph(struct repository *repo, const struct obje
10051005
uint32_t pos;
10061006

10071007
if (commit_graph_paranoia == -1)
1008-
commit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 1);
1008+
commit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 0);
10091009

10101010
if (!prepare_commit_graph(repo))
10111011
return NULL;

commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ int repo_parse_commit_internal(struct repository *r,
577577
static int commit_graph_paranoia = -1;
578578

579579
if (commit_graph_paranoia == -1)
580-
commit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 1);
580+
commit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 0);
581581

582582
if (commit_graph_paranoia && !has_object(r, &item->object.oid, 0)) {
583583
unparse_commit(r, &item->object.oid);

t/t5318-commit-graph.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -911,10 +911,10 @@ test_expect_success 'stale commit cannot be parsed when given directly' '
911911
912912
# Verify that it is possible to read the commit from the
913913
# commit graph when not being paranoid, ...
914-
GIT_COMMIT_GRAPH_PARANOIA=false git rev-list B &&
914+
git rev-list B &&
915915
# ... but parsing the commit when double checking that
916916
# it actually exists in the object database should fail.
917-
test_must_fail git rev-list -1 B
917+
test_must_fail env GIT_COMMIT_GRAPH_PARANOIA=true git rev-list -1 B
918918
)
919919
'
920920

@@ -938,9 +938,9 @@ test_expect_success 'stale commit cannot be parsed when traversing graph' '
938938
939939
# Again, we should be able to parse the commit when not
940940
# being paranoid about commit graph staleness...
941-
GIT_COMMIT_GRAPH_PARANOIA=false git rev-parse HEAD~2 &&
941+
git rev-parse HEAD~2 &&
942942
# ... but fail when we are paranoid.
943-
test_must_fail git rev-parse HEAD~2 2>error &&
943+
test_must_fail env GIT_COMMIT_GRAPH_PARANOIA=true git rev-parse HEAD~2 2>error &&
944944
grep "error: commit $oid exists in commit-graph but not in the object database" error
945945
)
946946
'

t/t6022-rev-list-missing.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ test_expect_success 'create repository and alternate directory' '
1313
test_commit 3
1414
'
1515

16+
# We manually corrupt the repository, which means that the commit-graph may
17+
# contain references to already-deleted objects. We thus need to enable
18+
# commit-graph paranoia to not returned these deleted commits from the graph.
19+
GIT_COMMIT_GRAPH_PARANOIA=true
20+
export GIT_COMMIT_GRAPH_PARANOIA
21+
1622
for obj in "HEAD~1" "HEAD~1^{tree}" "HEAD:1.t"
1723
do
1824
test_expect_success "rev-list --missing=error fails with missing object $obj" '

t/t7700-repack.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ test_expect_success 'repacking fails when missing .pack actually means missing o
271271
ls .git/objects/pack/*.pack >before-pack-dir &&
272272
273273
test_must_fail git fsck &&
274-
test_must_fail git repack --cruft -d 2>err &&
274+
test_must_fail env GIT_COMMIT_GRAPH_PARANOIA=true git repack --cruft -d 2>err &&
275275
grep "bad object" err &&
276276
277277
# Before failing, the repack did not modify the

0 commit comments

Comments
 (0)