I have a solution to this, but it's really kludgey. A while back, I set up a pre-commit hook to stop me from accidentally using -a
when I have files staged. My solution is to read the command that invoked the original git command (probably only works on linux too).
while read -d $'\0' arg ; do
if [[ "$arg" == '--tags' ]] ; then
exit 0
fi
done < /proc/$PPID/cmdline
# and perform your check here
That being said, try calling env
in the hook; git sets a few extra vars (starting with GIT_
prefixes, like GIT_INDEX_FILE
).