Re: [PATCH v4 1/3] fetch/pull: Add the --recurse-submodules option

Subsystems: the rest

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH v4 1/3] fetch/pull: Add the --recurse-submodules option

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:50:13

Jens Lehmann [off-list ref] writes:
Am 09.12.2010 22:16, schrieb Junio C Hamano:
...
quoted
quoted
+int fetch_populated_submodules(int num_options, const char **options,
+			       const char *prefix, int quiet)
+{
+	int i, result = 0, argc = 0;
+	struct child_process cp;
+	const char **argv;
+	struct string_list_item *name_for_path;
+	const char *work_tree = get_git_work_tree();
+	if (!work_tree)
+		return 0;
+
+	if (!the_index.initialized)
+		if (read_cache() < 0)
+			die("index file corrupt");
+
+	argv = xcalloc(num_options + 5, sizeof(const char *));
Where is this '5' coming from?  "fetch" "--submodule-prefix", the prefix,
and the terminating NULL?  What did I miss?
No, you didn't miss anything but I have been off by one ... '4' is
sufficient here.
Ok, thanks for double checking.

-- >8 --
Subject: [PATCH] fetch_populated_submodules(): document dynamic allocation size

... while fixing a miscounting.

Signed-off-by: Junio C Hamano <redacted>
---
 submodule.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/submodule.c b/submodule.c
index 4e62900..6f1c107 100644
--- a/submodule.c
+++ b/submodule.c
@@ -264,7 +264,8 @@ int fetch_populated_submodules(int num_options, const char **options,
 		if (read_cache() < 0)
 			die("index file corrupt");
 
-	argv = xcalloc(num_options + 5, sizeof(const char *));
+	/* 4: "fetch" (options) "--submodule-prefix" prefix NULL */
+	argv = xcalloc(num_options + 4, sizeof(const char *));
 	argv[argc++] = "fetch";
 	for (i = 0; i < num_options; i++)
 		argv[argc++] = options[i];

Re: [PATCH v4 1/3] fetch/pull: Add the --recurse-submodules option

From: Jens Lehmann <hidden>
Date: 2016-06-15 22:50:13

Am 10.12.2010 18:30, schrieb Junio C Hamano:
Jens Lehmann [off-list ref] writes:
quoted
No, you didn't miss anything but I have been off by one ... '4' is
sufficient here.
Ok, thanks for double checking.

-- >8 --
Subject: [PATCH] fetch_populated_submodules(): document dynamic allocation size
Thanks and ack.

(This was a leftover from the time the "--recurse-submodules" option had been
added in this function before I moved that into add_options_to_argv())
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help