[Cmake-commits] CMake branch, hooks, created. 7cd6238240d440f0a69a0f4e8eecc3b2a23a1973

cmake-commits at cmake.org cmake-commits at cmake.org
Mon May 3 08:23:56 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 created
        at  7cd6238240d440f0a69a0f4e8eecc3b2a23a1973 (commit)

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7cd6238240d440f0a69a0f4e8eecc3b2a23a1973
commit 7cd6238240d440f0a69a0f4e8eecc3b2a23a1973
Author: Brad King <brad.king at kitware.com>
Date:   Wed Apr 28 13:35:19 2010 -0400

    commit-msg: Exclude diff during "git commit -v"
    
    Stop processing the commit message text at a "diff --git" line.  Such
    lines occur when the user commits with the "-v" option.  We should not
    check the patch content; it will be stripped by Git anyway.

diff --git a/commit-msg b/commit-msg
index e47ec0f..3953b37 100755
--- a/commit-msg
+++ b/commit-msg
@@ -2,9 +2,11 @@
 #
 # Copy or link this file as ".git/hooks/pre-commit".
 
-# Prepare a backup message without comments.
+# Prepare a copy of the message:
+#  - strip comment lines
+#  - stop at "diff --git" (git commit -v)
 commit_msg="$GIT_DIR/COMMIT_MSG"
-grep -v '^#' "$1" > "$commit_msg"
+sed -n -e '/^#/d' -e '/^diff --git/q' -e 'p;d' "$1" > "$commit_msg"
 
 die() {
 	echo 'commit-msg hook failure' 1>&2

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0df83855da1e4dcf59bdfe22a939d3f1ddf2a02a
commit 0df83855da1e4dcf59bdfe22a939d3f1ddf2a02a
Author: Brad King <brad.king at kitware.com>
Date:   Tue Apr 27 13:55:06 2010 -0400

    pre-commit: Workaround shell syntax limitations
    
    Commit "Reject leading TABs" added use of shell syntax of the form
    
      $(case "..." in
         a) ... ;;
        esac)
    
    Some shell implementations fail to recognize that the ')' in the case
    label is not the end of the '$(' expression.  Work around the problem
    by moving the case block into a separate function outside the '$()'
    expression.

diff --git a/pre-commit b/pre-commit
index 858842e..14e03ab 100755
--- a/pre-commit
+++ b/pre-commit
@@ -58,19 +58,22 @@ check_tab() {
 	grep '^+	' > /dev/null &&
 	echo "  $1"
 }
+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" ;;
+	esac
+}
 bad=$(git diff-index --name-only --cached $against -- |
 while read file; do
-	case "$file" in
-		*.c)		check_tab "$file" ;;
-		*.h)		check_tab "$file" ;;
-		*.cxx)		check_tab "$file" ;;
-		*.txx)		check_tab "$file" ;;
-		*.hxx)		check_tab "$file" ;;
-		*.htm)		check_tab "$file" ;;
-		*.html)		check_tab "$file" ;;
-		*.txt)		check_tab "$file" ;;
-		*.cmake)	check_tab "$file" ;;
-	esac
+	check_file "$file"
 done)
 test -z "$bad" || die 'Leading TABs added in
 '"$bad"'

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f226aad5a424de464def3eaf4202d55271e1337f
commit f226aad5a424de464def3eaf4202d55271e1337f
Author: Brad King <brad.king at kitware.com>
Date:   Fri Apr 23 15:49:01 2010 -0400

    pre-commit: Reject leading TABs
    
    Our style guidelines do not permit indentation by TABs.

diff --git a/pre-commit b/pre-commit
index c106875..858842e 100755
--- a/pre-commit
+++ b/pre-commit
@@ -51,3 +51,27 @@ fi
 
 # Builtin whitespace checks.
 bad=$(git diff-index --check --cached $against --) || die "$bad"
+
+# Reject leading TABs.
+check_tab() {
+	git diff-index -p --cached $against -- "$1" |
+	grep '^+	' > /dev/null &&
+	echo "  $1"
+}
+bad=$(git diff-index --name-only --cached $against -- |
+while read file; do
+	case "$file" in
+		*.c)		check_tab "$file" ;;
+		*.h)		check_tab "$file" ;;
+		*.cxx)		check_tab "$file" ;;
+		*.txx)		check_tab "$file" ;;
+		*.hxx)		check_tab "$file" ;;
+		*.htm)		check_tab "$file" ;;
+		*.html)		check_tab "$file" ;;
+		*.txt)		check_tab "$file" ;;
+		*.cmake)	check_tab "$file" ;;
+	esac
+done)
+test -z "$bad" || die 'Leading TABs added in
+'"$bad"'
+Convert them to spaces (2 per TAB) before commit.'

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5395049e7f82a5f92e4b08ec1a939af239bd2fcd
commit 5395049e7f82a5f92e4b08ec1a939af239bd2fcd
Author: Brad King <brad.king at kitware.com>
Date:   Thu Apr 22 11:42:14 2010 -0400

    commit-msg: Preserve bad message for user to fix
    
    Store a backup copy of the input message.  Remove the backup only on
    success.  On failure, tell the user how to use and edit the message
    without having to enter it from scratch.

diff --git a/commit-msg b/commit-msg
index 80f4971..e47ec0f 100755
--- a/commit-msg
+++ b/commit-msg
@@ -2,11 +2,18 @@
 #
 # Copy or link this file as ".git/hooks/pre-commit".
 
+# Prepare a backup message without comments.
+commit_msg="$GIT_DIR/COMMIT_MSG"
+grep -v '^#' "$1" > "$commit_msg"
+
 die() {
 	echo 'commit-msg hook failure' 1>&2
 	echo '-----------------------' 1>&2
 	echo '' 1>&2
 	echo "$@" 1>&2
+	echo 'To continue editing, run the command
+  git commit -e -F '"$commit_msg"'
+(assuming your working directory is at the top).' 1>&2
 	exit 1
 }
 
@@ -51,7 +58,8 @@ msg_rest() {
 
 # Pipe commit message into the state machine.
 state=first
-cat "$1" | grep -v '^#' |
+cat "$commit_msg" |
 while read line; do
 	msg_$state || break
-done
+done &&
+rm -f "$commit_msg"

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2b3a3cd7a6fc5f217e9ee628ca5e348165be002a
commit 2b3a3cd7a6fc5f217e9ee628ca5e348165be002a
Author: Brad King <brad.king at kitware.com>
Date:   Tue Apr 20 11:28:25 2010 -0400

    pre-commit: Validate user.name and user.email

diff --git a/pre-commit b/pre-commit
index 442fe9a..c106875 100755
--- a/pre-commit
+++ b/pre-commit
@@ -12,15 +12,25 @@ die() {
 
 #-----------------------------------------------------------------------------
 # Check for committer identity.
-git config --get user.name > /dev/null &&
-git config --get user.email > /dev/null ||
-die 'Identity not configured!  Use the commands
+advice='
+Use the commands
 
 	git config --global user.name '\''Your Name'\''
 	git config --global user.email '\''you at yourdomain.com'\''
 
 to introduce yourself to Git before committing.'
 
+# Ensure name and email are available.
+git config --get user.name > /dev/null &&
+git config --get user.email > /dev/null ||
+die 'Identity not configured!' "$advice"
+
+# Validate the name and email.
+git config --get user.name | grep ' ' > /dev/null ||
+die 'Set user.name to your Real Name (with a space), not a userid.' "$advice"
+git config --get user.email | grep '^[^@]*@[^@]*$' > /dev/null ||
+die 'Set user.email to an email address (userid at validdomain.com).' "$advice"
+
 #-----------------------------------------------------------------------------
 # Check content that will be added by this commit.
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8f96d67507bba38e884aa6d4643d2af0147c2b65
commit 8f96d67507bba38e884aa6d4643d2af0147c2b65
Author: Brad King <brad.king at kitware.com>
Date:   Thu Apr 1 15:33:56 2010 -0400

    Teach Git to ignore sample hooks

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a5a3854
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.sample

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=68d1d3b4aff40df4cd35f33cf2ecad7d9b9a56ca
commit 68d1d3b4aff40df4cd35f33cf2ecad7d9b9a56ca
Author: Brad King <brad.king at kitware.com>
Date:   Wed Mar 31 17:39:00 2010 -0400

    Prototype pre-commit and commit-msg hook scripts
    
    These hooks perform some basic commit-time checks to keep history clean.

diff --git a/commit-msg b/commit-msg
new file mode 100755
index 0000000..80f4971
--- /dev/null
+++ b/commit-msg
@@ -0,0 +1,57 @@
+#!/bin/sh
+#
+# Copy or link this file as ".git/hooks/pre-commit".
+
+die() {
+	echo 'commit-msg hook failure' 1>&2
+	echo '-----------------------' 1>&2
+	echo '' 1>&2
+	echo "$@" 1>&2
+	exit 1
+}
+
+#-----------------------------------------------------------------------------
+# Check the commit message layout with a simple state machine.
+
+msg_first() {
+	len=$(echo -n "$line" | wc -c)
+	if test $len -eq 0; then
+		# not yet first line
+		return
+	elif test $len -lt 8; then
+		die 'The first line must be at least 8 characters:
+--------
+'"$line"'
+--------
+'
+	elif test $len -gt 78; then
+		die 'The first line may be at most 78 characters:
+------------------------------------------------------------------------------
+'"$line"'
+------------------------------------------------------------------------------
+'
+	else
+		# first line okay
+		state=second
+	fi
+}
+
+msg_second() {
+	if test "x$line" != "x"; then
+		die 'The second line must be empty:
+'"$line"
+	else
+		state=rest
+	fi
+}
+
+msg_rest() {
+	false
+}
+
+# Pipe commit message into the state machine.
+state=first
+cat "$1" | grep -v '^#' |
+while read line; do
+	msg_$state || break
+done
diff --git a/pre-commit b/pre-commit
new file mode 100755
index 0000000..442fe9a
--- /dev/null
+++ b/pre-commit
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# Copy or link this file as ".git/hooks/pre-commit".
+
+die() {
+	echo 'pre-commit hook failure' 1>&2
+	echo '-----------------------' 1>&2
+	echo '' 1>&2
+	echo "$@" 1>&2
+	exit 1
+}
+
+#-----------------------------------------------------------------------------
+# Check for committer identity.
+git config --get user.name > /dev/null &&
+git config --get user.email > /dev/null ||
+die 'Identity not configured!  Use the commands
+
+	git config --global user.name '\''Your Name'\''
+	git config --global user.email '\''you at yourdomain.com'\''
+
+to introduce yourself to Git before committing.'
+
+#-----------------------------------------------------------------------------
+# Check content that will be added by this commit.
+
+if git rev-parse --verify -q HEAD > /dev/null; then
+	against=HEAD
+else
+	# Initial commit: diff against an empty tree object
+	against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
+fi
+
+# Disallow non-ascii file names.  The printable range starts at the
+# space character and ends with tilde.
+if test "$(git diff --cached --name-only --diff-filter=A -z $against |
+	   LC_ALL=C tr -d '[ -~]\0')"; then
+	die 'Non-ascii file names may not be added:
+'"$(git diff --cached --name-only --diff-filter=A $against)"
+fi
+
+# Builtin whitespace checks.
+bad=$(git diff-index --check --cached $against --) || die "$bad"

-----------------------------------------------------------------------


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list