From 2d9ee2a97cb41c505692d39aa172ed074c98c48e Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Apr 2013 13:12:19 -0400 Subject: [PATCH] hooks-config: Subsume hooks-chain functionality Remove hooks-chain.bash and place its content in hooks-config.bash. --- commit-msg | 1 - hooks-chain.bash | 33 --------------------------------- hooks-config.bash | 16 ++++++++++++++++ pre-commit | 1 - prepare-commit-msg | 1 - 5 files changed, 16 insertions(+), 36 deletions(-) delete mode 100644 hooks-chain.bash diff --git a/commit-msg b/commit-msg index 238407ffa..b0006fa91 100755 --- a/commit-msg +++ b/commit-msg @@ -145,5 +145,4 @@ esac #----------------------------------------------------------------------------- # Chain to project-specific hook. -. "$HOOKS_DIR/hooks-chain.bash" hooks_chain commit-msg "$@" diff --git a/hooks-chain.bash b/hooks-chain.bash deleted file mode 100644 index 7aca6ce95..000000000 --- a/hooks-chain.bash +++ /dev/null @@ -1,33 +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. -#============================================================================= - -hooks_chain() { - hook="$1" ; shift - 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="" ;; - '.'*) prefix="" ;; - *) prefix="./" ;; - esac - if test -x "$prefix$chain" ; then - exec "$prefix$chain" "$@" - fi -} - -# vim: set filetype=sh tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab : diff --git a/hooks-config.bash b/hooks-config.bash index adc35fd7b..c857c8e4a 100644 --- a/hooks-config.bash +++ b/hooks-config.bash @@ -25,4 +25,20 @@ config=".hooks-config.bash" && test -r "$config" && . "$config" # Set up the location for "this" set of hooks. HOOKS_DIR="${BASH_SOURCE%/*}" +hooks_chain() { + hook="$1" ; shift + 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="" ;; + '.'*) prefix="" ;; + *) prefix="./" ;; + esac + if test -x "$prefix$chain" ; then + exec "$prefix$chain" "$@" + fi +} + # vim: set filetype=sh tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab : diff --git a/pre-commit b/pre-commit index 9d7563444..5fe22bf54 100755 --- a/pre-commit +++ b/pre-commit @@ -322,7 +322,6 @@ test -z "$bad" || die "$bad" #----------------------------------------------------------------------------- # Chain to project-specific hook. -. "$HOOKS_DIR/hooks-chain.bash" hooks_chain pre-commit "$@" # vim: set filetype=sh tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab : diff --git a/prepare-commit-msg b/prepare-commit-msg index a5d459252..9d3383909 100755 --- a/prepare-commit-msg +++ b/prepare-commit-msg @@ -27,5 +27,4 @@ esac #----------------------------------------------------------------------------- # Chain to project-specific hook. -. "$HOOKS_DIR/hooks-chain.bash" hooks_chain prepare-commit-msg "$@"