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

Re: [PATCH v2] ls-files: add pathspec matching for submodules

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 21, 2016, 17:49 UTC
Message-ID
<xmqq37kt9m83.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<xmqqmvj19nyp.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 9 quoted lines
> Brandon Williams <bmwill@google.com> writes:
>
>> On a similar but slightly different note.  In general do we want
>> the pathspec '??b' to match against the sib/ directory and
>> subsequently have ls-files print all entries inside of the sib/
>> directory?  (this is in the non-recursive case)
>
> I'd need to find time to dig a bit of history before I can give a
> firm opinion on this, but here is a knee-jerk version of my reaction.

In the context of what you are doing, i.e. "ls-files that recurses into submodules", my opinion is that "ls-files --recurse-submodules" should behave wrt pathspecs AS IF all the submodule contents are flattened into a single index of the superproject.

In the sample scenario under discussion, i.e.
    In the superproject we have these
    $ git ls-files -s
    100644 c489803d5bdec1755f650854fe7ef5ab7a3ee58d 0       .gitmodules
    100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0       sib/file
    160000 1f5a0695289c500f25e7fa55e3ad27e394d1206b 0       sub
    In 'sub' submodule we have this
    100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0       file
such a flattend index would look like this:
    100644 c489803d5bdec1755f650854fe7ef5ab7a3ee58d 0       .gitmodules
    100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0       sib/file
    100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0       sub/file

i.e. removing 'sub' submodule entry from the index of the superproject and overlay everything in the submodule with sub/ prefixed to its path.

And with such an index, if and only if a path matches a pathspec, "git ls-files --recurse-submodules" run at the toplevel with the same pathspec should show the path. That means

    $ git ls-files --recurse-submodules '??b'
would show nothing (not even 'sub'), while
    $ git ls-files --recurse-submodules '??b*'

should show sib/file and sub/file. That is because that is how the command without "--recurse-submodules" working on that flat index would produce.

The "we have historically two kinds of pathspecs and they differ how they work with wildcard" is a separate issue, I would think, even though the result would affect what should happen in the above example (i.e. if we said "either a pattern match or a literal match to a leading directory path should make everything underneath match", '??b' would make sib/<anything> and sub/<anything> to be shown).

Previous: Junio C HamanoNext: Junio C Hamano
Message 24 of 25 in “[RFC] extending pathspec support to submodules”
  1. Brandon WilliamsSep 14, 2016
  2. Heiko VoigtSep 15, 2016
  3. Brandon WilliamsSep 15, 2016
  4. Junio C HamanoSep 15, 2016
  5. Stefan BellerSep 15, 2016
  6. Heiko VoigtSep 16, 2016
  7. Brandon WilliamsSep 16, 2016
  8. ls-files: add pathspec matching for submodulesBrandon Williams, Sep 17, 2016
  9. Junio C HamanoSep 17, 2016
  10. Brandon WilliamsSep 18, 2016
  11. Junio C HamanoSep 19, 2016
  12. Brandon WilliamsSep 19, 2016
  13. Junio C HamanoSep 19, 2016
  14. Brandon WilliamsSep 19, 2016
  15. Junio C HamanoSep 19, 2016
  16. Brandon WilliamsSep 19, 2016
  17. Junio C HamanoSep 19, 2016
  18. Brandon WilliamsSep 19, 2016
  19. ls-files: add pathspec matching for submodulesBrandon Williams, Sep 19, 2016
  20. Junio C HamanoSep 19, 2016
  21. Brandon WilliamsSep 20, 2016
  22. Brandon WilliamsSep 20, 2016
  23. Junio C HamanoSep 21, 2016
  24. Junio C HamanoSep 21, 2016
  25. Junio C HamanoSep 19, 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.