Skip to content

Commit 31b1de6

Browse files
derrickstoleegitster
authored andcommitted
commit-graph: turn on commit-graph by default
The commit-graph feature has seen a lot of activity in the past year or so since it was introduced. The feature is a critical performance enhancement for medium- to large-sized repos, and does not significantly hurt small repos. Change the defaults for core.commitGraph and gc.writeCommitGraph to true so users benefit from this feature by default. There are several places in the test suite where the environment variable GIT_TEST_COMMIT_GRAPH is disabled to avoid reading a commit-graph, if it exists. The config option overrides the environment, so swap these. Some GIT_TEST_COMMIT_GRAPH assignments remain, and those are to avoid writing a commit-graph when a new commit is created. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b068d9a commit 31b1de6

File tree

7 files changed

+12
-6
lines changed

7 files changed

+12
-6
lines changed

Documentation/config/core.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ the `GIT_NOTES_REF` environment variable. See linkgit:git-notes[1].
577577

578578
core.commitGraph::
579579
If true, then git will read the commit-graph file (if it exists)
580-
to parse the graph structure of commits. Defaults to false. See
580+
to parse the graph structure of commits. Defaults to true. See
581581
linkgit:git-commit-graph[1] for more information.
582582

583583
core.useReplaceRefs::

Documentation/config/gc.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ gc.writeCommitGraph::
6363
If true, then gc will rewrite the commit-graph file when
6464
linkgit:git-gc[1] is run. When using `git gc --auto`
6565
the commit-graph will be updated if housekeeping is
66-
required. Default is false. See linkgit:git-commit-graph[1]
66+
required. Default is true. See linkgit:git-commit-graph[1]
6767
for details.
6868

6969
gc.logExpiry::

repo-settings.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include "config.h"
33
#include "repository.h"
44

5+
#define UPDATE_DEFAULT_BOOL(s,v) do { if (s == -1) { s = v; } } while(0)
6+
57
void prepare_repo_settings(struct repository *r)
68
{
79
int value;
@@ -16,6 +18,8 @@ void prepare_repo_settings(struct repository *r)
1618
r->settings.core_commit_graph = value;
1719
if (!repo_config_get_bool(r, "gc.writecommitgraph", &value))
1820
r->settings.gc_write_commit_graph = value;
21+
UPDATE_DEFAULT_BOOL(r->settings.core_commit_graph, 1);
22+
UPDATE_DEFAULT_BOOL(r->settings.gc_write_commit_graph, 1);
1923

2024
if (!repo_config_get_bool(r, "index.version", &value))
2125
r->settings.index_version = value;

t/t0410-partial-clone.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ test_expect_success 'rev-list stops traversal at missing and promised commit' '
234234
235235
git -C repo config core.repositoryformatversion 1 &&
236236
git -C repo config extensions.partialclone "arbitrary string" &&
237-
GIT_TEST_COMMIT_GRAPH=0 git -C repo rev-list --exclude-promisor-objects --objects bar >out &&
237+
GIT_TEST_COMMIT_GRAPH=0 git -C repo -c core.commitGraph=false rev-list --exclude-promisor-objects --objects bar >out &&
238238
grep $(git -C repo rev-parse bar) out &&
239239
! grep $FOO out
240240
'

t/t5307-pack-missing-commit.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ test_expect_success 'check corruption' '
2424
'
2525

2626
test_expect_success 'rev-list notices corruption (1)' '
27-
test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git rev-list HEAD
27+
test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git -c core.commitGraph=false rev-list HEAD
2828
'
2929

3030
test_expect_success 'rev-list notices corruption (2)' '
31-
test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git rev-list --objects HEAD
31+
test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git -c core.commitGraph=false rev-list --objects HEAD
3232
'
3333

3434
test_expect_success 'pack-objects notices corruption' '

t/t5324-split-commit-graph.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ GIT_TEST_COMMIT_GRAPH=0
88
test_expect_success 'setup repo' '
99
git init &&
1010
git config core.commitGraph true &&
11+
git config gc.writeCommitGraph false &&
1112
infodir=".git/objects/info" &&
1213
graphdir="$infodir/commit-graphs" &&
1314
test_oid_init
@@ -332,6 +333,7 @@ test_expect_success 'split across alternate where alternate is not split' '
332333
git clone --no-hardlinks . alt-split &&
333334
(
334335
cd alt-split &&
336+
rm -f .git/objects/info/commit-graph &&
335337
echo "$(pwd)"/../.git/objects >.git/objects/info/alternates &&
336338
test_commit 18 &&
337339
git commit-graph write --reachable --split &&

t/t6011-rev-list-with-bad-commit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ test_expect_success 'corrupt second commit object' \
4242
'
4343

4444
test_expect_success 'rev-list should fail' '
45-
test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git rev-list --all > /dev/null
45+
test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git -c core.commitGraph=false rev-list --all > /dev/null
4646
'
4747

4848
test_expect_success 'git repack _MUST_ fail' \

0 commit comments

Comments
 (0)