[Cmake-commits] CMake branch, hooks, updated. ad08c2091c710f886c2d8a827bb3c90d8b8a9d03
cmake-commits at cmake.org
cmake-commits at cmake.org
Mon Oct 24 09:35:43 EDT 2011
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 ad08c2091c710f886c2d8a827bb3c90d8b8a9d03 (commit)
via 4b2beb61ef92a7d8633d3fe0da888fe0ed99f561 (commit)
via 389c117192ee911af4e6afb42c53f70784cab71e (commit)
via 3bde0fa936309c7723608951460c38d9484040df (commit)
via 18358af31028ee70d3ae9d60851a2051b1994d75 (commit)
via e8180f209b8bf5255ba7ca4833728cb085cdd323 (commit)
via f059ba93878b33edf6280aae917bdf4948b8f82b (commit)
via 69b19172e436eb0911c4dd362470364c694478bb (commit)
from bc6d41f4d2c9b0c4645aaf6be4d92429bf52fab6 (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=ad08c2091c710f886c2d8a827bb3c90d8b8a9d03
commit ad08c2091c710f886c2d8a827bb3c90d8b8a9d03
Merge: 3bde0fa 4b2beb6
Author: Brad King <brad.king at kitware.com>
AuthorDate: Mon Oct 24 09:33:21 2011 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 24 09:33:21 2011 -0400
Merge branch 'itk-hook-cleanup' into hooks
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4b2beb61ef92a7d8633d3fe0da888fe0ed99f561
commit 4b2beb61ef92a7d8633d3fe0da888fe0ed99f561
Author: Matt McCormick <matt.mccormick at kitware.com>
AuthorDate: Fri Oct 21 13:52:49 2011 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 24 09:26:21 2011 -0400
Remove pre-commit-style.
These pre-commit hooks where added to the ITK specific hook chain since all
projects do not use them.
Change-Id: Ifcb41645374914c4f30f7c5f2feb2e5d40a4b3e3
diff --git a/pre-commit b/pre-commit
index f46cf5d..1a937e1 100755
--- a/pre-commit
+++ b/pre-commit
@@ -319,10 +319,6 @@ done
test -z "$bad" || die "$bad"
#-----------------------------------------------------------------------------
-# Style hooks.
-. "$GIT_DIR/hooks/pre-commit-style"
-
-#-----------------------------------------------------------------------------
# Chain to project-specific hook.
. "$GIT_DIR/hooks/hooks-chain.bash"
hooks_chain pre-commit "$@"
diff --git a/pre-commit-style b/pre-commit-style
deleted file mode 100644
index 8c22704..0000000
--- a/pre-commit-style
+++ /dev/null
@@ -1,266 +0,0 @@
-#=============================================================================
-# Copyright 2010-2011 Kitware, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#=============================================================================
-
-# Run uncrustify and KWStyle pre-commit hooks.
-#
-# 'git config' is used to enable the hooks and set their configuration files.
-# The repository .gitattributes must also enable the hooks on the targeted
-# files.
-
-do_KWStyle=$(git config --bool hooks.KWStyle) || do_KWStyle=false
-
-do_uncrustify=$(git config --bool hooks.uncrustify) || do_uncrustify=false
-
-#-----------------------------------------------------------------------------
-# Check if we want to run the style on a given file. Uses git attributes. If
-# the hook.style attribute is set, then all styles are executed. If the
-# hook.style attribute is set to a value, only the values given are executed.
-# Also, do not run the style check if there are unstaged changes in the file.
-# The first positional parameter is the file to check.
-# The second positional parameter is the style to check.
-# Returns 0 for execute, 1 for don't execute.
-run_style_on_file() {
- # Do not run on submodule changes.
- if git diff-index --cached $against -- "$1" | grep -q '^:...... 160000'; then
- return 1
- fi
- if ! git diff-files --quiet -- "$1"; then
- # A way to always allow skipping.
- skip_unstaged=$(git config --bool hooks.styleSkipUnstaged) ||
- skip_unstaged=false
- file_sha=$(git diff-index --cached --abbrev=7 $against -- "$1" | \
- awk '{print substr($3,1,9) substr($4,1,7)}')
- if file_skip_unstaged=$(git config "hooks.$1.styleSkipUnstaged"); then
- if test ",$file_skip_unstaged," = ",$file_sha," -o \
- ",$file_skip_unstaged," = ",true,"; then
- skip_unstaged=true
- fi
- fi
-
- if $skip_unstaged; then
- echo "The file '$1' contains unstaged stages. Skipping style \
-check '$2'."
- else
- die "Style check '$2' cannot run on '$1' with unstaged stages.
-
-Allow skipping the style check for this commit with
-
- git config \"hooks.$1.styleSkipUnstaged\" $file_sha"
- fi
- return 1
- fi
- style=$(git check-attr hooks.style -- "$1" |
- sed 's/^[^:]*: hooks.style: //')
- case "$style" in
- 'unset') return 1 ;;
- 'set') return 0 ;;
- 'unspecified') return 1 ;;
- *) echo ",$style," | grep -iq ",$2," && return 0 ;;
- esac
- return 1
-}
-
-#-----------------------------------------------------------------------------
-# KWStyle.
-check_for_KWStyle() {
- KWStyle_path=$(git config hooks.KWStyle.path) ||
- KWStyle_path=$(which KWStyle)
- if [ $? != 0 ] ; then
- echo "KWStyle executable was not found.
-
- No style verification will be performed with KWStyle!
-
-Please install KWStyle or set the executable location with
-
- git config hooks.KWStyle.path /path/to/KWStyle
-
-See http://public.kitware.com/KWStyle/
-" >&2
- return 1
- fi
- KWStyle_conf=$(git config hooks.KWStyle.conf)
- if ! test -f "$KWStyle_conf"; then
- die "The file '$KWStyle_conf' does not exist.
-
-Please run
-
- git config hooks.KWStyle.conf path/to/KWStyle.conf.xml"
- fi
- KWStyle_overWriteRulesConf=$(git config hooks.KWStyle.overwriteRulesConf)
- if test $? -eq 0 && ! test -f "$KWStyle_overWriteRulesConf"; then
- die "The hooks.KWStyle.overwriteRulesConf file '$KWStyle_overWriteRulesConf' does not exist."
- fi
-}
-
-run_KWStyle_on_file() {
- if test -z "$KWStyle_overWriteRulesConf"; then
- "$KWStyle_path" -v -xml "$KWStyle_conf" "$1"
- else
- "$KWStyle_path" -v -xml "$KWStyle_conf" -o "$KWStyle_overWriteRulesConf" "$1"
- fi
-
- if test $? -ne 0; then
- cp -- "$1"{,.kws}
- die "KWStyle check failed.
-
-Line numbers in the errors shown refer to the file:
-${1}.kws"
- fi
-}
-
-run_KWStyle() {
- git diff-index --cached --diff-filter=ACMR --name-only $against -- |
- while read f; do
- if run_style_on_file "$f" KWStyle; then
- run_KWStyle_on_file "$f"
- fi || return
- done
-}
-
-#-----------------------------------------------------------------------------
-# uncrustify.
-check_for_uncrustify() {
- uncrustify_path=$(git config hooks.uncrustify.path) ||
- uncrustify_path=$(which uncrustify) ||
- die "uncrustify executable was not found.
-
-Please install uncrustify or set the executable location with
-
- git config hooks.uncrustify.path /path/to/uncrustify
-
- See http://uncrustify.sourceforge.net/"
-
- uncrustify_conf=$(git config hooks.uncrustify.conf)
- if ! test -f "$uncrustify_conf"; then
- die "The file '$uncrustify_conf' does not exist.
-
-Please run
-
- git config hooks.uncrustify.conf path/to/uncrustify.conf"
- fi
-}
-
-run_uncrustify_on_file() {
- MERGED="$1"
- if run_style_on_file "$MERGED" uncrustify; then
- ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
- BACKUP="./$MERGED.BACKUP.$ext"
- LOCAL="./$MERGED.STAGED.$ext"
- REMOTE="./$MERGED.UNCRUSTIFY.$ext"
- NEW_MERGED="./$MERGED.NEW.$ext"
- OLD_MERGED="$MERGED"
-
- mv -- "$MERGED" "$BACKUP"
- # We temporarily change MERGED because the file might already be open, and
- # the text editor may complain.
- MERGED="$NEW_MERGED"
- cp -- "$BACKUP" "$MERGED"
- cp -- "$BACKUP" "$LOCAL"
-
- if ! "$uncrustify_path" -c "$uncrustify_conf" -f "$LOCAL" \
- -o "$REMOTE" 2> /dev/null; then
- mv -- "$BACKUP" "$OLD_MERGED"
-
- if test "$merge_keep_temporaries" = "false"; then
- rm -f -- "$LOCAL" "$REMOTE" "$BACKUP"
- fi
-
- die "error when running uncrustify on $OLD_MERGED"
- fi
-
- if test $(git hash-object -- "$LOCAL") != $(git hash-object -- "$REMOTE") &&
- ! run_merge_tool "$merge_tool" "false" </dev/tty; then
- mv -- "$BACKUP" "$OLD_MERGED"
-
- if test "$merge_keep_temporaries" = "false"; then
- rm -f -- "$LOCAL" "$REMOTE" "$BACKUP" "$NEW_MERGED"
- fi
-
- die "uncrustify merge of $OLD_MERGED failed"
- fi
-
- mv -- "$NEW_MERGED" "$OLD_MERGED"
- MERGED="$OLD_MERGED"
-
- if test "$merge_keep_backup" = "true"; then
- mv -- "$BACKUP" "$MERGED.orig"
- else
- rm -- "$BACKUP"
- fi
-
- git add -- "$MERGED"
- rm -f -- "$LOCAL" "$REMOTE" "$BACKUP"
-
- fi # end if run uncrustify on file
-
- if $do_KWStyle &&
- $have_KWStyle &&
- run_style_on_file "$MERGED" KWStyle
- then
- run_KWStyle_on_file "$MERGED"
- else
- return 0
- fi
-}
-
-run_uncrustify() {
- $do_KWStyle && check_for_KWStyle
- if test $?; then
- have_KWStyle=false
- else
- have_KWStyle=true
- fi
-
- merge_tool=$(get_merge_tool "$merge_tool") || die "Merge tool not configured.
-
-Set the merge tool with
-
- git config merge.tool <toolname>
-
-For more information, see
-
- git help mergetool"
- merge_keep_backup="$(git config --bool mergetool.keepBackup || echo true)"
- merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)"
- git diff-index --cached --diff-filter=ACMR --name-only $against -- |
- while read MERGED; do
- run_uncrustify_on_file "$MERGED" || return
- done # end for changed files
-}
-
-# Do not run during merge commits for now.
-if test -f "$GIT_DIR/MERGE_HEAD"; then
- :
-elif $do_uncrustify; then
- # We use git-mergetool settings to review the uncrustify changes.
- TOOL_MODE=merge
- . "$(git --exec-path)/git-mergetool--lib"
- # Redefine check_unchanged because we do not need to check if the merge was
- # successful.
- check_unchanged() {
- status=0
- }
- check_for_uncrustify
- run_uncrustify || exit 1
-# do_uncrustify will run KWStyle on the files incrementally so excessive
-# uncrustify merges do not have to occur.
-elif $do_KWStyle; then
- if check_for_KWStyle; then
- run_KWStyle || exit 1
- fi
-fi
-
-# vim: set filetype=sh tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab :
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=389c117192ee911af4e6afb42c53f70784cab71e
commit 389c117192ee911af4e6afb42c53f70784cab71e
Author: Matt McCormick <matt.mccormick at kitware.com>
AuthorDate: Fri Oct 21 13:39:39 2011 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 24 09:25:47 2011 -0400
Remove .txx pre-commit check.
This is an ITK specific check. It is already implemented in
the ITK Utilities/Hooks/pre-commit script executed in the hook chain.
This should allow commiting when on the ITK release branch where .txx
files still currently exist.
Change-Id: I1115a2129beb89d6657d599aa6e72bb6515dfca3
diff --git a/pre-commit b/pre-commit
index 4bc6c6b..f46cf5d 100755
--- a/pre-commit
+++ b/pre-commit
@@ -300,22 +300,6 @@ done
test -z "$bad" || die "$bad"
#-----------------------------------------------------------------------------
-# Do not allow adding of files with .txx extension.
-diffs_added=$(git diff-index --diff-filter=A --cached $against -- |
- sed -n '/^:[^:]/ {s/^://;p;}')
-diffs_normal_added=$(echo "$diffs" | grep -v '^...... 160000')
-bad=$(
-test -n "$diffs_normal" && echo "$diffs_normal" |
-while read src_mode dst_mode src_obj dst_obj status file; do
- if echo "$file" | grep -q -E '\.txx$'; then
- echo "Attempted to add file $file."
- echo "Files with the .txx extension are not allowed -- use .hxx instead."
- fi
-done
-)
-test -z "$bad" || die "$bad"
-
-#-----------------------------------------------------------------------------
# Merge checks.
if test -n "$merge_head"; then
merge_diffs=$(git diff-index --cached $merge_head -- |
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3bde0fa936309c7723608951460c38d9484040df
commit 3bde0fa936309c7723608951460c38d9484040df
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu Oct 6 18:09:05 2011 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Oct 6 18:11:15 2011 -0400
hooks-chain: Look for chains in project hooks config
If a local hook chain rule is not in the local git configuration
check for a value defined in .hooks-config.bash:
hooks_chain_pre_commit
hooks_chain_commit_msg
hooks_chain_prepare_commit_msg
This allows project to configure chained hooks without adding any
values to the local git configuration. Since the project hooks
config can be versioned with the hook scripts it references this
ensures a consistent state.
diff --git a/hooks-chain.bash b/hooks-chain.bash
index a4c7544..7aca6ce 100644
--- a/hooks-chain.bash
+++ b/hooks-chain.bash
@@ -16,7 +16,9 @@
hooks_chain() {
hook="$1" ; shift
- chain=$(git config --get hooks.chain-$hook) || return 0
+ chain=$(git config --get hooks.chain-$hook) ||
+ eval chain="\${hooks_chain_${hook//-/_}}"
+ test -n "$chain" || return 0
case "$chain" in
'/'*) prefix="" ;;
'[A-Za-z]:/'*) prefix="" ;;
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=18358af31028ee70d3ae9d60851a2051b1994d75
commit 18358af31028ee70d3ae9d60851a2051b1994d75
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu Oct 6 17:56:05 2011 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Oct 6 17:56:05 2011 -0400
Load local hooks configuration from work tree
Look for a ".hooks-config.bash" file at the top of the work tree.
Load it in each hook to get per-project configuration. Currently
we do not define any config options, but this adds the framework.
diff --git a/commit-msg b/commit-msg
index 414285f..8c0562e 100755
--- a/commit-msg
+++ b/commit-msg
@@ -35,6 +35,8 @@ die() {
exit 1
}
+. "$GIT_DIR/hooks/hooks-config.bash"
+
#-----------------------------------------------------------------------------
# Check the commit message layout with a simple state machine.
diff --git a/prepare-commit-msg b/hooks-config.bash
old mode 100755
new mode 100644
similarity index 78%
copy from prepare-commit-msg
copy to hooks-config.bash
index b791fbf..a25d7d1
--- a/prepare-commit-msg
+++ b/hooks-config.bash
@@ -1,4 +1,3 @@
-#!/usr/bin/env bash
#=============================================================================
# Copyright 2010-2011 Kitware, Inc.
#
@@ -15,7 +14,7 @@
# limitations under the License.
#=============================================================================
-#-----------------------------------------------------------------------------
-# Chain to project-specific hook.
-. "$GIT_DIR/hooks/hooks-chain.bash"
-hooks_chain prepare-commit-msg "$@"
+# Load hooks configuration from source tree.
+config=".hooks-config.bash" && test -r "$config" && . "$config"
+
+# vim: set filetype=sh tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab :
diff --git a/pre-commit b/pre-commit
index 1a937e1..b2cfe2d 100755
--- a/pre-commit
+++ b/pre-commit
@@ -23,6 +23,8 @@ die() {
exit 1
}
+. "$GIT_DIR/hooks/hooks-config.bash"
+
zero='0000000000000000000000000000000000000000'
#-----------------------------------------------------------------------------
diff --git a/prepare-commit-msg b/prepare-commit-msg
index b791fbf..f2bd2ab 100755
--- a/prepare-commit-msg
+++ b/prepare-commit-msg
@@ -15,6 +15,8 @@
# limitations under the License.
#=============================================================================
+. "$GIT_DIR/hooks/hooks-config.bash"
+
#-----------------------------------------------------------------------------
# Chain to project-specific hook.
. "$GIT_DIR/hooks/hooks-chain.bash"
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e8180f209b8bf5255ba7ca4833728cb085cdd323
commit e8180f209b8bf5255ba7ca4833728cb085cdd323
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu Oct 6 13:34:51 2011 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Oct 6 13:34:51 2011 -0400
pre-commit: Remove KWStyle and uncrustify support
These checks can be added in projects that want them using the
pre-commit hook chaining.
diff --git a/pre-commit b/pre-commit
index f46cf5d..1a937e1 100755
--- a/pre-commit
+++ b/pre-commit
@@ -319,10 +319,6 @@ done
test -z "$bad" || die "$bad"
#-----------------------------------------------------------------------------
-# Style hooks.
-. "$GIT_DIR/hooks/pre-commit-style"
-
-#-----------------------------------------------------------------------------
# Chain to project-specific hook.
. "$GIT_DIR/hooks/hooks-chain.bash"
hooks_chain pre-commit "$@"
diff --git a/pre-commit-style b/pre-commit-style
deleted file mode 100644
index 8c22704..0000000
--- a/pre-commit-style
+++ /dev/null
@@ -1,266 +0,0 @@
-#=============================================================================
-# Copyright 2010-2011 Kitware, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#=============================================================================
-
-# Run uncrustify and KWStyle pre-commit hooks.
-#
-# 'git config' is used to enable the hooks and set their configuration files.
-# The repository .gitattributes must also enable the hooks on the targeted
-# files.
-
-do_KWStyle=$(git config --bool hooks.KWStyle) || do_KWStyle=false
-
-do_uncrustify=$(git config --bool hooks.uncrustify) || do_uncrustify=false
-
-#-----------------------------------------------------------------------------
-# Check if we want to run the style on a given file. Uses git attributes. If
-# the hook.style attribute is set, then all styles are executed. If the
-# hook.style attribute is set to a value, only the values given are executed.
-# Also, do not run the style check if there are unstaged changes in the file.
-# The first positional parameter is the file to check.
-# The second positional parameter is the style to check.
-# Returns 0 for execute, 1 for don't execute.
-run_style_on_file() {
- # Do not run on submodule changes.
- if git diff-index --cached $against -- "$1" | grep -q '^:...... 160000'; then
- return 1
- fi
- if ! git diff-files --quiet -- "$1"; then
- # A way to always allow skipping.
- skip_unstaged=$(git config --bool hooks.styleSkipUnstaged) ||
- skip_unstaged=false
- file_sha=$(git diff-index --cached --abbrev=7 $against -- "$1" | \
- awk '{print substr($3,1,9) substr($4,1,7)}')
- if file_skip_unstaged=$(git config "hooks.$1.styleSkipUnstaged"); then
- if test ",$file_skip_unstaged," = ",$file_sha," -o \
- ",$file_skip_unstaged," = ",true,"; then
- skip_unstaged=true
- fi
- fi
-
- if $skip_unstaged; then
- echo "The file '$1' contains unstaged stages. Skipping style \
-check '$2'."
- else
- die "Style check '$2' cannot run on '$1' with unstaged stages.
-
-Allow skipping the style check for this commit with
-
- git config \"hooks.$1.styleSkipUnstaged\" $file_sha"
- fi
- return 1
- fi
- style=$(git check-attr hooks.style -- "$1" |
- sed 's/^[^:]*: hooks.style: //')
- case "$style" in
- 'unset') return 1 ;;
- 'set') return 0 ;;
- 'unspecified') return 1 ;;
- *) echo ",$style," | grep -iq ",$2," && return 0 ;;
- esac
- return 1
-}
-
-#-----------------------------------------------------------------------------
-# KWStyle.
-check_for_KWStyle() {
- KWStyle_path=$(git config hooks.KWStyle.path) ||
- KWStyle_path=$(which KWStyle)
- if [ $? != 0 ] ; then
- echo "KWStyle executable was not found.
-
- No style verification will be performed with KWStyle!
-
-Please install KWStyle or set the executable location with
-
- git config hooks.KWStyle.path /path/to/KWStyle
-
-See http://public.kitware.com/KWStyle/
-" >&2
- return 1
- fi
- KWStyle_conf=$(git config hooks.KWStyle.conf)
- if ! test -f "$KWStyle_conf"; then
- die "The file '$KWStyle_conf' does not exist.
-
-Please run
-
- git config hooks.KWStyle.conf path/to/KWStyle.conf.xml"
- fi
- KWStyle_overWriteRulesConf=$(git config hooks.KWStyle.overwriteRulesConf)
- if test $? -eq 0 && ! test -f "$KWStyle_overWriteRulesConf"; then
- die "The hooks.KWStyle.overwriteRulesConf file '$KWStyle_overWriteRulesConf' does not exist."
- fi
-}
-
-run_KWStyle_on_file() {
- if test -z "$KWStyle_overWriteRulesConf"; then
- "$KWStyle_path" -v -xml "$KWStyle_conf" "$1"
- else
- "$KWStyle_path" -v -xml "$KWStyle_conf" -o "$KWStyle_overWriteRulesConf" "$1"
- fi
-
- if test $? -ne 0; then
- cp -- "$1"{,.kws}
- die "KWStyle check failed.
-
-Line numbers in the errors shown refer to the file:
-${1}.kws"
- fi
-}
-
-run_KWStyle() {
- git diff-index --cached --diff-filter=ACMR --name-only $against -- |
- while read f; do
- if run_style_on_file "$f" KWStyle; then
- run_KWStyle_on_file "$f"
- fi || return
- done
-}
-
-#-----------------------------------------------------------------------------
-# uncrustify.
-check_for_uncrustify() {
- uncrustify_path=$(git config hooks.uncrustify.path) ||
- uncrustify_path=$(which uncrustify) ||
- die "uncrustify executable was not found.
-
-Please install uncrustify or set the executable location with
-
- git config hooks.uncrustify.path /path/to/uncrustify
-
- See http://uncrustify.sourceforge.net/"
-
- uncrustify_conf=$(git config hooks.uncrustify.conf)
- if ! test -f "$uncrustify_conf"; then
- die "The file '$uncrustify_conf' does not exist.
-
-Please run
-
- git config hooks.uncrustify.conf path/to/uncrustify.conf"
- fi
-}
-
-run_uncrustify_on_file() {
- MERGED="$1"
- if run_style_on_file "$MERGED" uncrustify; then
- ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
- BACKUP="./$MERGED.BACKUP.$ext"
- LOCAL="./$MERGED.STAGED.$ext"
- REMOTE="./$MERGED.UNCRUSTIFY.$ext"
- NEW_MERGED="./$MERGED.NEW.$ext"
- OLD_MERGED="$MERGED"
-
- mv -- "$MERGED" "$BACKUP"
- # We temporarily change MERGED because the file might already be open, and
- # the text editor may complain.
- MERGED="$NEW_MERGED"
- cp -- "$BACKUP" "$MERGED"
- cp -- "$BACKUP" "$LOCAL"
-
- if ! "$uncrustify_path" -c "$uncrustify_conf" -f "$LOCAL" \
- -o "$REMOTE" 2> /dev/null; then
- mv -- "$BACKUP" "$OLD_MERGED"
-
- if test "$merge_keep_temporaries" = "false"; then
- rm -f -- "$LOCAL" "$REMOTE" "$BACKUP"
- fi
-
- die "error when running uncrustify on $OLD_MERGED"
- fi
-
- if test $(git hash-object -- "$LOCAL") != $(git hash-object -- "$REMOTE") &&
- ! run_merge_tool "$merge_tool" "false" </dev/tty; then
- mv -- "$BACKUP" "$OLD_MERGED"
-
- if test "$merge_keep_temporaries" = "false"; then
- rm -f -- "$LOCAL" "$REMOTE" "$BACKUP" "$NEW_MERGED"
- fi
-
- die "uncrustify merge of $OLD_MERGED failed"
- fi
-
- mv -- "$NEW_MERGED" "$OLD_MERGED"
- MERGED="$OLD_MERGED"
-
- if test "$merge_keep_backup" = "true"; then
- mv -- "$BACKUP" "$MERGED.orig"
- else
- rm -- "$BACKUP"
- fi
-
- git add -- "$MERGED"
- rm -f -- "$LOCAL" "$REMOTE" "$BACKUP"
-
- fi # end if run uncrustify on file
-
- if $do_KWStyle &&
- $have_KWStyle &&
- run_style_on_file "$MERGED" KWStyle
- then
- run_KWStyle_on_file "$MERGED"
- else
- return 0
- fi
-}
-
-run_uncrustify() {
- $do_KWStyle && check_for_KWStyle
- if test $?; then
- have_KWStyle=false
- else
- have_KWStyle=true
- fi
-
- merge_tool=$(get_merge_tool "$merge_tool") || die "Merge tool not configured.
-
-Set the merge tool with
-
- git config merge.tool <toolname>
-
-For more information, see
-
- git help mergetool"
- merge_keep_backup="$(git config --bool mergetool.keepBackup || echo true)"
- merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)"
- git diff-index --cached --diff-filter=ACMR --name-only $against -- |
- while read MERGED; do
- run_uncrustify_on_file "$MERGED" || return
- done # end for changed files
-}
-
-# Do not run during merge commits for now.
-if test -f "$GIT_DIR/MERGE_HEAD"; then
- :
-elif $do_uncrustify; then
- # We use git-mergetool settings to review the uncrustify changes.
- TOOL_MODE=merge
- . "$(git --exec-path)/git-mergetool--lib"
- # Redefine check_unchanged because we do not need to check if the merge was
- # successful.
- check_unchanged() {
- status=0
- }
- check_for_uncrustify
- run_uncrustify || exit 1
-# do_uncrustify will run KWStyle on the files incrementally so excessive
-# uncrustify merges do not have to occur.
-elif $do_KWStyle; then
- if check_for_KWStyle; then
- run_KWStyle || exit 1
- fi
-fi
-
-# vim: set filetype=sh tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab :
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f059ba93878b33edf6280aae917bdf4948b8f82b
commit f059ba93878b33edf6280aae917bdf4948b8f82b
Author: Matt McCormick <matt.mccormick at kitware.com>
AuthorDate: Fri Jul 15 20:39:30 2011 -0400
Commit: David Cole <david.cole at kitware.com>
CommitDate: Tue Jul 19 11:02:00 2011 -0400
ENH: pre-commit: Prevent add .txx files.
A transition occurred in the toolkit to move all .txx files to .hxx files.
This prevents accidental additions of or renames to .txx files.
Change-Id: Id4ace9cfca2c56506d93396366d146173e015003
diff --git a/pre-commit b/pre-commit
index f46cf5d..4bc6c6b 100755
--- a/pre-commit
+++ b/pre-commit
@@ -300,6 +300,22 @@ done
test -z "$bad" || die "$bad"
#-----------------------------------------------------------------------------
+# Do not allow adding of files with .txx extension.
+diffs_added=$(git diff-index --diff-filter=A --cached $against -- |
+ sed -n '/^:[^:]/ {s/^://;p;}')
+diffs_normal_added=$(echo "$diffs" | grep -v '^...... 160000')
+bad=$(
+test -n "$diffs_normal" && echo "$diffs_normal" |
+while read src_mode dst_mode src_obj dst_obj status file; do
+ if echo "$file" | grep -q -E '\.txx$'; then
+ echo "Attempted to add file $file."
+ echo "Files with the .txx extension are not allowed -- use .hxx instead."
+ fi
+done
+)
+test -z "$bad" || die "$bad"
+
+#-----------------------------------------------------------------------------
# Merge checks.
if test -n "$merge_head"; then
merge_diffs=$(git diff-index --cached $merge_head -- |
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=69b19172e436eb0911c4dd362470364c694478bb
commit 69b19172e436eb0911c4dd362470364c694478bb
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Jun 14 15:42:38 2011 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Tue Jun 14 15:42:38 2011 -0400
pre-commit-style: Fix exit code on failure
The return code from 'die' was absorbed inside a subshell on the
right-hand side of a pipeline. Propagate it out to the main script.
diff --git a/pre-commit-style b/pre-commit-style
index 74d2caa..8c22704 100644
--- a/pre-commit-style
+++ b/pre-commit-style
@@ -126,7 +126,7 @@ run_KWStyle() {
while read f; do
if run_style_on_file "$f" KWStyle; then
run_KWStyle_on_file "$f"
- fi
+ fi || return
done
}
@@ -237,7 +237,7 @@ For more information, see
merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)"
git diff-index --cached --diff-filter=ACMR --name-only $against -- |
while read MERGED; do
- run_uncrustify_on_file "$MERGED"
+ run_uncrustify_on_file "$MERGED" || return
done # end for changed files
}
@@ -254,12 +254,12 @@ elif $do_uncrustify; then
status=0
}
check_for_uncrustify
- run_uncrustify
+ run_uncrustify || exit 1
# do_uncrustify will run KWStyle on the files incrementally so excessive
# uncrustify merges do not have to occur.
elif $do_KWStyle; then
if check_for_KWStyle; then
- run_KWStyle
+ run_KWStyle || exit 1
fi
fi
-----------------------------------------------------------------------
Summary of changes:
commit-msg | 2 +
hooks-chain.bash | 4 +-
prepare-commit-msg => hooks-config.bash | 9 +-
pre-commit | 6 +-
pre-commit-style | 266 -------------------------------
prepare-commit-msg | 2 +
6 files changed, 13 insertions(+), 276 deletions(-)
copy prepare-commit-msg => hooks-config.bash (78%)
mode change 100755 => 100644
delete mode 100644 pre-commit-style
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list