repo-settings: create feature.manyFiles setting
authorDerrick Stolee <dstolee@microsoft.com>
Tue, 13 Aug 2019 18:37:47 +0000 (11:37 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Aug 2019 20:33:55 +0000 (13:33 -0700)
The feature.manyFiles setting is suitable for repos with many
files in the working directory. By setting index.version=4 and
core.untrackedCache=true, commands such as 'git status' should
improve.

While adding this setting, modify the index version precedence
tests to check how this setting overrides the default for
index.version is unset.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config.txt
Documentation/config/core.txt
Documentation/config/feature.txt [new file with mode: 0644]
Documentation/config/index.txt
repo-settings.c
t/t1600-index.sh
index e3f5bc3396d0c7502f16eed989220c8e2010bcc1..77f3b1486b78ab81e1248e1a6cfb651c9e17fd85 100644 (file)
@@ -345,6 +345,8 @@ include::config/difftool.txt[]
 
 include::config/fastimport.txt[]
 
+include::config/feature.txt[]
+
 include::config/fetch.txt[]
 
 include::config/format.txt[]
index e66d79fd76059fd953aa9baec928603389cd8455..852d2ba37a1204e0e210e9abf671d7f0c9c850d8 100644 (file)
@@ -86,7 +86,9 @@ core.untrackedCache::
        it will automatically be removed, if set to `false`. Before
        setting it to `true`, you should check that mtime is working
        properly on your system.
-       See linkgit:git-update-index[1]. `keep` by default.
+       See linkgit:git-update-index[1]. `keep` by default, unless
+       `feature.manyFiles` is enabled which sets this setting to
+       `true` by default.
 
 core.checkStat::
        When missing or is set to `default`, many fields in the stat
diff --git a/Documentation/config/feature.txt b/Documentation/config/feature.txt
new file mode 100644 (file)
index 0000000..8ea198a
--- /dev/null
@@ -0,0 +1,15 @@
+feature.*::
+       The config settings that start with `feature.` modify the defaults of
+       a group of other config settings. These groups are created by the Git
+       developer community as recommended defaults and are subject to change.
+       In particular, new config options may be added with different defaults.
+
+feature.manyFiles::
+       Enable config options that optimize for repos with many files in the
+       working directory. With many files, commands such as `git status` and
+       `git checkout` may be slow and these new defaults improve performance:
++
+* `index.version=4` enables path-prefix compression in the index.
++
+* `core.untrackedCache=true` enables the untracked cache. This setting assumes
+that mtime is working on your machine.
index f18150304106891ad388a7620594937b43e7615e..7cb50b37e98dba813886adb4578435495be8e78c 100644 (file)
@@ -24,3 +24,4 @@ index.threads::
 index.version::
        Specify the version with which new index files should be
        initialized.  This does not affect existing repositories.
+       If `feature.manyFiles` is enabled, then the default is 4.
index abbc6566f8fb7da1e76f17fd1b53d0a5f4889f38..d5bf9069f4ae31a54d53823b27f702bf66fefbee 100644 (file)
@@ -36,9 +36,12 @@ void prepare_repo_settings(struct repository *r)
                free(strval);
        }
 
-
        if (!repo_config_get_bool(r, "pack.usesparse", &value))
                r->settings.pack_use_sparse = value;
+       if (!repo_config_get_bool(r, "feature.manyfiles", &value) && value) {
+               UPDATE_DEFAULT_BOOL(r->settings.index_version, 4);
+               UPDATE_DEFAULT_BOOL(r->settings.core_untracked_cache, UNTRACKED_CACHE_WRITE);
+       }
 
        /* Hack for test programs like test-dump-untracked-cache */
        if (ignore_untracked_cache_config)
index 42962ed7d46f6dafa09c7b276942c32da130e300..c77721b580c1535de33f3bd109c95bb52200a691 100755 (executable)
@@ -59,17 +59,38 @@ test_expect_success 'out of bounds index.version issues warning' '
        )
 '
 
-test_expect_success 'GIT_INDEX_VERSION takes precedence over config' '
+test_index_version () {
+       INDEX_VERSION_CONFIG=$1 &&
+       FEATURE_MANY_FILES=$2 &&
+       ENV_VAR_VERSION=$3
+       EXPECTED_OUTPUT_VERSION=$4 &&
        (
                rm -f .git/index &&
-               GIT_INDEX_VERSION=4 &&
-               export GIT_INDEX_VERSION &&
-               git config --add index.version 2 &&
+               rm -f .git/config &&
+               if test "$INDEX_VERSION_CONFIG" -ne 0
+               then
+                       git config --add index.version $INDEX_VERSION_CONFIG
+               fi &&
+               git config --add feature.manyFiles $FEATURE_MANY_FILES
+               if test "$ENV_VAR_VERSION" -ne 0
+               then
+                       GIT_INDEX_VERSION=$ENV_VAR_VERSION &&
+                       export GIT_INDEX_VERSION
+               else
+                       unset GIT_INDEX_VERSION
+               fi &&
                git add a 2>&1 &&
-               echo 4 >expect &&
+               echo $EXPECTED_OUTPUT_VERSION >expect &&
                test-tool index-version <.git/index >actual &&
                test_cmp expect actual
        )
+}
+
+test_expect_success 'index version config precedence' '
+       test_index_version 2 false 4 4 &&
+       test_index_version 2 true 0 2 &&
+       test_index_version 0 true 0 4 &&
+       test_index_version 0 true 2 2
 '
 
 test_done