55
# "t=%s; printf 'http://.../?id=%%s' \$t; echo;echo; git show -C \$t; echo"
56
# Be careful if "..." contains things that will be expanded by shell "eval"
57
# or printf.
58
+# hooks.emailmaxlines
59
+# The maximum number of lines that should be included in the generated
60
+# email body. If not specified, there is no limit.
61
+# Lines beyond the limit are suppressed and counted, and a final
62
+# line is added indicating the number of suppressed lines.
63
#
64
# Notes
65
# -----
89
oldrev=$(git rev-parse $1)
90
newrev=$(git rev-parse $2)
91
refname="$3"
92
+ maxlines=$4
93
94
# --- Interpret
95
# 0000->1234 (create)
198
fn_name=atag
199
;;
200
esac
195
- generate_${change_type}_${fn_name}_email
201
+
202
+ if [ -z "$maxlines" ]; then
203
+ generate_${change_type}_${fn_name}_email
204
+ else
205
+ generate_${change_type}_${fn_name}_email | limit_lines $maxlines
206
+ fi
207
208
generate_email_footer
209
}
653
}
654
655
656
+limit_lines()
657
+{
658
+ lines=0
659
+ skipped=0
660
+ while IFS="" read -r line; do
661
+ lines=$((lines + 1))
662
+ if [ $lines -gt $1 ]; then
663
+ skipped=$((skipped + 1))
664
+ else
665
+ printf "%s\n" "$line"
666
+ fi
667
+ done
668
+ if [ $skipped -ne 0 ]; then
669
+ echo "... $skipped lines suppressed ..."
670
+ fi
671
+}
672
+
673
+
674
send_mail()
675
{
676
if [ -n "$envelopesender" ]; then
708
envelopesender=$(git config hooks.envelopesender)
709
emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')
710
custom_showrev=$(git config hooks.showrev)
711
+maxlines=$(git config hooks.emailmaxlines)
712
713
# --- Main loop
714
# Allow dual mode: run from the command line just like the update hook, or
721
else
722
while read oldrev newrev refname
723
do
694
- generate_email $oldrev $newrev $refname | send_mail
724
+ generate_email $oldrev $newrev $refname $maxlines | send_mail
725
done
726
fi