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

[PATCH 10/10] submodule ensure-core-worktree: write to config.worktree

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jan 16, 2019, 10:31 UTC
Message-ID
<20190116103159.9305-11-pclouds@gmail.com>
In-Reply-To
<20190116103159.9305-1-pclouds@gmail.com>

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(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 8a12d2f0ed..890de5902c 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -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);
 	}
-- 
2.20.0.482.g66447595a7
Previous: Nguyễn Thái Ngọc Duy
Message 14 of 14 in “Support using submodules with worktrees”
  1. 00/10 Support using submodules with worktreesNguyễn Thái Ngọc Duy, Jan 16, 2019
  2. 01/10 doc: about submodule support with multiple worktreesNguyễn Thái Ngọc Duy, Jan 16, 2019
  3. Stefan BellerJan 16, 2019
  4. Duy NguyenJan 17, 2019
  5. 02/10 submodule--helper: add missing \nNguyễn Thái Ngọc Duy, Jan 16, 2019
  6. 03/10 submodule add: support multiple worktreesNguyễn Thái Ngọc Duy, Jan 16, 2019
  7. Stefan BellerJan 16, 2019
  8. 04/10 submodule init: support multiple worktreesNguyễn Thái Ngọc Duy, Jan 16, 2019
  9. 05/10 submodule update: add tests for multiple worktreesNguyễn Thái Ngọc Duy, Jan 16, 2019
  10. 06/10 submodule sync: support multiple worktreesNguyễn Thái Ngọc Duy, Jan 16, 2019
  11. 07/10 submodule deinit: support multiple worktreesNguyễn Thái Ngọc Duy, Jan 16, 2019
  12. 08/10 submodule clone: use repo_config_set()Nguyễn Thái Ngọc Duy, Jan 16, 2019
  13. 09/10 submodule clone: propagate extensions.worktreeConfigNguyễn Thái Ngọc Duy, Jan 16, 2019
  14. 10/10 submodule ensure-core-worktree: write to config.worktreeNguyễn Thái Ngọc Duy, Jan 16, 2019

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.