[Cmake-commits] CMake branch, hooks, updated. e368fa1290fb1eeb6a0a343f0f73356f852e93f7
Brad King
brad.king at kitware.com
Mon Aug 30 11:31:10 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 e368fa1290fb1eeb6a0a343f0f73356f852e93f7 (commit)
from 19ee713db129db2d2704d1b7ee4bde24e8ce91ad (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=e368fa1290fb1eeb6a0a343f0f73356f852e93f7
commit e368fa1290fb1eeb6a0a343f0f73356f852e93f7
Author: Brad King <brad.king at kitware.com>
AuthorDate: Mon Aug 30 10:02:42 2010 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Aug 30 10:02:42 2010 -0400
pre-commit: Approximate Git 1.7.2 tab-in-indent check
Check for leading TABs in files marked with the whitespace=tab-in-indent
attribute instead of hard-coding a list of file extensions.
diff --git a/pre-commit b/pre-commit
index 76a3081..afaba6c 100755
--- a/pre-commit
+++ b/pre-commit
@@ -68,33 +68,30 @@ fi
# Builtin whitespace checks.
bad=$(git diff-index --check --cached $against --) || die "$bad"
-#-----------------------------------------------------------------------------
-# Reject leading TABs.
+# Approximate whitespace=tab-in-indent check with Git < 1.7.2.
check_tab() {
- git diff-index -p --cached $against -- "$1" |
- grep '^+ ' > /dev/null &&
- echo " $1"
+ lines=$(git diff-index -p --cached $against -- "$1" |
+ grep '^+ ') &&
+ echo "$lines" |
+ while read line; do
+ echo "$1: tab in indent." &&
+ echo "$line"
+ done
}
-check_file() {
- case "$1" in
- *.c) check_tab "$1" ;;
- *.h) check_tab "$1" ;;
- *.cxx) check_tab "$1" ;;
- *.txx) check_tab "$1" ;;
- *.hxx) check_tab "$1" ;;
- *.htm) check_tab "$1" ;;
- *.html) check_tab "$1" ;;
- *.txt) check_tab "$1" ;;
- *.cmake) check_tab "$1" ;;
+approx_tab_in_indent() {
+ ws=$(git check-attr whitespace -- "$file" |
+ sed 's/^[^:]*: whitespace: //')
+ case ",$ws," in
+ *,tab-in-indent,*) check_tab "$1" ;;
esac
}
-bad=$(git diff-index --name-only --cached $against -- |
-while read file; do
- check_file "$file"
-done)
-test -z "$bad" || die 'Leading TABs added in
-'"$bad"'
-Convert them to spaces (2 per TAB) before commit.'
+if git --version | grep " \(1\.[0-6]\|1\.7\.[01]\)" >/dev/null; then
+ bad=$(git diff-index --name-only --cached $against -- |
+ while read file; do
+ approx_tab_in_indent "$file"
+ done)
+ test -z "$bad" || die "$bad"
+fi
#-----------------------------------------------------------------------------
# Check file modes and sizes.
-----------------------------------------------------------------------
Summary of changes:
pre-commit | 43 ++++++++++++++++++++-----------------------
1 files changed, 20 insertions(+), 23 deletions(-)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list