Skip to content

Fix attr magic combined with pathspec prefix

Junio C Hamano git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2t6135: attr magic with path patternt/t6135-pathspec-with-attrs.sh+21 -10 replies
2/2dir: do not feed path suffix to pathspec matchdir.c t/t6135-pathspec-with-attrs.sh+31 -246 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] Fix attr magic combined with pathspec prefix

Matthew Hughes noticed and reported that a pathspec that uses the attribute magic with pathspec pattern does not work correctly.

After digging around, I found that

    $ git ls-files ":(attr:label)"

notices that the "label" attribute is set to path "sub/file" by listing it, and combined with a pathspec pattern, i.e.

    $ git ls-files ":(attr:label)sub"

it still correctly reports "sub/file" has the "label" attribute, be it defined in ".gitignore" or "sub/.gitignore". The case that it does not work is the command invocation is

    $ git ls-files ":(attr:label)sub/"

and the attribute "label" is defined in "sub/.gitattributes" for "sub/file".

It turns out that the problematic invocation triggers the common prefix optimization, which is totally broken for this case.

The first patch enhances the test coverage, and the second patch fixes the broken common prefix optimization.

Junio C Hamano (2):
t6135: attr magic with path pattern
dir: do not feed path suffix to pathspec match

 dir.c                          | 31 ++++++-----------------
 t/t6135-pathspec-with-attrs.sh | 46 ++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 25 deletions(-)
Signature · 1 line
2.41.0-318-g061c58647e