diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-05-16 16:47:29 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-05-16 16:54:20 +0200 |
commit | 66fce1f61e7e088bd92e19ecb0dd94553de6f824 (patch) | |
tree | 8186fec1125f425fb6d2073d61847ace5c7083f1 /.git-hooks | |
parent | fcf5b5c081ded93b12dd888236d0a860b7693ed1 (diff) |
git pre-commit hook: block large files
Change-Id: Id27cfa805fc7cd0f4f6cc3d8bb770aa7abd536e1
Diffstat (limited to '.git-hooks')
-rwxr-xr-x | .git-hooks/pre-commit | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit index fdd07ad94603..693319826b66 100755 --- a/.git-hooks/pre-commit +++ b/.git-hooks/pre-commit @@ -131,6 +131,20 @@ EOM exit( 1 ); } +# Block large files. +open( FILES, "git diff --cached --name-only --diff-filter=A -z $against |" ) || die "Cannot run git diff-index."; +while (<FILES>) +{ + my $size = `git cat-file -s :$_`; + # For now let's say large is 500KB + my $limit = 500; + if ($size > $limit * 1024) + { + print "Error: Attempt to add a large file: $_, pleasy try to fit into $limit KB.\n"; + exit( 1 ); + } +} + # fix whitespace in code check_whitespaces( $against); |