@@ -2063,18 +2063,16 @@ static int ensure_core_worktree(int argc, const char **argv, const char *prefix)
die(_("could not get a repository handle for submodule '%s'"), path);
if (!repo_config_get_string(&subrepo, "core.worktree", &cw)) {
- char *cfg_file, *abs_path;
+ char *abs_path;
const char *rel_path;
struct strbuf sb = STRBUF_INIT;
- cfg_file = repo_git_path(&subrepo, "config");
-
abs_path = absolute_pathdup(path);
rel_path = relative_path(abs_path, subrepo.gitdir, &sb);
- git_config_set_in_file(cfg_file, "core.worktree", rel_path);
+ if (repo_config_set_worktree_gently(&subrepo, "core.worktree", rel_path))
+ die(_("could not set '%s' to '%s'"), "core.worktree", rel_path);
- free(cfg_file);
free(abs_path);
strbuf_release(&sb);
}
Use repo_config_set_worktree_gently() to write core.worktree. If the submodule has extensions.worktreeConfig on, the key will be in config.worktree instead of config file and not affect any new submodule's worktrees. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> --- builtin/submodule--helper.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)