Expected behaviour for pathspecs matching attributes in subdirectories

From: Matthew Hughes <hidden>
Date: 2023-07-06 10:33:48

Hi,

I'm working with pathspecs matching on attributes, here's a basic repo setup:

    $ git init .
    $ mkdir -p sub/sub
    $ touch fileA sub/fileA sub/sub/fileA
    $ echo 'fileA labelA' > sub/.gitattributes
    $ git add .
    $ git commit -m 'Build the repo'

What I want to do: list all files under 'sub/sub' that have 'labelA' as an
attribute.

Working from the top level I get the output I would expect:

    $ git ls-files -- ':(attr:labelA)'
    sub/fileA
    sub/sub/fileA
    $ git ls-files -- ':(attr:labelA)sub'
    sub/fileA
    sub/sub/fileA

But as soon as a directory is included in the pathspec's path no files are
returned:

    $ git ls-files -- ':(attr:labelA)sub/'
    $ git ls-files -- ':(attr:labelA)sub/sub'

Without the attribtue magic I can use a directory to list files there:

    $ git ls-files -- sub/sub
    sub/sub/fileA

Is this the expected behaviour? I looked in t/t6135-pathspec-with-attrs.sh and
didn't see a test case covering something similar. If this is expected, is
there another way to achieve what I'm looking for?

Thanks for your time,
Matt
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help