From: Derrick Stolee <dstolee@xxxxxxxxxxxxx> When any `extensions.*` setting is configured, we newly ignore it unless `core.repositoryFormatVersion` is set to a positive value. This might be quite surprising, e.g. when calling `git config --worktree [...]` elicits a warning that it requires `extensions.worktreeConfig = true` when that setting _is_ configured (but ignored because `core.repositoryFormatVersion` is unset). Let's warn about this situation specifically, especially because there might be already setups out there that configured a sparse worktree using Git v2.27.0 (which does set `extensions.worktreeConfig` but not `core.repositoryFormatVersion`) and users might want to work in those setups with Git v2.28.0, too. This warning is specifically placed inside an existing error message for 'git config --worktree' that already fails if the repository format version is not 1. Reported-by: Johannes Schindelin <johannes.schindelin@xxxxxx> Signed-off-by: Derrick Stolee <dstolee@xxxxxxxxxxxxx> --- builtin/config.c | 5 +++-- t/t2404-worktree-config.sh | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/builtin/config.c b/builtin/config.c index ee4aef6a35..2cdc293ae5 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -678,8 +678,9 @@ int cmd_config(int argc, const char **argv, const char *prefix) else if (worktrees[0] && worktrees[1]) die(_("--worktree cannot be used with multiple " "working trees unless the config\n" - "extension worktreeConfig is enabled. " - "Please read \"CONFIGURATION FILE\"\n" + "extension worktreeConfig is enabled " + "and core.repositoryFormatVersion is at least\n" + "1. Please read \"CONFIGURATION FILE\"" "section in \"git help worktree\" for details")); else given_config_source.file = git_pathdup("config"); diff --git a/t/t2404-worktree-config.sh b/t/t2404-worktree-config.sh index 9536d10919..303a2644bd 100755 --- a/t/t2404-worktree-config.sh +++ b/t/t2404-worktree-config.sh @@ -77,5 +77,17 @@ test_expect_success 'config.worktree no longer read without extension' ' test_cmp_config -C wt1 shared this.is && test_cmp_config -C wt2 shared this.is ' +test_expect_success 'show advice when extensions.* are not enabled' ' + test_config core.repositoryformatversion 1 && + test_config extensions.worktreeConfig true && + git config --worktree test.one true && + test_cmp_config true test.one && + test_config core.repositoryformatversion 0 && + test_must_fail git config --worktree test.two true 2>err && + test_i18ngrep "extension worktreeConfig is enabled" err && + git config --unset core.repositoryformatversion && + test_must_fail git config --worktree test.three true 2>err && + test_i18ngrep "core.repositoryFormatVersion is at least" err +' test_done -- gitgitgadget