From 64786cec61d1c0544543145627f6d16ad0e54215 Mon Sep 17 00:00:00 2001 From: Alex Dehnert Date: Sat, 2 Feb 2013 17:50:52 -0500 Subject: [PATCH] zephyr-post-receive: send the diff when short When the diff represented by a commit is sufficiently short, send the diff in addition to the usual commit and change size information. Patch from /mit/ua/git/zephyr-post-receive, probably originally written by Quentin Smith . --- git-hooks/zephyr-post-receive | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/git-hooks/zephyr-post-receive b/git-hooks/zephyr-post-receive index 51b9660..d0c6f44 100755 --- a/git-hooks/zephyr-post-receive +++ b/git-hooks/zephyr-post-receive @@ -11,6 +11,7 @@ class=`git config zephyr.class` instance=`git config zephyr.instance` zsig=`git config zephyr.zsig` color=`git config --bool zephyr.color` +maxlines=`git config --int zephyr.maxlines 2>/dev/null || echo 50` if [ "${color:-true}" = "true" ]; then usecolor="--color" @@ -59,13 +60,20 @@ while read oldrev newrev refname; do while read rev; do check_max shortrev=`git log -1 --pretty=format:%h "$rev"` - (git show --stat -M $usecolor "$rev" | + lines=`git show -M "$rev" | wc -l` + cmd="git show --stat -M $usecolor $rev" + if [ $lines -lt $maxlines ]; then + cmd="git show -M $usecolor $rev" + fi + ($cmd | sed -e 's/@/@@/g' \ -e 's/}/@(})/g' \ -e 's/\[m/}@{/g' \ + -e 's/\[1m/}@b{/g' \ -e 's/\[33m/@color(yellow)/g' \ -e 's/\[31m/@color(red)/g' \ -e 's/\[32m/@color(green)/g' \ + -e 's/\[36m/@color(cyan)/g' \ -e '1s/^/@{/' \ -e '$s/$/}/') | zwrite -c "$class" -i "${instance:-$shortrev}" -s "$zsig: $refname" -d -- 2.44.0