# [ANNOUNCE] A pre-receive hook to intelligently block binary data

1 messages from 2014-10-31 to 2014-10-31. Participants: Ævar Arnfjörð Bjarmason.
Thread: https://gitlist.dev/t/37858

## Ævar Arnfjörð Bjarmason, 2014-10-31 19:25

Subject: [ANNOUNCE] A pre-receive hook to intelligently block binary data
Message-ID: <CACBZZX64ofaQSoOMhQcjx+ED2LOpdDVZJ_5TSjotuBv4m+Fb5A@mail.gmail.com>
URL: https://gitlist.dev/e/CACBZZX64ofaQSoOMhQcjx%2BED2LOpdDVZJ_5TSjotuBv4m%2BFb5A%40mail.gmail.com

```
After searching around a bit I couldn't find a stand-alone Git hook
that would intelligently block binary data pushes so I wrote my own:
https://github.com/avar/pre-receive-reject-binaries

Main features:

 * Quota per-commit for how much binary data is OK
 * Ability to optionally allow users to override binary pushes by
including a notice in their commit messages
 * Doesn't disallow removing existing binary data, or renaming
existing binary files
 * Will block commits that include references to existing binary blobs though
 * Spots cases where a push is pushing commits that add and then
remove binary blobs (i.e. counts net additions)
 * Has hookable support for logging by piping its output to external
commands when it runs or when it rejects/unblocks a binary push. I'm
using this for logging its output to a logfile, and to send E-Mails
when it blocks/is unblocked.
* Only requires a stock perl install, should run on any *nix-like OS
out of the box
* Should be relatively fast compared to some other similar solutions
I've seen, i.e. it parses the output of one "git-log --stat" command
for the entire push, and doesn't e.g. do a "git show" for each commit
being pushed.

One general note about git-log output: I was disappointed to see that
there was no easily parsable "git log" output that showed you how much
binary files increased in size, --numstat will just show "-" for
binary files, and it's non-trivial to parse the "--stat" output. It's
meant for human consumption and will sometimes include variations in
how much whitespace is inserted.

```
