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

[PATCH 3/3] submodule: use worktree.path instead of core.worktree

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Feb 8, 2015, 13:16 UTC
Message-ID
<1423401394-13675-4-git-send-email-pclouds@gmail.com>
In-Reply-To
<1423401394-13675-1-git-send-email-pclouds@gmail.com>
This opens a door of using submodule with multiple worktrees
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 git-submodule.sh                       | 2 +-
 submodule.c                            | 6 +++---
 t/lib-submodule-update.sh              | 8 ++++----
 t/t7400-submodule-basic.sh             | 4 ++--
 t/t7409-submodule-detached-worktree.sh | 6 +++---
 5 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index 9245abf..6e9e1d1 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -309,7 +309,7 @@ module_clone()
 	printf '%s\n' "gitdir: $rel/$a" >"$sm_path/.git"
 
 	rel=$(printf '%s\n' "$a" | sed -e 's|[^/][^/]*|..|g')
-	(clear_local_git_env; cd "$sm_path" && GIT_WORK_TREE=. git config core.worktree "$rel/$b")
+	(clear_local_git_env; cd "$sm_path" && GIT_WORK_TREE=. git config worktree.path "$rel/$b")
 }
 
 isnumber()
diff --git a/submodule.c b/submodule.c
index d37d400..f886fa6 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1115,11 +1115,11 @@ void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir)
 
 	/* Update core.worktree setting */
 	strbuf_reset(&file_name);
-	strbuf_addf(&file_name, "%s/config", git_dir);
-	if (git_config_set_in_file(file_name.buf, "core.worktree",
+	strbuf_addf(&file_name, "%s/config.worktree", git_dir);
+	if (git_config_set_in_file(file_name.buf, "worktree.path",
 				   relative_path(real_work_tree, git_dir,
 						 &rel_path)))
-		die(_("Could not set core.worktree in %s"),
+		die(_("Could not set worktree.path in %s"),
 		    file_name.buf);
 
 	strbuf_release(&file_name);
diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh
index 79cdd34..ce140cf 100755
--- a/t/lib-submodule-update.sh
+++ b/t/lib-submodule-update.sh
@@ -105,7 +105,7 @@ replace_gitfile_with_git_dir () {
 		git_dir="$(git rev-parse --git-dir)" &&
 		rm -f .git &&
 		cp -R "$git_dir" .git &&
-		GIT_WORK_TREE=. git config --unset core.worktree
+		GIT_WORK_TREE=. git config --unset worktree.path
 	)
 }
 
@@ -120,16 +120,16 @@ test_git_directory_is_unchanged () {
 	(
 		cd ".git/modules/$1" &&
 		# does core.worktree point at the right place?
-		test "$(git config core.worktree)" = "../../../$1" &&
+		test "$(git config worktree.path)" = "../../../$1" &&
 		# remove it temporarily before comparing, as
 		# "$1/.git/config" lacks it...
-		git config --unset core.worktree
+		git config --unset worktree.path
 	) &&
 	diff -r ".git/modules/$1" "$1/.git" &&
 	(
 		# ... and then restore.
 		cd ".git/modules/$1" &&
-		git config core.worktree "../../../$1"
+		git config worktree.path "../../../$1"
 	)
 }
 
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 7c88245..def28e6 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -93,7 +93,7 @@ test_expect_success 'submodule add' '
 		test_cmp expect submod/.git &&
 		(
 			cd submod &&
-			git config core.worktree >actual &&
+			git config worktree.path >actual &&
 			echo "../../../submod" >expect &&
 			test_cmp expect actual &&
 			rm -f actual expect
@@ -945,7 +945,7 @@ test_expect_success 'submodule deinit fails when submodule has a .git directory
 		cd init &&
 		rm .git &&
 		cp -R ../.git/modules/example .git &&
-		GIT_WORK_TREE=. git config --unset core.worktree
+		GIT_WORK_TREE=. git config --unset worktree.path
 	) &&
 	test_must_fail git submodule deinit init &&
 	test_must_fail git submodule deinit -f init &&
diff --git a/t/t7409-submodule-detached-worktree.sh b/t/t7409-submodule-detached-worktree.sh
index c207171..ba50d77 100755
--- a/t/t7409-submodule-detached-worktree.sh
+++ b/t/t7409-submodule-detached-worktree.sh
@@ -55,7 +55,7 @@ test_expect_success 'submodule on detached working tree' '
 	)
 '
 
-test_expect_success 'submodule on detached working pointed by core.worktree' '
+test_expect_success 'submodule on detached working pointed by worktree.path' '
 	mkdir home3 &&
 	(
 		cd home3 &&
@@ -63,7 +63,7 @@ test_expect_success 'submodule on detached working pointed by core.worktree' '
 		export GIT_DIR &&
 		git clone --bare ../remote "$GIT_DIR" &&
 		git config core.bare false &&
-		git config core.worktree .. &&
+		git config worktree.path .. &&
 		git checkout master &&
 		git submodule add ../bundle1 .vim/bundle/dupe &&
 		test_commit "dupe" &&
@@ -74,7 +74,7 @@ test_expect_success 'submodule on detached working pointed by core.worktree' '
 		GIT_DIR="$(pwd)/.dotfiles" &&
 		export GIT_DIR &&
 		git config core.bare false &&
-		git config core.worktree .. &&
+		git config worktree.path .. &&
 		git pull &&
 		git submodule update --init &&
 		test -f .vim/bundle/dupe/shoot.t
-- 
2.3.0.rc1.137.g477eb31
Previous: Nguyễn Thái Ngọc DuyNext: Jens Lehmann
Message 4 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.