Skip to content

Commit 082fc57

Browse files
committed
repo-settings: create feature.manyFiles setting
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 <[email protected]>
1 parent ec0abff commit 082fc57

File tree

6 files changed

+51
-7
lines changed

6 files changed

+51
-7
lines changed

Documentation/config.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ include::config/difftool.txt[]
345345

346346
include::config/fastimport.txt[]
347347

348+
include::config/feature.txt[]
349+
348350
include::config/fetch.txt[]
349351

350352
include::config/format.txt[]

Documentation/config/core.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ core.untrackedCache::
8686
it will automatically be removed, if set to `false`. Before
8787
setting it to `true`, you should check that mtime is working
8888
properly on your system.
89-
See linkgit:git-update-index[1]. `keep` by default.
89+
See linkgit:git-update-index[1]. `keep` by default, unless
90+
`feature.manyFiles` is enabled which sets this setting to
91+
`true` by default.
9092

9193
core.checkStat::
9294
When missing or is set to `default`, many fields in the stat

Documentation/config/feature.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
feature.*::
2+
The config settings that start with `feature.` modify the defaults of
3+
a group of other config settings. These groups are created by the Git
4+
developer community as recommended defaults and are subject to change.
5+
In particular, new config options may be added with different defaults.
6+
7+
feature.manyFiles::
8+
Enable config options that optimize for repos with many files in the
9+
working directory. With many files, commands such as `git status` and
10+
`git checkout` may be slow and these new defaults improve performance:
11+
+
12+
* `index.version=4` enables path-prefix compression in the index.
13+
+
14+
* `core.untrackedCache=true` enables the untracked cache. This setting assumes
15+
that mtime is working on your machine.

Documentation/config/index.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ index.threads::
2424
index.version::
2525
Specify the version with which new index files should be
2626
initialized. This does not affect existing repositories.
27+
If `feature.manyFiles` is enabled, then the default is 4.

repo-settings.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@ void prepare_repo_settings(struct repository *r)
3636
free(strval);
3737
}
3838

39-
4039
if (!repo_config_get_bool(r, "pack.usesparse", &value))
4140
r->settings.pack_use_sparse = value;
41+
if (!repo_config_get_bool(r, "feature.manyfiles", &value) && value) {
42+
UPDATE_DEFAULT_BOOL(r->settings.index_version, 4);
43+
UPDATE_DEFAULT_BOOL(r->settings.core_untracked_cache, UNTRACKED_CACHE_WRITE);
44+
}
4245

4346
/* Hack for test programs like test-dump-untracked-cache */
4447
if (ignore_untracked_cache_config)

t/t1600-index.sh

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,38 @@ test_expect_success 'out of bounds index.version issues warning' '
5959
)
6060
'
6161

62-
test_expect_success 'GIT_INDEX_VERSION takes precedence over config' '
62+
test_index_version () {
63+
INDEX_VERSION_CONFIG=$1 &&
64+
FEATURE_MANY_FILES=$2 &&
65+
ENV_VAR_VERSION=$3
66+
EXPECTED_OUTPUT_VERSION=$4 &&
6367
(
6468
rm -f .git/index &&
65-
GIT_INDEX_VERSION=4 &&
66-
export GIT_INDEX_VERSION &&
67-
git config --add index.version 2 &&
69+
rm -f .git/config &&
70+
if test "$INDEX_VERSION_CONFIG" -ne 0
71+
then
72+
git config --add index.version $INDEX_VERSION_CONFIG
73+
fi &&
74+
git config --add feature.manyFiles $FEATURE_MANY_FILES
75+
if test "$ENV_VAR_VERSION" -ne 0
76+
then
77+
GIT_INDEX_VERSION=$ENV_VAR_VERSION &&
78+
export GIT_INDEX_VERSION
79+
else
80+
unset GIT_INDEX_VERSION
81+
fi &&
6882
git add a 2>&1 &&
69-
echo 4 >expect &&
83+
echo $EXPECTED_OUTPUT_VERSION >expect &&
7084
test-tool index-version <.git/index >actual &&
7185
test_cmp expect actual
7286
)
87+
}
88+
89+
test_expect_success 'index version config precedence' '
90+
test_index_version 2 false 4 4 &&
91+
test_index_version 2 true 0 2 &&
92+
test_index_version 0 true 0 4 &&
93+
test_index_version 0 true 2 2
7394
'
7495

7596
test_done

0 commit comments

Comments
 (0)