git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 2/2] config: provide extra detail about worktree config

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Jul 14, 2020, 01:26 UTC
Message-ID
<e11e973c6fff6a523da090f7294234902e65a9d0.1594690017.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.674.v2.git.1594690017.gitgitgadget@gmail.com>
From: Derrick Stolee <dstolee@microsoft.com>

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@gmx.de>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
 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
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 14 of 15 in “setup: warn if extensions exist on old format”
  1. setup: warn if extensions exist on old formatDerrick Stolee via GitGitGadget, Jul 13, 2020
  2. Taylor BlauJul 13, 2020
  3. Derrick StoleeJul 13, 2020
  4. Junio C HamanoJul 13, 2020
  5. Junio C HamanoJul 13, 2020
  6. setup: tweak upgrade policy to grandfather worktreeconfigJunio C Hamano, Jul 13, 2020
  7. Derrick StoleeJul 13, 2020
  8. Junio C HamanoJul 13, 2020
  9. Jonathan NiederJul 14, 2020
  10. Junio C HamanoJul 14, 2020
  11. 0/2 setup: warn if extensions exist on old formatDerrick Stolee via GitGitGadget, Jul 14, 2020
  12. 1/2 setup: tweak upgrade policy to grandfather worktreeconfigDerrick Stolee via GitGitGadget, Jul 14, 2020
  13. Johannes SchindelinJul 14, 2020
  14. 2/2 config: provide extra detail about worktree configDerrick Stolee via GitGitGadget, Jul 14, 2020
  15. Johannes SchindelinJul 14, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.