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

Re: [PATCH 1/2] ls-files: optionally recurse into submodules

From
BWBrandon Williams <bmwill@google.com>
Date
Sep 23, 2016, 23:31 UTC
Message-ID
<CAKoko1od4=PtHkYaU5bdktH4orL_k_G32M=3svgFGwvy6BKKsw@mail.gmail.com>
In-Reply-To
<20160922062047.jbxsgfabej26jt5i@sigill.intra.peff.net>
On Wed, Sep 21, 2016 at 11:20 PM, Jeff King <peff@peff.net> wrote:
Show 26 quoted lines
>> +/**
>> + * Recursively call ls-files on a submodule
>> + */
>> +static void show_gitlink(const struct cache_entry *ce)
>> +{
>> +     struct child_process cp = CHILD_PROCESS_INIT;
>> +     int status;
>> +
>> +     argv_array_push(&cp.args, "ls-files");
>> +     argv_array_push(&cp.args, "--recurse-submodules");
>> +     argv_array_pushf(&cp.args, "--submodule-prefix=%s%s/",
>> +                      submodule_prefix ? submodule_prefix : "",
>> +                      ce->name);
>> +     cp.git_cmd = 1;
>> +     cp.dir = ce->name;
>> +     status = run_command(&cp);
>> +     if (status)
>> +             exit(status);
>> +}
>
> This doesn't propagate the parent argv at all. So if I run:
>
>   git ls-files -z --recurse-submodules
>
> then the paths are all NUL-terminated in the parent, but
> newline-terminated in the submodules. Oops.
Yep definitely missed that.  I can fix that.  I think the main reason
for not blindly
copying the argv array is that there may be some things we don't want to pass
to the child. While not in the context of ls-files, I was working on
recursive grep
earlier and with that you can pass a rev to grep.  You can't blindly
copy that because
 the rev is meaningless to the the child and may produce broken
output.  Instead we
would need to pass the actual rev of what the parent has checked out
in that particular
rev.  I haven't thought it completely through yet but it did
discourage me from blindly
copying the args across.
-Brandon
Previous: Jeff KingNext: Junio C Hamano
Message 14 of 29 in “ls-files: adding support for submodules”
  1. 1/2 ls-files: adding support for submodulesBrandon Williams, Sep 21, 2016
  2. 2/2 ls-files: add pathspec matching for submodulesBrandon Williams, Sep 21, 2016
  3. Junio C HamanoSep 21, 2016
  4. Brandon WilliamsSep 21, 2016
  5. 2/2 ls-files: add pathspec matching for submodulesBrandon Williams, Sep 21, 2016
  6. Junio C HamanoSep 23, 2016
  7. Junio C HamanoSep 23, 2016
  8. Brandon WilliamsSep 23, 2016
  9. Brandon WilliamsSep 21, 2016
  10. Junio C HamanoSep 21, 2016
  11. Brandon WilliamsSep 21, 2016
  12. 1/2 ls-files: optionally recurse into submodulesBrandon Williams, Sep 21, 2016
  13. Jeff KingSep 22, 2016
  14. Brandon WilliamsSep 23, 2016
  15. Junio C HamanoSep 21, 2016
  16. Jeff KingSep 22, 2016
  17. Stefan BellerSep 22, 2016
  18. Junio C HamanoSep 22, 2016
  19. Jeff KingSep 23, 2016
  20. Stefan BellerSep 23, 2016
  21. Jeff KingSep 23, 2016
  22. Brandon WilliamsSep 23, 2016
  23. Stefan BellerSep 23, 2016
  24. Nazri RamliySep 25, 2016
  25. Junio C HamanoSep 27, 2016
  26. Brandon WilliamsSep 27, 2016
  27. Junio C HamanoSep 27, 2016
  28. Brandon WilliamsSep 27, 2016
  29. Junio C HamanoSep 27, 2016

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.