This opens a door of using submodule with multiple worktrees

Signed-off-by: Nguyễn Thái Ngọc Duy <pclo...@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

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

Reply via email to