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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 10, 2010, 17:30 UTC
Message-ID
<7vlj3xedru.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4D016146.9010907@web.de>
Jens Lehmann <Jens.Lehmann@web.de> writes:
Show 24 quoted lines
> Am 09.12.2010 22:16, schrieb Junio C Hamano:
> ...
>>> +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 <gitster@pobox.com>
---
 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];
Previous: Jens LehmannNext: Jens Lehmann
Message 23 of 24 in “Teach fetch and pull to recursively fetch submodules”
  1. 0/3 Teach fetch and pull to recursively fetch submodulesJens Lehmann, Nov 10, 2010
  2. 1/3 fetch/pull: Add the --recurse-submodules optionJens Lehmann, Nov 10, 2010
  3. 2/3 Add the 'fetch.recurseSubmodules' config settingJens Lehmann, Nov 10, 2010
  4. Jonathan NiederNov 11, 2010
  5. Jens LehmannNov 11, 2010
  6. Jonathan NiederNov 11, 2010
  7. Junio C HamanoNov 11, 2010
  8. Jonathan NiederNov 11, 2010
  9. Jens LehmannNov 12, 2010
  10. Jonathan NiederNov 12, 2010
  11. Jens LehmannNov 12, 2010
  12. Jonathan NiederNov 12, 2010
  13. Jens LehmannNov 12, 2010
  14. Jens LehmannNov 12, 2010
  15. 3/3 Submodules: Add the "fetchRecurseSubmodules" config optionJens Lehmann, Nov 10, 2010
  16. Jonathan NiederNov 11, 2010
  17. Jens LehmannNov 11, 2010
  18. 1/3 fetch/pull: Add the --recurse-submodules optionJens Lehmann, Nov 12, 2010
  19. Jonathan NiederNov 12, 2010
  20. Jens LehmannNov 12, 2010
  21. Junio C HamanoDec 9, 2010
  22. Jens LehmannDec 9, 2010
  23. Junio C HamanoDec 10, 2010
  24. Jens LehmannDec 10, 2010

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.