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

[PATCH v9 1/2] submodule refactor: use strbuf_git_path_submodule() in add_submodule_odb()

From
Max Kirillov <max@max630.net>
Date
Sep 13, 2015, 22:17 UTC
Message-ID
<1442182662-28834-2-git-send-email-max@max630.net>
In-Reply-To
<1442182662-28834-1-git-send-email-max@max630.net>

Functions which directly operate submodule's object database do not handle the case when the submodule is linked worktree (which are introduced in c7b3a3d2fe). Instead of fixing the path calculation use already existing strbuf_git_path_submodule() function without changing overall behaviour. Then it will be possible to modify only that function whenever we need to change real location of submodule's repository content.

Edited-by: Jeff King <peff@peff.net>
Signed-off-by: Max Kirillov <max@max630.net>
---
 submodule.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/submodule.c b/submodule.c
index 245ed4d..16b7c35 100644
--- a/submodule.c
+++ b/submodule.c
@@ -124,13 +124,7 @@ static int add_submodule_odb(const char *path)
 	int ret = 0;
 	const char *git_dir;
 
-	strbuf_addf(&objects_directory, "%s/.git", path);
-	git_dir = read_gitfile(objects_directory.buf);
-	if (git_dir) {
-		strbuf_reset(&objects_directory);
-		strbuf_addstr(&objects_directory, git_dir);
-	}
-	strbuf_addstr(&objects_directory, "/objects/");
+	strbuf_git_path_submodule(&objects_directory, path, "objects/");
 	if (!is_directory(objects_directory.buf)) {
 		ret = -1;
 		goto done;
-- 
2.3.4.2801.g3d0809b
Previous: Max KirillovNext: Junio C Hamano
Message 2 of 4 in “Submodule object path”
  1. 0/2 Submodule object pathMax Kirillov, Sep 13, 2015
  2. 1/2 submodule refactor: use strbuf_git_path_submodule() in add_submodule_odb()Max Kirillov, Sep 13, 2015
  3. Junio C HamanoSep 14, 2015
  4. 2/2 path: implement common_dir handling in git_pathdup_submodule()Max Kirillov, Sep 13, 2015

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.