submodule deinit: unset core.worktree
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>
Stefan Beller committed
Jun 18, 2018 at 17:06 UTC
984cd77ddbf0eea7371a18ad7124120473b6bb2d
3 files changed
+8
-1
builtin/submodule--helper.c
+2
@@ -980,6 +980,8 @@ static void deinit_submodule(const char *path, const char *prefix,
980
if (!(flags & OPT_QUIET))
981
printf(format, displaypath);
982
983
+ submodule_unset_core_worktree(sub);
984
+
985
strbuf_release(&sb_rm);
986
}
987
t/lib-submodule-update.sh
+1
-1
@@ -235,7 +235,7 @@ reset_work_tree_to_interested () {
235
then
236
mkdir -p submodule_update/.git/modules/sub1/modules &&
237
cp -r submodule_update_repo/.git/modules/sub1/modules/sub2 submodule_update/.git/modules/sub1/modules/sub2
238
- GIT_WORK_TREE=. git -C submodule_update/.git/modules/sub1/modules/sub2 config --unset core.worktree
238
+ # core.worktree is unset for sub2 as it is not checked out
239
fi &&
240
# indicate we are interested in the submodule:
241
git -C submodule_update config submodule.sub1.url "bogus" &&
t/t7400-submodule-basic.sh
+5
@@ -991,6 +991,11 @@ test_expect_success 'submodule deinit should remove the whole submodule section
991
rmdir init
992
'
993
994
+test_expect_success 'submodule deinit should unset core.worktree' '
995
+ test_path_is_file .git/modules/example/config &&
996
+ test_must_fail git config -f .git/modules/example/config core.worktree
997
+'
998
+
999
test_expect_success 'submodule deinit from subdirectory' '
1000
git submodule update --init &&
1001
git config submodule.example.foo bar &&