3 # Generate a mail feed for a commits list.
5 # Based on 'gitlog.sh' originally written by (c) Ross Vandegrift.
6 # Adapted to his scripts set by (c) Petr Baudis, 2005.
7 # Major optimizations by (c) Phillip Lougher.
9 # Takes an id resolving to a commit to start from (HEAD by default).
11 # regex for parent declarations
12 PARENTS
="^parent [A-Za-z0-9]{40}$"
14 TMPCL
=$
(mktemp
-t gitmail.XXXXXX
)
15 TMPCM
=$
(mktemp
-t gitmail.XXXXXX
)
16 TMPML
=$
(mktemp
-t gitmail.XXXXXX
)
17 TMPMD
=$
(mktemp
-td gitmail.XXXXXX
)
19 FROM
=`whoami`@
`hostname`
20 #SENDMAIL=/usr/lib/sendmail
21 #MLIST=`whoami`@`hostname`
22 # Unless configured otherwise, just cat it instead of mailing.
24 MLIST
=git-commits-mail.out
26 # takes an object and generates the object's parent(s)
28 local parents new_parent
34 while [ $parents -gt 0 ]; do
35 parent
=${new_parent[$(($parents-1))]}
37 echo $parent >> $TMPCL
44 git-cat-file commit
$parent > $TMPCM
46 while read key rest
; do
58 if grep -q $rest $TMPCL; then
59 ignoredparents
=$
(($ignoredparents+1))
62 new_parent
[$parents]=$rest
63 parents
=$
(($parents+1))
69 sec
=${date[0]}; tz
=${date[1]}
70 dtz
=${tz/+/+ }; dtz
=${dtz/-/- }
71 pdate
="$(date -Rud "1970-01-01 UTC
+ $sec sec
$dtz" 2>/dev/null)"
73 echo $key $rest |
sed "s/>.*/> ${pdate/+0000/$tz}/"
83 done > $TMPML < $TMPCM
85 if [ $
(($parents+$ignoredparents)) -eq 1 ]; then
86 [ -z "$lastparent" ] && lastparent
=${new_parent[0]}
87 # Only one parent; not a merge. Mail this cset
93 Content-Type: text/plain; charset=UTF-8
95 X-Git-Parent: $lastparent
100 cg-diff
-r $lastparent -r $parent > $TMPCM
101 diffstat
-p1 $TMPCM 2>/dev
/null
109 while [ $i -lt $
(($parents-1)) ]; do
110 createmails
${new_parent[$i]}
116 base
=$
(cg-object-id
-c $1)
119 lastmail
=`cat .git/tags/MailDone`
121 lastmail
=$
(cg-object-id
-c $2)
125 # tagname=`ls -rt .git/tags | grep -v MailDone | tail -1`
126 # release=`cat .git/tags/$tagname`
128 # release=$(gitXnormid.sh -c $3)
131 base
=$
(cg-object-id
-c $1) ||
exit 1
134 if [ "$base" != "$lastmail" ]; then
135 # List the commits at which we should stop following the tree, because
136 # we've come back to commits which were already in $lastmail.
137 git-rev-tree
--edges $base $lastmail | cut
-f2- -d\ |
sed 's/[a-z0-9]*:1//g' >> $TMPCL
140 # No 'cg-tag -F' -- cheat.
141 echo $base > .git
/tags
/MailDone
142 tac $TMPCL |
while read commit
; do
143 if [ -r "$TMPMD/$commit" ]; then
144 $SENDMAIL $MLIST < $TMPMD/$commit
148 rm $TMPCL $TMPCM $TMPML