[Libreoffice-commits] core.git: .git-hooks/pre-commit

Miklos Vajna vmiklos at collabora.co.uk
Fri May 16 07:54:49 PDT 2014


 .git-hooks/pre-commit |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

New commits:
commit 66fce1f61e7e088bd92e19ecb0dd94553de6f824
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri May 16 16:47:29 2014 +0200

    git pre-commit hook: block large files
    
    Change-Id: Id27cfa805fc7cd0f4f6cc3d8bb770aa7abd536e1

diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit
index fdd07ad..6933198 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);
 


More information about the Libreoffice-commits mailing list