]> snippets.scripts.mit.edu Git - Scripts/git/.git/blame - git-hooks/zephyr-post-receive
git-hooks/zephyr-post-receive: Use --first-parent when listing commits.
[Scripts/git/.git] / git-hooks / zephyr-post-receive
CommitLineData
5b11b497
GT
1#!/bin/sh
2#
3# This script is run after receive-pack has accepted a pack and the
4# repository has been updated. It is passed arguments in through stdin
5# in the form
6# <oldrev> <newrev> <refname>
7# For example:
8# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
9
10class=`git config zephyr.class`
916beed8 11instance=`git config zephyr.instance`
5b11b497 12zsig=`git config zephyr.zsig`
aa39c04d
NE
13color=`git config --bool zephyr.color`
14
15if [ "${color:-true}" = "true" ]; then
16 usecolor="--color"
17else
18 usecolor=""
19fi
20
5b11b497
GT
21if [ -z "$class" ]; then
22 echo "I don't know where to send a commit zephyr!" >&2
23 echo "Please set the zephyr.class config variable in" >&2
24 echo "$PWD/config." >&2
25 exit 1
26fi
27while read oldrev newrev refname; do
d0ef17b3
GT
28 if [ "$oldrev" = "0000000000000000000000000000000000000000" ]; then
29 # dammit git
30 zwrite -c "$class" -i "$(basename "$refname")" -s "${zsig:-Git}: $refname" -d \
31 -m "New branch created."
32 continue
33 fi
6493056c 34 git rev-list --first-parent --reverse "$oldrev..$newrev" | while read rev; do
5b11b497 35 shortrev=`git log -1 --pretty=format:%h "$rev"`
aa39c04d 36 (git show --stat $usecolor "$rev" |
5dceef3e
AK
37 sed -e 's/@/@@/g' \
38 -e 's/}/@(})/g' \
39 -e 's/\e\[m/}@{/g' \
40 -e 's/\e\[33m/@color(yellow)/g' \
41 -e 's/\e\[31m/@color(red)/g' \
42 -e 's/\e\[32m/@color(green)/g' \
43 -e '1s/^/@{/' \
44 -e '$s/$/}/') |
916beed8 45 zwrite -c "$class" -i "${instance:-$shortrev}" -s "${zsig:-Git}: $refname" -d
5b11b497
GT
46 done
47done