[090fc1]: / hooks-config.bash  Maximize  Restore  History

Download this file

67 lines (59 with data), 1.8 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#=============================================================================
# Copyright 2010-2012 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.
#=============================================================================
# Make sure GIT_DIR is set.
if test -z "$GIT_DIR"; then
export GIT_DIR=$(git rev-parse --git-dir)
fi
# Load hooks configuration from source tree.
hooks_config=".hooks-config"
if test -r "$hooks_config"; then
hooks_config() {
git config -f "$hooks_config" "$@"
}
else
hooks_config() {
false
}
fi
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) ||
chain="$(hooks_config --get hooks.chain.$hook)" ||
eval chain="\${hooks_chain_${hook//-/_}}"
hooks_child "$chain" "$@" || exit
}
hooks_start() {
hook="$1" ; shift
start="$(hooks_config --get hooks.start.$hook)"
hooks_child "$start" "$@" || exit
}
hooks_child() {
child="$1" ; shift
test -n "$child" || return 0
case "$child" in
'/'*) prefix="" ;;
'[A-Za-z]:/'*) prefix="" ;;
'.'*) prefix="" ;;
*) prefix="./" ;;
esac
if test -x "$prefix$child" ; then
"$prefix$child" "$@"
fi
}
# vim: set filetype=sh tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab :