StackUnderflow StackUnderflow - 7 months ago 43
Git Question

list all files having a git attribute set

git check-attr
allows me to check if an attribute is set in
for a specific set of files.

# git check-attr myAttr -- org/example/file1 org/example/file2
org/example/file1: myAttr: set
org/example/file2: myAttr: unspecified

Is there an easy way to list all files having
set, including all wildcard matches?


You could set as an argument the list with all the files in your repository using git ls-files, like this:

git check-attr myAttr `git ls-files`

If your repository has too many files you might the following error:

-bash: /usr/bin/git: Argument list too long

which you can overcome with xargs:

git ls-files | xargs git check-attr myAttr

Finally, if you have too many files you will probably want to filter out the ones where you didn't specify the argument, to make the output more readable:

git ls-files | xargs git check-attr myAttr | grep -v 'unspecified$'

With grep, you could apply more filters to this output in order to match just the files that you want.