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

Re: [PATCHv5 1/3] submodule: Reimplement `module_list` shell function in C

From
Stefan Beller <sbeller@google.com>
Date
Sep 3, 2015, 19:18 UTC
Message-ID
<CAGZ79kb5_VJwJoBpvUdVMC43qvJThKa1utQFO68HjM1sciZ6-w@mail.gmail.com>
In-Reply-To
<xmqqio7rjppv.fsf@gitster.mtv.corp.google.com>
On Thu, Sep 3, 2015 at 11:57 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 5 quoted lines
>
> It is customary to use X_alloc, X_nr for an array X_something that
> is managed by ALLOC_GROW(), I think.  I'd also suggest wrapping
> these in a struct and passing it between module_list_compute() and
> its callers.

I did not take the suggestion as a strong suggestion at the time, but the looking at resulting squash proposal it looks way better.

> I may have said this already, but unlike tree entries, the index
> entries will never be a directory.  S_ISDIR() check here is
> meaningless [*1*].

Right. I was too focused on the other bug, of checking S_ISGITLINK after the pathspec matching, that I overlooked the ISDIR again. :(

Show 16 quoted lines
>> +int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
>> +{
>> +     int i;
>> +     if (argc < 2)
>> +             die(_("fatal: submodule--helper subcommand must be "
>> +                   "called with a subcommand"));
>> +
>> +     for (i = 0; i < ARRAY_SIZE(commands); i++)
>> +             if (!strcmp(argv[1], commands[i].cmd))
>> +                     return commands[i].fn(argc - 1, argv + 1, prefix);
>> +
>> +     die(_("fatal: '%s' is not a valid submodule--helper "
>> +           "subcommand"), argv[1]);
>> +}
>
> Nice and clean code structure.  I like it ;-).

It took a good while of discussion and reviews to arrive at that structure eventually.

The squash proposal looks good to me.
Previous: Junio C HamanoNext: Stefan Beller
Message 4 of 10 in “[PATCHv5 0/3] submodule--helper: Have some refactoring only patches first”
  1. Stefan BellerSep 2, 2015
  2. 1/3 submodule: Reimplement `module_list` shell function in CStefan Beller, Sep 2, 2015
  3. Junio C HamanoSep 3, 2015
  4. Stefan BellerSep 3, 2015
  5. 2/3 submodule: Reimplement `module_name` shell function in CStefan Beller, Sep 2, 2015
  6. 3/3 submodule: Reimplement `module_clone` shell function in CStefan Beller, Sep 2, 2015
  7. Junio C HamanoSep 3, 2015
  8. Stefan BellerSep 8, 2015
  9. Junio C HamanoSep 8, 2015
  10. Eric SunshineSep 3, 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.