Commit 94751ada authored by Duy Nguyen's avatar Duy Nguyen

submodule ensure-core-worktree: write to config.worktree

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.
parent 3a103531
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment