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

[PATCH 3/3] submodule deinit: unset core.worktree

From
Stefan Beller <sbeller@google.com>
Date
Jun 19, 2018, 00:06 UTC
Message-ID
<20180619000608.147422-4-sbeller@google.com>
In-Reply-To
<20180619000608.147422-1-sbeller@google.com>

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>
---
 builtin/submodule--helper.c | 2 ++
 t/lib-submodule-update.sh   | 2 +-
 t/t7400-submodule-basic.sh  | 5 +++++
 3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index dffc55ed8ee..19480902681 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -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);
 	}
 
diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh
index 12cd4e9233e..aa5ac03325a 100755
--- a/t/lib-submodule-update.sh
+++ b/t/lib-submodule-update.sh
@@ -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" &&
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 812db137b8d..48fd14fae6e 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -993,6 +993,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 &&
-- 
2.18.0.rc1.244.gcf134e6275-goog
Previous: Stefan Beller
Message 11 of 11 in “submodules with no working tree shall unset core.worktree”
  1. 0/3 submodules with no working tree shall unset core.worktreeStefan Beller, Jun 12, 2018
  2. 1/3 submodule: unset core.worktree if no working tree is presentStefan Beller, Jun 12, 2018
  3. 2/3 submodule: ensure core.worktree is set after updateStefan Beller, Jun 12, 2018
  4. SZEDER GáborJun 16, 2018
  5. 3/3 submodule deinit: unset core.worktreeStefan Beller, Jun 12, 2018
  6. Junio C HamanoJun 13, 2018
  7. Stefan BellerJun 13, 2018
  8. 0/3 submodules with no working tree shall unset core.worktreeStefan Beller, Jun 19, 2018
  9. 1/3 submodule: unset core.worktree if no working tree is presentStefan Beller, Jun 19, 2018
  10. 2/3 submodule: ensure core.worktree is set after updateStefan Beller, Jun 19, 2018
  11. 3/3 submodule deinit: unset core.worktreeStefan Beller, Jun 19, 2018

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.