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

[PATCHv2 4/5] ok_to_remove_submodule: absorb the submodule git dir

From
Stefan Beller <sbeller@google.com>
Date
Dec 13, 2016, 20:56 UTC
Message-ID
<20161213205622.841-5-sbeller@google.com>
In-Reply-To
<20161213205622.841-1-sbeller@google.com>

It is a major reason to say no, when deciding if a submodule can be deleted, if the git directory of the submodule being contained in the submodule's working directory.

Migrate the git directory into the superproject instead of failing, and proceed with the other checks.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 submodule.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/submodule.c b/submodule.c
index 2d13744b06..e42efa2337 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1026,11 +1026,22 @@ int ok_to_remove_submodule(const char *path, unsigned flags)
 	struct strbuf buf = STRBUF_INIT;
 	int ok_to_remove = 1;
 
+	/* Is it there? */
 	if (!file_exists(path) || is_empty_dir(path))
 		return 1;
 
-	if (!submodule_uses_gitfile(path))
-		return 0;
+	/* Does it have a .git directory? */
+	if (!submodule_uses_gitfile(path)) {
+		absorb_git_dir_into_superproject("", path,
+			ABSORB_GITDIR_RECURSE_SUBMODULES);
+
+		/*
+		 * We should be using a gitfile by now. Let's double
+		 * check as losing the git dir would be fatal.
+		 */
+		if (!submodule_uses_gitfile(path))
+			return 0;
+	}
 
 	argv_array_pushl(&cp.args, "status", "--porcelain",
 				   "--ignore-submodules=none", NULL);
-- 
2.11.0.rc2.35.g26e18c9
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 10 in “[PATCHv2 0/5] git-rm absorbs submodule git directory before deletion”
  1. Stefan BellerDec 13, 2016
  2. 1/5 submodule.h: add extern keyword to functionsStefan Beller, Dec 13, 2016
  3. 2/5 submodule: modernize ok_to_remove_submodule to use argv_arrayStefan Beller, Dec 13, 2016
  4. Junio C HamanoDec 14, 2016
  5. 4/5 ok_to_remove_submodule: absorb the submodule git dirStefan Beller, Dec 13, 2016
  6. Junio C HamanoDec 14, 2016
  7. Stefan BellerDec 14, 2016
  8. 5/5 rm: add absorb a submodules git dir before deletionStefan Beller, Dec 13, 2016
  9. Junio C HamanoDec 14, 2016
  10. 3/5 submodule: add flags to ok_to_remove_submoduleStefan Beller, Dec 13, 2016

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.