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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]