git check-attr
allows me to check if an attribute is set in .gitattributes
for a specific set of files.
e.g:
# 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 myAttr
set, including all wildcard matches?
The other posts weren't working well for me, but I got there:
git ls-files | git check-attr -a --stdin
"Check every file in git and print all filters" one liner.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With