summaryrefslogtreecommitdiff
path: root/git-hooks/git_post_commit_hook
blob: 2a0a0ca84f6b71c9bd3fb26ecca8b7c591e76a34 (plain)
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
#! /bin/sh
# Copyright (C) 2015 The Qt Company Ltd.
# Contact: http://www.qt.io/licensing/
#
# You may use this file under the terms of the 3-clause BSD license.
# See the file LICENSE from this package for details.
#

# Usage: in every repository you want to have checked:
#    cd .git/hooks
#    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
        base=`dirname "$me"`
        me=`ls -l "$me" | sed 's/^.*-> //'`
        me=`makeAbsolute "$me" "$base"`
    fi
fi

sha1=${1-HEAD} # just for debugging
exec `dirname "$me"`/sanitize-commit $sha1 strict >&2