{"thread":{"id":"64054","subject":"[PATCH] update worktree in config.worktree if it exists","startedAt":"2025-08-28T16:12:22Z","lastAt":"2025-08-28T16:12:22Z","messageCount":1,"participants":["haihuayang via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"525117","messageId":"pull.2035.git.git.1756397539285.gitgitgadget@gmail.com","threadId":"64054","inReplyTo":null,"subject":"[PATCH] update worktree in config.worktree if it exists","fromName":"haihuayang via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-08-28T16:12:19Z","receivedAt":"2025-08-28T16:12:22Z","isPatch":true,"sender":{"key":"name:haihuayang","avatar":null},"body":"From: Haihua Yang <yanghh@gmail.com>\n\nWhen updating submodule core.worktree configuration\n- If config.worktree exists in the submodule's gitdir, write to that file\n- Otherwise, write to the commondir/config file\n\nSigned-off-by: Haihua Yang <yanghh@gmail.com>\n\nSigned-off-by: Haihua Yang <yanghh@gmail.com>\n---\n    update worktree in config.worktree if it exists\n    \n    When updating submodule core.worktree configuration\n    \n     * If config.worktree exists in the submodule's gitdir, write to that\n       file\n     * Otherwise, write to the commondir/config file\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2035%2Fhaihuayang%2Fmaster-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2035/haihuayang/master-v1\nPull-Request: https://github.com/git/git/pull/2035\n\n builtin/submodule--helper.c | 7 ++++++-\n 1 file changed, 6 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 07a1935cbe..231c70f12e 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -2519,7 +2519,12 @@ static int ensure_core_worktree(const char *path)\n \t\tconst char *rel_path;\n \t\tstruct strbuf sb = STRBUF_INIT;\n \n-\t\tcfg_file = repo_git_path(&subrepo, \"config\");\n+\t\t/* Use config.worktree if it exists, otherwise use config */\n+\t\tcfg_file = repo_git_path(&subrepo, \"config.worktree\");\n+\t\tif (access(cfg_file, F_OK) != 0) {\n+\t\t\tfree(cfg_file);\n+\t\t\tcfg_file = repo_git_path(&subrepo, \"config\");\n+\t\t}\n \n \t\tabs_path = absolute_pathdup(path);\n \t\trel_path = relative_path(abs_path, subrepo.gitdir, &sb);\n\nbase-commit: 1fa68948c3d76328236cac73d2adf33c905bd8e3\n-- \ngitgitgadget\n"}]}