git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Jens Lehmann" <Jens.Lehmann@web.de>,
	"Max Kirillov" <max@max630.net>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 3/3] submodule: use worktree.path instead of core.worktree
Date: Sun,  8 Feb 2015 20:16:34 +0700	[thread overview]
Message-ID: <1423401394-13675-4-git-send-email-pclouds@gmail.com> (raw)
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

  parent reply	other threads:[~2015-02-08 13:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-08 13:16 [PATCH/RFD 0/3] worktree.* config keys and submodule and multiple worktrees Nguyễn Thái Ngọc Duy
2015-02-08 13:16 ` [PATCH 1/3] config.c: new config namespace worktree.* stored in $GIT_DIR/config.worktree Nguyễn Thái Ngọc Duy
2015-02-08 13:16 ` [PATCH 2/3] setup: add worktree.path to shadow core.worktree Nguyễn Thái Ngọc Duy
2015-02-08 13:16 ` Nguyễn Thái Ngọc Duy [this message]
2015-02-08 17:36 ` [PATCH/RFD 0/3] worktree.* config keys and submodule and multiple worktrees Jens Lehmann
2015-02-08 17:41   ` Jens Lehmann
2015-02-09  9:35   ` Duy Nguyen
2015-03-18 21:33   ` per-repository and per-worktree config variables Max Kirillov
2015-03-24 13:48     ` Duy Nguyen
2015-03-26 12:04       ` [PATCH v2] config.c: split some variables to $GIT_DIR/config.worktree Nguyễn Thái Ngọc Duy
2015-03-26 22:19         ` Max Kirillov
2015-03-29  1:25           ` Duy Nguyen
2015-03-30 21:26             ` Max Kirillov
2015-03-31 12:14         ` [PATCH v3] " Nguyễn Thái Ngọc Duy
2015-03-31 12:17           ` Duy Nguyen
2015-04-01 20:56           ` Max Kirillov
2015-04-03 10:30             ` Duy Nguyen
2015-04-13 23:37           ` Max Kirillov
2015-04-18 11:10             ` Duy Nguyen
2015-04-20  2:51               ` Max Kirillov
2015-04-20  3:22                 ` Duy Nguyen
2015-03-25 21:33     ` per-repository and per-worktree config variables Jens Lehmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1423401394-13675-4-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=max@max630.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).