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 <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Aug 13, 2019 at 11:37 UTC 31b1de6a09bad59cc0d88419925486afc7add277
7 files changed +12 -6
Documentation/config/core.txt
+1 -1
@@ -577,7 +577,7 @@ the `GIT_NOTES_REF` environment variable. See linkgit:git-notes[1].
577
578 core.commitGraph::
579 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
581 linkgit:git-commit-graph[1] for more information.
582
583 core.useReplaceRefs::
Documentation/config/gc.txt
+1 -1
@@ -63,7 +63,7 @@ gc.writeCommitGraph::
63 If true, then gc will rewrite the commit-graph file when
64 linkgit:git-gc[1] is run. When using `git gc --auto`
65 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]
67 for details.
68
69 gc.logExpiry::
repo-settings.c
+4
@@ -2,6 +2,8 @@
2 #include "config.h"
3 #include "repository.h"
4
5 +#define UPDATE_DEFAULT_BOOL(s,v) do { if (s == -1) { s = v; } } while(0)
6 +
7 void prepare_repo_settings(struct repository *r)
8 {
9 int value;
@@ -16,6 +18,8 @@ void prepare_repo_settings(struct repository *r)
18 r->settings.core_commit_graph = value;
19 if (!repo_config_get_bool(r, "gc.writecommitgraph", &value))
20 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);
23
24 if (!repo_config_get_bool(r, "index.version", &value))
25 r->settings.index_version = value;
t/t0410-partial-clone.sh
+1 -1
@@ -234,7 +234,7 @@ test_expect_success 'rev-list stops traversal at missing and promised commit' '
234
235 git -C repo config core.repositoryformatversion 1 &&
236 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 &&
238 grep $(git -C repo rev-parse bar) out &&
239 ! grep $FOO out
240 '
t/t5307-pack-missing-commit.sh
+2 -2
@@ -24,11 +24,11 @@ test_expect_success 'check corruption' '
24 '
25
26 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
28 '
29
30 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
32 '
33
34 test_expect_success 'pack-objects notices corruption' '
t/t5324-split-commit-graph.sh
+2
@@ -8,6 +8,7 @@ GIT_TEST_COMMIT_GRAPH=0
8 test_expect_success 'setup repo' '
9 git init &&
10 git config core.commitGraph true &&
11 + git config gc.writeCommitGraph false &&
12 infodir=".git/objects/info" &&
13 graphdir="$infodir/commit-graphs" &&
14 test_oid_init
@@ -332,6 +333,7 @@ test_expect_success 'split across alternate where alternate is not split' '
333 git clone --no-hardlinks . alt-split &&
334 (
335 cd alt-split &&
336 + rm -f .git/objects/info/commit-graph &&
337 echo "$(pwd)"/../.git/objects >.git/objects/info/alternates &&
338 test_commit 18 &&
339 git commit-graph write --reachable --split &&
t/t6011-rev-list-with-bad-commit.sh
+1 -1
@@ -42,7 +42,7 @@ test_expect_success 'corrupt second commit object' \
42 '
43
44 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
46 '
47
48 test_expect_success 'git repack _MUST_ fail' \