How do I determine which files are being filtered by gitattributes when the filter is executed?
I have a bunch of ruby scripts in a git repository and it seems to be really hard to get people to write deferred code correctly.
I also have a small ruby script that formats the code to a specific standard and now I would like to run it as a filter script so that the unwanted file is not pushed to the repository.
echo "*.rb filter=rubyfilter" > .gitattributes
echo "[filter \"rubyfilter\"]" >> .git/config
echo " clean = /home/rasjani/bin/rbeauty" >> .git/config
echo " smudge = /home/rasjani/bin/rbeauty" >> .git/config
does a dirty git trick but ruby script should handle the affected files:
how / where can i see these?
a source to share
As described in GitPro Book
Git applies these settings only to a subdirectory or subset of files. These path-specific settings are called Git attributes and are set either in a .gitattributes file in one of your directories.
The man page git attributes
states:
- After verification, when the smudge command is specified, the command passes the blob object from its standard input, and its standard output is used to update the working directory file.
- Likewise, a pure command is used to transform the contents of the worktree file on registration.

This way your script will process every *.rb
file (in the directory and subdirectories where the file is located .gitattributes
) on checkout and commit.
See this SO question for a specific example.
You can test your own setup with:
git checkout --force
Note. As fooobar.com/questions/9380 / ... mentioned in this question , scripts smudge
and clean
can only modify the contents of a file without knowing which file they are processing.
a source to share