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

Re: [PATCH 2/5] pathspec: add tree_recursive_diff parameter

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 28, 2010, 05:28 UTC
Message-ID
<7vk4m6v3ly.fsf@alter.siamese.dyndns.org>
In-Reply-To
<AANLkTinZt8kish9L2F-ad_boXByZTUj-BnYTp-vtePk0@mail.gmail.com>
Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:
Show 24 quoted lines
> 2010/9/28 Junio C Hamano <gitster@pobox.com>:
>> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>> ...
>>>  - If it's recursive diff, directories are just an intermediate step.
>>>    All path must end with a file name. Thus, directories will be
>>>    unconditionally matched.
>>
>> Hmm, I am not sure what you mean by this.  If the pathspec says a/b*/c,
>> you are in "a" and are deciding if you should descend to its subdirectory,
>> then you would surely want to be able to say:
>>
>>  (1) Ah, the subdirectory I am looking at is "bar" and it does match "b*".
>>      It might contain "c"; I should descend into it.
>>
>>  (2) Nope, the subdirectory I am looking at is "frotz" and it can never
>>      match "b*", so there is no point recursing into it.
>
> I did not go that far, trying to analyse the pattern. When I wrote
> "immediate step" I was thinking of "*foo" pattern, which effectively
> means descending to any reachable directories because '*' matches
> slashes too. I think that's the worst case.
>
> Anyway I did not know that I could borrow some optimizations from
> pathspec_matches() in builtin/grep.c.

As you noticed, over time we have polished our re-implementations of the pathspec logic to avoid needlessly descending into subdirectories, and the one in the grep may be the latest incarnation of it. The logic that uses the path_simplify structure in dir.c may also offer you some inspirations.

Note that the worst case will fall out as a natural consequence of doing the fallback in the dumb and simple way, so you do not have to worry too much about it ;-) I would prefer to see the new, consolidated logic to at least know the easy optimizations we already have.

Thanks.
Previous: Nguyen Thai Ngoc DuyNext: Nguyễn Thái Ngọc Duy
Message 6 of 9 in “Globbing support in diff family”
  1. 0/5 Globbing support in diff familyNguyễn Thái Ngọc Duy, Sep 19, 2010
  2. 1/5 pathspec: mark wildcard pathspecs from the beginningNguyễn Thái Ngọc Duy, Sep 19, 2010
  3. 2/5 pathspec: add tree_recursive_diff parameterNguyễn Thái Ngọc Duy, Sep 19, 2010
  4. Junio C HamanoSep 27, 2010
  5. Nguyen Thai Ngoc DuySep 28, 2010
  6. Junio C HamanoSep 28, 2010
  7. 3/5 tree_entry_interesting: turn to match_pathspec if wildcard is presentNguyễn Thái Ngọc Duy, Sep 19, 2010
  8. 4/5 Convert ce_path_match() to use struct pathspecNguyễn Thái Ngọc Duy, Sep 19, 2010
  9. 5/5 ce_path_match: drop prefix matching in favor of match_pathspecNguyễn Thái Ngọc Duy, Sep 19, 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.