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

[PATCH] update worktree in config.worktree if it exists

From
HGhaihuayang via GitGitGadget <gitgitgadget@gmail.com>
Date
Aug 28, 2025, 16:12 UTC
Message-ID
<pull.2035.git.git.1756397539285.gitgitgadget@gmail.com>
From: Haihua Yang <yanghh@gmail.com>
When updating submodule core.worktree configuration
- If config.worktree exists in the submodule's gitdir, write to that file
- Otherwise, write to the commondir/config file
Signed-off-by: Haihua Yang <yanghh@gmail.com>
Signed-off-by: Haihua Yang <yanghh@gmail.com>
---
    update worktree in config.worktree if it exists
    
    When updating submodule core.worktree configuration
    
     * If config.worktree exists in the submodule's gitdir, write to that
       file
     * Otherwise, write to the commondir/config file
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2035%2Fhaihuayang%2Fmaster-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2035/haihuayang/master-v1
Pull-Request: https://github.com/git/git/pull/2035
 builtin/submodule--helper.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 07a1935cbe..231c70f12e 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -2519,7 +2519,12 @@ static int ensure_core_worktree(const char *path)
 		const char *rel_path;
 		struct strbuf sb = STRBUF_INIT;
 
-		cfg_file = repo_git_path(&subrepo, "config");
+		/* Use config.worktree if it exists, otherwise use config */
+		cfg_file = repo_git_path(&subrepo, "config.worktree");
+		if (access(cfg_file, F_OK) != 0) {
+			free(cfg_file);
+			cfg_file = repo_git_path(&subrepo, "config");
+		}
 
 		abs_path = absolute_pathdup(path);
 		rel_path = relative_path(abs_path, subrepo.gitdir, &sb);

base-commit: 1fa68948c3d76328236cac73d2adf33c905bd8e3
-- 
gitgitgadget
Message 1 of 1 in “update worktree in config.worktree if it exists”
  1. update worktree in config.worktree if it existshaihuayang via GitGitGadget, Aug 28, 2025

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.