git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Oct 31, 2014, 19:25 UTC
Message-ID
<CACBZZX64ofaQSoOMhQcjx+ED2LOpdDVZJ_5TSjotuBv4m+Fb5A@mail.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.

Message 1 of 1 in “[ANNOUNCE] A pre-receive hook to intelligently block binary data”
  1. Ævar Arnfjörð BjarmasonOct 31, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.