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