There's no reason. That's just the way it is.
If you want to make git support pre-add hooks, then you can use filter
s. In case it's not obvious from the documentation, here's what you'd have to do:
In a gitattributes file, you assign a filter for the paths you want to hit. For example, in .git/info/attributes
you put:
*.c filter=myFilter
Then, in one of git's config files, you'll have to define the filter.myFilter.clean command. For example, in .git/config
:
[filter "myFilter"]
clean = $(git rev-parse --show-toplevel)/.git/hooks/pre-add
Now, every time you add a .c
file, you will run the commands in pre-add
.
(Remember to chmod +x
your script if you want it to run, and that it's being invoked from a different script, so stdout won't be tied to your terminal unless you do something like echo "Hi, this is a pre-add hook" > /dev/tty
)