vtk-m/prepare-commit-msg
Brad King 5ebbe2dacc Set GIT_DIR if not already set
Although it seems reasonable to expect GIT_DIR to be set when
hooks are invoked, the "git help hooks" documentation does not
guarantee it.  On msysGit 1.7.8 (and perhaps others) "git gui"
runs prepare-commit-msg without setting GIT_DIR.  Set GIT_DIR
at the beginning of each commit hook if it is not already set.
2012-02-29 16:32:01 -05:00

32 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
#=============================================================================
# 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.
#=============================================================================
. "${BASH_SOURCE%/*}/hooks-config.bash"
# Invoke the Gerrit Change-Id hook here for "git merge" because
# it does not run the normal commit-msg hook.
hooks_GerritId=$(git config --get hooks.GerritId)
case "$hooks_GerritId,$2,$3" in
true,merge,) "$GIT_DIR/hooks/gerrit/commit-msg" "$1" ;;
*) ;;
esac
#-----------------------------------------------------------------------------
# Chain to project-specific hook.
. "$GIT_DIR/hooks/hooks-chain.bash"
hooks_chain prepare-commit-msg "$@"