]> mj.ucw.cz Git - git-tools.git/blob - update
Added a generic update hook script.
[git-tools.git] / update
1 #!/bin/sh
2 #
3 # This is a generic update hook script for GIT repositories.
4 #
5 # Called by git-receive-pack with arguments: refname sha1-old sha1-new
6 #
7 # Expects the following environment variables:
8 #
9 #       recipient       where to send the mail reports to
10 #       sub_prefix      prefix which should be prepended to mail subject
11 #
12
13 branch=${1#refs/heads/}
14 if [ "$branch" == "$1" ] ; then
15         # Not something we care about
16         exit 0
17 fi
18 if [ $branch == origin ] ; then
19         # We are not following the origin
20         exit 0
21 fi
22
23 out=`mktemp -t gitlog.XXXXXXX`
24 if [ $branch == master ] ; then
25         subj="$sub_prefix"
26 else
27         subj="[$sub_prefix:$branch]"
28 fi
29 exec >$out
30
31 if expr "$2" : '0*$' >/dev/null ; then
32         echo "Created a new branch $branch, with the following commits:"
33         echo
34         git-rev-list --pretty --max-count=20 "$3"
35         echo "(and possibly more)"
36 else
37         base=$(git-merge-base "$2" "$3")
38         case "$base" in
39         "$2")
40                 echo "New commits to branch $branch:"
41                 ;;
42         *)
43                 echo "Rebased branch $branch, commits from common ancestor:"
44                 ;;
45         esac
46         echo
47         git-rev-list --pretty "$3" "^$base"
48         git-diff -C "$base" "$3"
49         t=`mktemp -t gitlog.XXXXXXX`
50         git-diff --name-only -r "$base" "$3" >$t
51         while read X ; do
52                 if [ ${#subj} -lt 80 ] ; then
53                         subj="$subj $X"
54                 fi
55         done <$t
56         rm $t
57 fi
58
59 exec >&2
60 mutt -F/dev/null -x -e 'set charset="utf-8"; set send_charset="us-ascii:iso-8859-2:utf-8"' -s "$subj" "$recipient" <$out
61 rm $out
62 exit 0