You can use the file command to check the file and automatically determine what type it is. For instance:
$ file foo.gpg foo.gpg: GPG encrypted data $ file foo foo: ASCII text
You can match this with a hook. Sort of:
case "$filename" in *.gpg) if [ "$(file -b "$filename")" != "GPG encrypted data" ]; then echo "Error: $filename should be encrypted but isn't" >&2 exit 1 fi ;; esac
For a client-side click, you can use the pre-commit binding with git diff --cached --name-only to get a list of names to check.
Server-side failure is more complicated. I think you can connect to the preliminary reception, check the suggested links to a temporary place, check them (perhaps using git diff --name-only HEAD^ to get the list of files changed), and then reject the update from there if it breaks your requirements.
source share