From 25e76597fa4a282599498f883660f0f6d4251f1f Mon Sep 17 00:00:00 2001 From: Haihua Yang Date: Sat, 23 Aug 2025 00:36:30 +0000 Subject: [PATCH] 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 Signed-off-by: Haihua Yang Signed-off-by: Haihua Yang --- 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 07a1935cbe1a69..231c70f12eb463 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);