diff options
author | Ralph Boehme <slow at samba.org> | 2018-04-10 13:04:27 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2018-04-26 01:09:27 +0200 |
commit | 8649e216650de85cd73eda64caa2e338d59582d5 (patch) | |
tree | 65a7ec5a85a2caafc4ce453682f21a10f40e31da /script | |
parent | a6fade4e10760284ef56abf45d3fa70038091cbe (diff) | |
download | samba-8649e216650de85cd73eda64caa2e338d59582d5.tar.gz |
Add a wrapper script as git pre-commit hook
When developer mode is enabled, the wrapper script
"script/git-hooks/pre-commit-hook" gets installed as
.git/hooks/pre-commit
and calls "script/git-hooks/pre-commit-script".
This way we can later modify the "script/git-hooks/pre-commit-script"
without the need to ever change the installed commit hook itself.
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Jeremy Allison <jra at samba.org>
Diffstat (limited to 'script')
-rwxr-xr-x | script/git-hooks/pre-commit-hook | 17 | ||||
-rwxr-xr-x | script/git-hooks/pre-commit-script | 17 |
2 files changed, 34 insertions, 0 deletions
diff --git a/script/git-hooks/pre-commit-hook b/script/git-hooks/pre-commit-hook new file mode 100755 index 00000000000..3f51254c2cf --- /dev/null +++ b/script/git-hooks/pre-commit-hook @@ -0,0 +1,17 @@ +#!/bin/sh + +set -eu + +gitdir=$(git rev-parse --show-toplevel) +if [ $? -ne 0 ] ; then + echo "git rev-parse --show-toplevel failed" + exit 1 +fi + +if [ ! -f ${gitdir}/script/git-hooks/pre-commit-script ] ; then + exit 0 +fi + +${gitdir}/script/git-hooks/pre-commit-script || exit $? + +exit 0 diff --git a/script/git-hooks/pre-commit-script b/script/git-hooks/pre-commit-script new file mode 100755 index 00000000000..22ebecec970 --- /dev/null +++ b/script/git-hooks/pre-commit-script @@ -0,0 +1,17 @@ +#!/bin/sh + +set -eu + +# +# make emacs/magit work, cf +# https://github.com/magit/magit/issues/3419 +# +unset GIT_LITERAL_PATHSPECS + +gitdir=$(git rev-parse --show-toplevel) +if [ $? -ne 0 ] ; then + echo "git rev-parse --show-toplevel failed" + exit 1 +fi + +exit 0 |