]> git.ipfire.org Git - thirdparty/git.git/commitdiff
repo-settings: read an int for index.version
authorDerrick Stolee <dstolee@microsoft.com>
Wed, 23 Oct 2019 20:38:57 +0000 (20:38 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 24 Oct 2019 02:33:45 +0000 (11:33 +0900)
Several config options were combined into a repo_settings struct in
ds/feature-macros, including a move of the "index.version" config
setting in 7211b9e (repo-settings: consolidate some config settings,
2019-08-13).

Unfortunately, that file looked like a lot of boilerplate and what is
clearly a factor of copy-paste overload, the config setting is parsed
with repo_config_ge_bool() instead of repo_config_get_int(). This means
that a setting "index.version=4" would not register correctly and would
revert to the default version of 3.

I caught this while incorporating v2.24.0-rc0 into the VFS for Git
codebase, where we really care that the index is in version 4.

This was not caught by the codebase because the version checks placed
in t1600-index.sh did not test the "basic" scenario enough. Here, we
modify the test to include these normal settings to not be overridden by
features.manyFiles or GIT_INDEX_VERSION. While the "default" version is
3, this is demoted to version 2 in do_write_index() when not necessary.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
repo-settings.c
t/t1600-index.sh

index 3779b85c17532c7f51de0ae6e28208e3ca2c9c8e..3fed31ecf9deede2d91bd63cd4eb8db5d6427f71 100644 (file)
@@ -22,7 +22,7 @@ void prepare_repo_settings(struct repository *r)
        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))
+       if (!repo_config_get_int(r, "index.version", &value))
                r->settings.index_version = value;
        if (!repo_config_get_maybe_bool(r, "core.untrackedcache", &value)) {
                if (value == 0)
index c77721b580c1535de33f3bd109c95bb52200a691..b7c31aa86a11ffbecd7c82a3ab3e920105caf71f 100755 (executable)
@@ -87,6 +87,10 @@ test_index_version () {
 }
 
 test_expect_success 'index version config precedence' '
+       test_index_version 0 false 0 2 &&
+       test_index_version 2 false 0 2 &&
+       test_index_version 3 false 0 2 &&
+       test_index_version 4 false 0 4 &&
        test_index_version 2 false 4 4 &&
        test_index_version 2 true 0 2 &&
        test_index_version 0 true 0 4 &&