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

[PATCH 1/5] FIXUP submodule: implement `module_clone` as a builtin helper

From
Stefan Beller <sbeller@google.com>
Date
Aug 25, 2015, 17:28 UTC
Message-ID
<1440523706-23041-2-git-send-email-sbeller@google.com>
In-Reply-To
<1440523706-23041-1-git-send-email-sbeller@google.com>
This closes the memory leaks as pointed out by Jeff.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/submodule--helper.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index ae74b80..7e298b4 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -220,7 +220,6 @@ static int module_clone(int argc, const char **argv, const char *prefix)
 
 	strbuf_addf(&sb, "%s/modules/%s", get_git_dir(), name);
 	sm_gitdir = strbuf_detach(&sb, NULL);
-	strbuf_reset(&sb);
 
 	if (!file_exists(sm_gitdir)) {
 		safe_create_leading_directories_const(sm_gitdir);
@@ -259,12 +258,16 @@ static int module_clone(int argc, const char **argv, const char *prefix)
 	/* Redirect the worktree of the submodule in the superprojects config */
 	if (!is_absolute_path(sm_gitdir)) {
 		char *s = (char*)sm_gitdir;
-		strbuf_addf(&sb, "%s/%s", xgetcwd(), sm_gitdir);
+		if (strbuf_getcwd(&sb))
+			die_errno("unable to get current working directory");
+		strbuf_addf(&sb, "/%s", sm_gitdir);
 		sm_gitdir = strbuf_detach(&sb, NULL);
-		strbuf_reset(&sb);
 		free(s);
 	}
-	strbuf_addf(&sb, "%s/%s", xgetcwd(), path);
+
+	if (strbuf_getcwd(&sb))
+		die_errno("unable to get current working directory");
+	strbuf_addf(&sb, "/%s", path);
 
 	p = git_pathdup_submodule(path, "config");
 	if (!p)
-- 
2.5.0.400.gff86faf
Previous: Stefan BellerNext: Stefan Beller
Message 2 of 19 in “Demonstrate new parallel threading API”
  1. 0/5 Demonstrate new parallel threading APIStefan Beller, Aug 25, 2015
  2. 1/5 FIXUP submodule: implement `module_clone` as a builtin helperStefan Beller, Aug 25, 2015
  3. 2/5 thread-utils: add a threaded task queueStefan Beller, Aug 25, 2015
  4. 3/5 submodule: helper to run foreach in parallelStefan Beller, Aug 25, 2015
  5. Junio C HamanoAug 25, 2015
  6. Stefan BellerAug 25, 2015
  7. Junio C HamanoAug 25, 2015
  8. Junio C HamanoAug 25, 2015
  9. Jeff KingAug 26, 2015
  10. Stefan BellerAug 26, 2015
  11. 4/5 index-pack: Use the new worker poolStefan Beller, Aug 25, 2015
  12. Jeff KingAug 25, 2015
  13. Stefan BellerAug 25, 2015
  14. Junio C HamanoAug 25, 2015
  15. Stefan BellerAug 25, 2015
  16. Junio C HamanoAug 25, 2015
  17. Stefan BellerAug 25, 2015
  18. Junio C HamanoAug 25, 2015
  19. 5/5 pack-objects: Use new worker poolStefan Beller, Aug 25, 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.