summaryrefslogtreecommitdiff
path: root/git-hooks/git_post_commit_hook
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2012-02-16 18:49:05 +0100
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2012-02-16 19:21:32 +0100
commit9acf5f5ecc59fd932a687122adb4e4e0bc95556d (patch)
tree04d451026e164f67a5e6a2dfc5b89a86490c9235 /git-hooks/git_post_commit_hook
parentc9eb0681ac0f5cb7a22ca3b17d099c377a3d1449 (diff)
downloadqtrepotools-9acf5f5ecc59fd932a687122adb4e4e0bc95556d.tar.gz
make symlinking the script actually work without setting up PATH
Change-Id: I8643544e8e3fd94a89d4ef49977aa00acadf18e2 Reviewed-by: Shane Kearns <ext-shane.2.kearns@nokia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Diffstat (limited to 'git-hooks/git_post_commit_hook')
-rwxr-xr-xgit-hooks/git_post_commit_hook29
1 files changed, 28 insertions, 1 deletions
diff --git a/git-hooks/git_post_commit_hook b/git-hooks/git_post_commit_hook
index e4728c5..5090c75 100755
--- a/git-hooks/git_post_commit_hook
+++ b/git-hooks/git_post_commit_hook
@@ -11,7 +11,34 @@
# ln -s /path/to/git_post_commit_hook post-commit
#
+makeAbsolute() {
+ case $1 in
+ /*)
+ # already absolute, return it
+ echo "$1"
+ ;;
+ *)
+ # relative, prepend $2 made absolute
+ echo `makeAbsolute "$2" "$PWD"`/"$1" | sed 's,/\.$,,'
+ ;;
+ esac
+}
+
+me=$0
+if test -L "$me"; then
+ # Try GNU readlink(1)
+ nme=`readlink -nf "$me" 2>/dev/null`
+ if test -n "$nme"; then
+ me=$nme
+ else
+ # No GNU readlink(1), so let's try ls -l
+ me=`ls -l "$me" | sed 's/^.*-> //'`
+ base=`dirname "$me"`
+ me=`makeAbsolute "$me" "$base"`
+ fi
+fi
+
sha1=${1-HEAD} # just for debugging
GIT_PUSH=${GIT_PUSH+$GIT_PUSH,}wip # this check makes totally no sense locally
export GIT_PUSH
-exec sanitize-commit $sha1 strict >&2
+exec `dirname "$me"`/sanitize-commit $sha1 strict >&2