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

[PATCH 2/3] setup: add worktree.path to shadow core.worktree

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Feb 8, 2015, 13:16 UTC
Message-ID
<1423401394-13675-3-git-send-email-pclouds@gmail.com>
In-Reply-To
<1423401394-13675-1-git-send-email-pclouds@gmail.com>

They have the same purpose. But they are located in different places: core.worktree in $GIT_DIR/config while worktree.path in $GIT_DIR/config.worktree

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Documentation/config.txt | 3 +++
 setup.c                  | 7 ++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 26e4e07..b717881 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -410,6 +410,7 @@ false), while all other repositories are assumed to be bare (bare
 = true).
 
 core.worktree::
+worktree.path::
 	Set the path to the root of the working tree.
 	This can be overridden by the GIT_WORK_TREE environment
 	variable and the '--work-tree' command-line option.
@@ -430,6 +431,8 @@ still use "/different/path" as the root of the work tree and can cause
 confusion unless you know what you are doing (e.g. you are creating a
 read-only snapshot of the same index to a location different from the
 repository's usual working tree).
++
+worktree.path takes precedence over core.worktree.
 
 core.logAllRefUpdates::
 	Enable the reflog. Updates to a ref <ref> is logged to the file
diff --git a/setup.c b/setup.c
index 979b13f..bc27f8b 100644
--- a/setup.c
+++ b/setup.c
@@ -4,6 +4,7 @@
 
 static int inside_git_dir = -1;
 static int inside_work_tree = -1;
+static int worktree_path_set;
 
 /*
  * The input parameter must contain an absolute path, and it must already be
@@ -807,12 +808,16 @@ int check_repository_format_version(const char *var, const char *value, void *cb
 		is_bare_repository_cfg = git_config_bool(var, value);
 		if (is_bare_repository_cfg == 1)
 			inside_work_tree = -1;
-	} else if (strcmp(var, "core.worktree") == 0) {
+	} else if (strcmp(var, "worktree.path") == 0 ||
+		   (strcmp(var, "core.worktree") == 0 &&
+		    !worktree_path_set)) {
 		if (!value)
 			return config_error_nonbool(var);
 		free(git_work_tree_cfg);
 		git_work_tree_cfg = xstrdup(value);
 		inside_work_tree = -1;
+		if (!strcmp(var, "worktree.path"))
+			worktree_path_set = 1;
 	}
 	return 0;
 }
-- 
2.3.0.rc1.137.g477eb31
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 3 of 22 in “worktree.* config keys and submodule and multiple worktrees”
  1. 0/3 worktree.* config keys and submodule and multiple worktreesNguyễn Thái Ngọc Duy, Feb 8, 2015
  2. 1/3 config.c: new config namespace worktree.* stored in $GIT_DIR/config.worktreeNguyễn Thái Ngọc Duy, Feb 8, 2015
  3. 2/3 setup: add worktree.path to shadow core.worktreeNguyễn Thái Ngọc Duy, Feb 8, 2015
  4. 3/3 submodule: use worktree.path instead of core.worktreeNguyễn Thái Ngọc Duy, Feb 8, 2015
  5. Jens LehmannFeb 8, 2015
  6. Jens LehmannFeb 8, 2015
  7. Duy NguyenFeb 9, 2015
  8. per-repository and per-worktree config variablesMax Kirillov, Mar 18, 2015
  9. Duy NguyenMar 24, 2015
  10. config.c: split some variables to $GIT_DIR/config.worktreeNguyễn Thái Ngọc Duy, Mar 26, 2015
  11. Max KirillovMar 26, 2015
  12. Duy NguyenMar 29, 2015
  13. Max KirillovMar 30, 2015
  14. config.c: split some variables to $GIT_DIR/config.worktreeNguyễn Thái Ngọc Duy, Mar 31, 2015
  15. Duy NguyenMar 31, 2015
  16. Max KirillovApr 1, 2015
  17. Duy NguyenApr 3, 2015
  18. Max KirillovApr 13, 2015
  19. Duy NguyenApr 18, 2015
  20. Max KirillovApr 20, 2015
  21. Duy NguyenApr 20, 2015
  22. Jens LehmannMar 25, 2015

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.