Expected behaviour for pathspecs matching attributes in subdirectories
- From
- Matthew Hughes <mhughes@uw.co.uk>
- Date
- Jul 6, 2023, 10:33 UTC
- Message-ID
- <CAEzX-aD1wfgp8AvNNfCXVM3jAaAjK+uFTqS2XP4CJbVvFr2BtQ@mail.gmail.com>
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/fileABut 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/fileAIs 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