submodule deinit: unset core.worktree
authorStefan Beller <sbeller@google.com>
Tue, 19 Jun 2018 00:06:08 +0000 (17:06 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 Jun 2018 16:28:13 +0000 (09:28 -0700)
When a submodule is deinit'd, the working tree is gone, so the setting of
core.worktree is bogus. Unset it.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c
t/lib-submodule-update.sh
t/t7400-submodule-basic.sh
index dffc55ed8ee973b0051076334c8e8e2d60b7595e..19480902681833b115c2cdf535068533efdbf2d1 100644 (file)
@@ -980,6 +980,8 @@ static void deinit_submodule(const char *path, const char *prefix,
                if (!(flags & OPT_QUIET))
                        printf(format, displaypath);
 
+               submodule_unset_core_worktree(sub);
+
                strbuf_release(&sb_rm);
        }
 
index 12cd4e9233e345a1432e18b205e2833856a4425a..aa5ac03325a8c5038e9b568fceb1e953f4a0dcf4 100755 (executable)
@@ -235,7 +235,7 @@ reset_work_tree_to_interested () {
        then
                mkdir -p submodule_update/.git/modules/sub1/modules &&
                cp -r submodule_update_repo/.git/modules/sub1/modules/sub2 submodule_update/.git/modules/sub1/modules/sub2
-               GIT_WORK_TREE=. git -C submodule_update/.git/modules/sub1/modules/sub2 config --unset core.worktree
+               # core.worktree is unset for sub2 as it is not checked out
        fi &&
        # indicate we are interested in the submodule:
        git -C submodule_update config submodule.sub1.url "bogus" &&
index 2f532529b82a847f81d4bdda17f9f07c115c2d86..1a33040d94d628d1c6a2f3edcac6ab4f00b7bbf7 100755 (executable)
@@ -991,6 +991,11 @@ test_expect_success 'submodule deinit should remove the whole submodule section
        rmdir init
 '
 
+test_expect_success 'submodule deinit should unset core.worktree' '
+       test_path_is_file .git/modules/example/config &&
+       test_must_fail git config -f .git/modules/example/config core.worktree
+'
+
 test_expect_success 'submodule deinit from subdirectory' '
        git submodule update --init &&
        git config submodule.example.foo bar &&