[Cmake-commits] CMake branch, hooks, updated. a54ae582f7de41e8a0f54dff5b260dab94aaf9ef
cmake-commits at cmake.org
cmake-commits at cmake.org
Mon Jun 7 13:59:24 EDT 2010
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, hooks has been updated
via a54ae582f7de41e8a0f54dff5b260dab94aaf9ef (commit)
via 92c7517435970a4e1abc37292e03ea18302d523d (commit)
from 7827726e88c2a4cacdda5cd09e6907925cd30f2f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a54ae582f7de41e8a0f54dff5b260dab94aaf9ef
commit a54ae582f7de41e8a0f54dff5b260dab94aaf9ef
Author: Brad King <brad.king at kitware.com>
Date: Mon Jun 7 13:56:33 2010 -0400
pre-commit: Check file sizes
Check blob and tree object sizes to prevent large objects from entering
the repository. The default limit is 1024 KiB, but it can be set with
git config hooks.MaxObjectKiB $KiB
locally, or disabled by using 0 KiB.
diff --git a/pre-commit b/pre-commit
index 79b27a0..69b84b9 100755
--- a/pre-commit
+++ b/pre-commit
@@ -10,6 +10,8 @@ die() {
exit 1
}
+zero='0000000000000000000000000000000000000000'
+
#-----------------------------------------------------------------------------
# Check for committer identity.
advice='
@@ -82,7 +84,7 @@ test -z "$bad" || die 'Leading TABs added in
Convert them to spaces (2 per TAB) before commit.'
#-----------------------------------------------------------------------------
-# Check file modes.
+# Check file modes and sizes.
mode_looks_exe() {
case "$1" in
*.bat) return 0 ;;
@@ -109,11 +111,27 @@ check_mode() {
*) mode_non_file ;;
esac
}
+
+size_max_KiB=$(git config hooks.MaxObjectKiB)
+test -n "$size_max_KiB" || size_max_KiB=1024
+size_too_large() {
+ echo "The path '$file' has size $file_KiB KiB, greater than the maximum $size_max_KiB KiB."
+ echo 'Run "git config hooks.MaxObjectKiB $KiB" to set local limit, 0 to disable.'
+}
+check_size() {
+ if test "$size_max_KiB" -gt "0" \
+ -a "$dst_obj" != "$zero" -a "$dst_mode" != '160000'; then
+ file_KiB=$(expr '(' $(git cat-file -s "$dst_obj") + 1023 ')' / 1024)
+ test "$file_KiB" -le "$size_max_KiB" || size_too_large
+ fi
+}
+
bad=$(git diff-index --cached $against -- |
sed -n '/^:[^:]/ {s/^://;p;}' |
while read src_mode dst_mode src_obj dst_obj status file; do
if test "$src_mode" != "$dst_mode" -a "$dst_mode" != "000000"; then
check_mode
+ check_size
fi
done)
test -z "$bad" || die "$bad"
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=92c7517435970a4e1abc37292e03ea18302d523d
commit 92c7517435970a4e1abc37292e03ea18302d523d
Author: Brad King <brad.king at kitware.com>
Date: Mon Jun 7 13:27:19 2010 -0400
pre-commit: Rename looks_executable -> mode_looks_exe
Keep all mode-related check helpers in the "mode_" namespace.
diff --git a/pre-commit b/pre-commit
index 00dc848..79b27a0 100755
--- a/pre-commit
+++ b/pre-commit
@@ -83,7 +83,7 @@ Convert them to spaces (2 per TAB) before commit.'
#-----------------------------------------------------------------------------
# Check file modes.
-looks_executable() {
+mode_looks_exe() {
case "$1" in
*.bat) return 0 ;;
*.cmd) return 0 ;;
@@ -103,8 +103,8 @@ mode_non_file () {
}
check_mode() {
case "$dst_mode" in
- 100755) looks_executable "$file" "$dst_obj" || mode_bad_exe ;;
- 100644) looks_executable "$file" "$dst_obj" && mode_not_exe ;;
+ 100755) mode_looks_exe "$file" "$dst_obj" || mode_bad_exe ;;
+ 100644) mode_looks_exe "$file" "$dst_obj" && mode_not_exe ;;
160000) ;;
*) mode_non_file ;;
esac
-----------------------------------------------------------------------
Summary of changes:
pre-commit | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list