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

Re: [PATCH 5/7] submodule: implement `module_list` as a builtin helper

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 19, 2015, 18:22 UTC
Message-ID
<xmqqfv3f9m0l.fsf@gitster.dls.corp.google.com>
In-Reply-To
<xmqqpp2j9m7g.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
> Micronit.  Even though multiplication is commutative, the order of
> arguments to xcalloc() looks odd.  It lets you say "I want an array
> with nmemb elements, and each of its is size-bytes long" by giving
> it nmemb and then size.

Unrelated tangent, but while I have output from "git grep 'calloc.*pathspec'" on my screen... ;-)

 builtin/checkout.c | 2 +-
 builtin/ls-files.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 7ea533e..e3b28e4 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -283,7 +283,7 @@ static int checkout_paths(const struct checkout_opts *opts,
 	if (opts->source_tree)
 		read_tree_some(opts->source_tree, &opts->pathspec);
 
-	ps_matched = xcalloc(1, opts->pathspec.nr);
+	ps_matched = xcalloc(opts->pathspec.nr, 1);
 
 	/*
 	 * Make sure all pathspecs participated in locating the paths
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 6fa2205..b6a7cb0 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -516,7 +516,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
 
 	/* Treat unmatching pathspec elements as errors */
 	if (pathspec.nr && error_unmatch)
-		ps_matched = xcalloc(1, pathspec.nr);
+		ps_matched = xcalloc(pathspec.nr, 1);
 
 	if ((dir.flags & DIR_SHOW_IGNORED) && !exc_given)
 		die("ls-files --ignored needs some exclude pattern");
Previous: Junio C HamanoNext: Stefan Beller
Message 9 of 19 in “Submodule improvements”
  1. 0/7 Submodule improvementsStefan Beller, Aug 18, 2015
  2. 1/7 submodule: implement a config API for lookup of .gitmodules valuesStefan Beller, Aug 18, 2015
  3. 2/7 submodule: extract functions for config set and lookupStefan Beller, Aug 18, 2015
  4. 3/7 submodule: use new config API for worktree configurationsStefan Beller, Aug 18, 2015
  5. 4/7 submodule: Allow errornous values for the fetchrecursesubmodules optionStefan Beller, Aug 18, 2015
  6. Junio C HamanoAug 19, 2015
  7. 5/7 submodule: implement `module_list` as a builtin helperStefan Beller, Aug 18, 2015
  8. Junio C HamanoAug 19, 2015
  9. Junio C HamanoAug 19, 2015
  10. Stefan BellerAug 19, 2015
  11. Stefan BellerAug 19, 2015
  12. 6/7 submodule: implement `module_name` as a builtin helperStefan Beller, Aug 18, 2015
  13. 7/7 submodule: implement `module_clone` as a builtin helperStefan Beller, Aug 18, 2015
  14. Stefan BellerAug 18, 2015
  15. 7/7 submodule: implement `module_clone` as a builtin helperStefan Beller, Aug 18, 2015
  16. Junio C HamanoAug 19, 2015
  17. Stefan BellerAug 19, 2015
  18. Jeff KingAug 21, 2015
  19. Stefan BellerAug 18, 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.