commit-graph: turn on commit-graph by default
authorDerrick Stolee <dstolee@microsoft.com>
Tue, 13 Aug 2019 18:37:45 +0000 (11:37 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Aug 2019 20:33:55 +0000 (13:33 -0700)
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>
Documentation/config/core.txt
Documentation/config/gc.txt
repo-settings.c
t/t0410-partial-clone.sh
t/t5307-pack-missing-commit.sh
t/t5324-split-commit-graph.sh
t/t6011-rev-list-with-bad-commit.sh
index 75538d27e7e06b2041f556dc5e3fcd4aef1abf20..e66d79fd76059fd953aa9baec928603389cd8455 100644 (file)
@@ -577,7 +577,7 @@ the `GIT_NOTES_REF` environment variable.  See linkgit:git-notes[1].
 
 core.commitGraph::
        If true, then git will read the commit-graph file (if it exists)
-       to parse the graph structure of commits. Defaults to false. See
+       to parse the graph structure of commits. Defaults to true. See
        linkgit:git-commit-graph[1] for more information.
 
 core.useReplaceRefs::
index 02b92b18b5c2cf6f9d509483a4bb995f3677d519..00ea0a678ee214f86cc91b27389572698d35bece 100644 (file)
@@ -63,7 +63,7 @@ gc.writeCommitGraph::
        If true, then gc will rewrite the commit-graph file when
        linkgit:git-gc[1] is run. When using `git gc --auto`
        the commit-graph will be updated if housekeeping is
-       required. Default is false. See linkgit:git-commit-graph[1]
+       required. Default is true. See linkgit:git-commit-graph[1]
        for details.
 
 gc.logExpiry::
index 309577f6bceeab4a436e64b49a011061863af02e..d00b675687418e7cf0915f8d577f3685fee7e507 100644 (file)
@@ -2,6 +2,8 @@
 #include "config.h"
 #include "repository.h"
 
+#define UPDATE_DEFAULT_BOOL(s,v) do { if (s == -1) { s = v; } } while(0)
+
 void prepare_repo_settings(struct repository *r)
 {
        int value;
@@ -16,6 +18,8 @@ void prepare_repo_settings(struct repository *r)
                r->settings.core_commit_graph = value;
        if (!repo_config_get_bool(r, "gc.writecommitgraph", &value))
                r->settings.gc_write_commit_graph = value;
+       UPDATE_DEFAULT_BOOL(r->settings.core_commit_graph, 1);
+       UPDATE_DEFAULT_BOOL(r->settings.gc_write_commit_graph, 1);
 
        if (!repo_config_get_bool(r, "index.version", &value))
                r->settings.index_version = value;
index 5bd892f2f7a90ac9e35993c137e0addd10d17bde..181ffa44e9067072c89ef230446f3c2222efdedc 100755 (executable)
@@ -234,7 +234,7 @@ test_expect_success 'rev-list stops traversal at missing and promised commit' '
 
        git -C repo config core.repositoryformatversion 1 &&
        git -C repo config extensions.partialclone "arbitrary string" &&
-       GIT_TEST_COMMIT_GRAPH=0 git -C repo rev-list --exclude-promisor-objects --objects bar >out &&
+       GIT_TEST_COMMIT_GRAPH=0 git -C repo -c core.commitGraph=false rev-list --exclude-promisor-objects --objects bar >out &&
        grep $(git -C repo rev-parse bar) out &&
        ! grep $FOO out
 '
index dacb440b2750e40b393a200229a9ee968f12ccd3..f4338abb78a83967a1bdc6b264600262a0f94d65 100755 (executable)
@@ -24,11 +24,11 @@ test_expect_success 'check corruption' '
 '
 
 test_expect_success 'rev-list notices corruption (1)' '
-       test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git rev-list HEAD
+       test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git -c core.commitGraph=false rev-list HEAD
 '
 
 test_expect_success 'rev-list notices corruption (2)' '
-       test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git rev-list --objects HEAD
+       test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git -c core.commitGraph=false rev-list --objects HEAD
 '
 
 test_expect_success 'pack-objects notices corruption' '
index 03f45a1ed9023c2b3371bdac70f7abadd14b4202..19aa40de15c70c391d30a4a23b50240c631b6430 100755 (executable)
@@ -8,6 +8,7 @@ GIT_TEST_COMMIT_GRAPH=0
 test_expect_success 'setup repo' '
        git init &&
        git config core.commitGraph true &&
+       git config gc.writeCommitGraph false &&
        infodir=".git/objects/info" &&
        graphdir="$infodir/commit-graphs" &&
        test_oid_init
@@ -332,6 +333,7 @@ test_expect_success 'split across alternate where alternate is not split' '
        git clone --no-hardlinks . alt-split &&
        (
                cd alt-split &&
+               rm -f .git/objects/info/commit-graph &&
                echo "$(pwd)"/../.git/objects >.git/objects/info/alternates &&
                test_commit 18 &&
                git commit-graph write --reachable --split &&
index 545b461e51d4fd5df39c7d27953fb0f26f73e052..bad02cf5b83dbc014c23cc8ac66135e0cf095138 100755 (executable)
@@ -42,7 +42,7 @@ test_expect_success 'corrupt second commit object' \
    '
 
 test_expect_success 'rev-list should fail' '
-       test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git rev-list --all > /dev/null
+       test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git -c core.commitGraph=false rev-list --all > /dev/null
 '
 
 test_expect_success 'git repack _MUST_ fail' \