3 # Copyright (c) 2007 Andy Parkins
5 # An example hook script to mail out commit update information. This hook
6 # sends emails listing new revisions to the repository introduced by the
7 # change being reported. The rule is that (for branch updates) each commit
8 # will appear on one email and one email only.
11 # This is Girocco-customized version. No matter what is said below, it has
13 # * Calling with arguments is same as giving them on stdin.
14 # * Optional fourth parameter is project name, used at most places instead
16 # * Optional fifth parameter is email sender.
18 # * Default subject prefix is site name.
19 # * Unsubscribe instructions in email footer.
20 # * Default showrev includes gitweb link and show -C.
21 # * Nicer subject line.
22 # * Limit mail size to 256kb.
25 # This hook is stored in the contrib/hooks directory. Your distribution
26 # will have put this somewhere standard. You should make this script
27 # executable then link to it in the repository you would like to use it in.
28 # For example, on debian the hook is stored in
29 # /usr/share/git-core/contrib/hooks/post-receive-email:
31 # chmod a+x post-receive-email
32 # cd /path/to/your/repository.git
33 # ln -sf /usr/share/git-core/contrib/hooks/post-receive-email hooks/post-receive
35 # This hook script assumes it is enabled on the central repository of a
36 # project, with all users pushing only to it and not between each other. It
37 # will still work if you don't operate in that style, but it would become
38 # possible for the email to be from someone other than the person doing the
44 # This is the list that all pushes will go to; leave it blank to not send
45 # emails for every ref update.
47 # If true do not include the actual diff when showing new commits (the
48 # summary information will still be shown). Default is false.
50 # This is the list that all pushes of annotated tags will go to. Leave it
51 # blank to default to the mailinglist field. The announce emails lists
52 # the short log summary of the changes since the last annotated tag.
53 # hooks.envelopesender
54 # If set then the -f option is passed to sendmail to allow the envelope
55 # sender address to be set
57 # All emails have their subjects prefixed with this prefix, or "[SCM]"
58 # if emailprefix is unset, to aid filtering
60 # The shell command used to format each revision in the email, with
61 # "%s" replaced with the commit id. Defaults to "git rev-list -1
62 # --pretty %s", displaying the commit id, author, date and log
63 # message. To list full patches separated by a blank line, you
64 # could set this to "git show -C %s; echo".
65 # To list a gitweb/cgit URL *and* a full patch for each change set, use this:
66 # "t=%s; printf 'http://.../?id=%%s' \$t; echo;echo; git show -C \$t; echo"
67 # Be careful if "..." contains things that will be expanded by shell "eval"
72 # All emails include the headers "X-Git-Refname", "X-Git-Oldrev",
73 # "X-Git-Newrev", and "X-Git-Reftype" to enable fine tuned filtering and
74 # give information for debugging.
77 # ---------------------------- Functions
80 # Function to output arguments without interpretation followed by \n
88 # Function to read a tag's (the single argument) header fields into
89 # tagobject the "object" value
90 # tagtype the "type" value
91 # tagtag the "tag" value
92 # taggername from "tagger" value before first '<'
93 # taggerdate from "tagger" value after '>' but formatted into a date string
94 # taggeremail from "tagger" value between '<' and '>'
95 # On return all fields will be set (to empty if failure) and the three tagger
96 # fields will only be set to non-empty if a "tagger" header field is present.
97 # If the object does not exist or is not a tag the function returns failure.
106 if _tagfields
="$(git cat-file tag "$1" | LC_ALL=C awk -F '[ ]' '
107 function quotesh(sv) {
108 gsub(/'\''/, "'\'\\\\\'\''", sv)
109 return "'\''" sv "'\''"
112 sub(/^[ \t]+/, "", sv)
113 sub(/[ \t]+$/, "", sv)
117 sub(/^[^ ]* /, "", sv)
121 if ($1 == "object
") to=hval($0)
122 if ($1 == "type") ty=hval($0)
123 if ($1 == "tag
") tt=hval($0)
124 if ($1 == "tagger
") tr=hval($0)
127 if (tt == "" || to == "" || ty == "") exit 1
128 print "tagobject
=" quotesh(to)
129 print "tagtype
=" quotesh(ty)
130 print "tagtag
=" quotesh(tt)
131 if (match(tr, /^[ \t]*[^ \t<][^<]*/)) {
132 tn=substr(tr, RSTART, RLENGTH)
133 tr=substr(tr, RSTART + RLENGTH)
136 print "taggername
=" quotesh(tn)
137 if (match(tr, /^<.*>/)) {
139 te=substr(tr, RSTART+1, RLENGTH-2)
140 tr=substr(tr, RSTART + RLENGTH)
143 print "taggeremail
=" quotesh(te)
144 if (match(tr, /^[ \t]*[0-9]+([ \t]+[-+]?[0-9][0-9]([0-9][0-9]([0-9][0-9])?)?)[ \t]*$/))
147 print "taggerdate
=" quotesh(td)
153 [ -z "$taggerdate" ] || taggerdate
="$(strftime "$sdatefmt" $taggerdate)"
160 # Function to prepare for email generation. This decides what type
161 # of update this is and whether an email should even be generated.
166 oldrev
=$
(git rev-parse
--revs-only "$1" --)
167 newrev
=$
(git rev-parse
--revs-only "$2" --)
168 [ "$oldrev" != "$newrev" ] ||
return 1
169 scratch
="${newrev#????????????????}"
170 newrev16
="${newrev%$scratch}"
174 # 0000->1234 (create)
175 # 1234->2345 (update)
176 # 2345->0000 (delete)
177 if LC_ALL
=C
expr "$oldrev" : '0*$' >/dev
/null
181 if LC_ALL
=C
expr "$newrev" : '0*$' >/dev
/null
189 # --- Get the revision types
190 newrev_type
=$
(git cat-file
-t $newrev 2> /dev
/null
)
191 oldrev_type
=$
(git cat-file
-t "$oldrev" 2> /dev
/null
)
192 case "$change_type" in
195 rev_type
="$newrev_type"
199 rev_type
="$oldrev_type"
203 # The revision type tells us what type the commit is, combined with
204 # the location of the ref we can decide between
209 case "$refname","$rev_type" in
213 short_refname
=${refname##refs/tags/}
217 refname_type
="annotated tag"
218 short_refname
=${refname##refs/tags/}
220 if [ -n "$announcerecipients" ]; then
221 recipients
="$announcerecipients"
224 refs
/heads
/*,commit|refs
/heads
/*,tag
)
226 refname_type
="branch"
227 short_refname
=${refname##refs/heads/}
229 refs
/remotes
/*,commit
)
231 refname_type
="tracking branch"
232 short_refname
=${refname##refs/remotes/}
233 echol
>&2 "*** Push-update of tracking branch, $refname"
234 echol
>&2 "*** - no email generated."
237 refs
/mob
/*,commit|refs
/mob
/*,tag
)
239 refname_type
="personal mob ref"
240 short_refname
=${refname##refs/mob/}
241 echol
>&2 "*** Push-update of personal mob ref, $refname"
242 echol
>&2 "*** - no email generated."
246 # Anything else (is there anything else?)
247 echol
>&2 "*** Unknown type of update to $refname ($rev_type)"
248 echol
>&2 "*** - no email generated"
253 # Check if we've got anyone to send to
254 if [ -z "$recipients" ]; then
255 case "$refname_type" in
257 config_name
="hooks.announcelist"
260 config_name
="hooks.mailinglist"
263 echol
>&2 "*** $config_name is not set so no email will be sent"
264 echol
>&2 "*** for $refname update $oldrev->$newrev"
272 # Top level email generation function. This calls the appropriate
273 # body-generation routine after outputting the common header.
275 # Note this function doesn't actually generate any email output, that is
276 # taken care of by the functions it calls:
277 # - generate_email_header
278 # - generate_create_XXXX_email
279 # - generate_update_XXXX_email
280 # - generate_delete_XXXX_email
281 # - generate_email_footer
283 # Note also that this function cannot 'exit' from the script; when this
284 # function is running (in hook script mode), the send_mail() function
285 # is already executing in another process, connected via a pipe, and
286 # if this function exits without, whatever has been generated to that
287 # point will be sent as an email... even if nothing has been generated.
292 # The email subject will contain the best description of the ref
293 # that we can build from the parameters
294 describe
=$
(git describe
$rev 2>/dev
/null
)
295 if [ -z "$describe" ]; then
299 generate_email_header
301 # Call the correct body generation function
303 case "$refname_type" in
304 "tracking branch"|branch
)
311 generate_
${change_type}_
${fn_name}_email
313 generate_email_footer
316 generate_email_header
()
318 # --- Email (all stdout will be the email)
320 if [ -n "$emailsender" ]; then
321 echol
"From: $emailsender"
325 Subject: ${emailprefix}$projectname $refname_type $short_refname ${change_type}d: $describe
327 Content-Type: text/plain; charset=utf-8
328 Content-Transfer-Encoding: 8bit
330 [ -n "$cfg_suppress_x_girocco" ] || echol
"X-Girocco: $cfg_gitweburl"
331 [ -z "$emailextraheader" ] || echol
"$emailextraheader"
333 X-Git-Refname: $refname
334 X-Git-Reftype: $refname_type
335 X-Git-Oldrev: $oldrev
336 X-Git-Newrev: $newrev
337 Auto-Submitted: auto-generated
339 This is an automated email from the git hooks/post-receive script. It was
340 generated because a ref change was pushed to the repository containing
341 the project $projectname.
343 The $refname_type, $short_refname has been ${change_type}d
347 generate_email_footer
()
353 $cfg_name automatic notification. Contact project admin $projectowner
354 if you want to unsubscribe, or site admin $cfg_admin if you receive
361 # --------------- Branches
364 # Called for the creation of a branch
366 generate_create_branch_email
()
368 # This is a new branch and so oldrev is not valid
369 echol
" at $newrev ($newrev_type)"
376 # The diffstat is shown from an empty tree to the new revision.
377 # This is to show the truth of what happened in this change.
378 # Note that since Git 1.5.5 the empty tree object is ALWAYS available
379 # whether or not it's actually present in the repository.
381 echol
"Summary of changes:"
382 git diff-tree
--no-color --stat=72 --summary -B --find-copies-harder 4b825dc642cb6eb9a060e54bf8d69288fbee4904
$newrev
386 # Called for the change of a pre-existing branch
388 generate_update_branch_email
()
391 # 1 --- 2 --- O --- X --- 3 --- 4 --- N
393 # O is $oldrev for $refname
394 # N is $newrev for $refname
395 # X is a revision pointed to by some other ref, for which we may
396 # assume that an email has already been generated.
397 # In this case we want to issue an email containing only revisions
398 # 3, 4, and N. Given (almost) by
400 # git rev-list N ^O --not --all
402 # The reason for the "almost", is that the "--not --all" will take
403 # precedence over the "N", and effectively will translate to
405 # git rev-list N ^O ^X ^N
407 # So, we need to build up the list more carefully. git rev-parse
408 # will generate a list of revs that may be fed into git rev-list.
409 # We can get it to make the "--not --all" part and then filter out
412 # git rev-parse --not --all | grep -v N
414 # Then, using the --stdin switch to git rev-list we have effectively
417 # git rev-list N ^O ^X
419 # This leaves a problem when someone else updates the repository
420 # while this script is running. Their new value of the ref we're
421 # working on would be included in the "--not --all" output; and as
422 # our $newrev would be an ancestor of that commit, it would exclude
423 # all of our commits. What we really want is to exclude the current
424 # value of $refname from the --not list, rather than N itself. So:
426 # git rev-parse --not --all | grep -v $(git rev-parse $refname)
428 # Get's us to something pretty safe (apart from the small time
429 # between refname being read, and git rev-parse running - for that,
433 # Next problem, consider this:
434 # * --- B --- * --- O ($oldrev)
436 # * --- X --- * --- N ($newrev)
438 # That is to say, there is no guarantee that oldrev is a strict
439 # subset of newrev (it would have required a --force, but that's
440 # allowed). So, we can't simply say rev-list $oldrev..$newrev.
441 # Instead we find the common base of the two revs and list from
444 # As above, we need to take into account the presence of X; if
445 # another branch is already in the repository and points at some of
446 # the revisions that we are about to output - we don't want them.
447 # The solution is as before: git rev-parse output filtered.
449 # Finally, tags: 1 --- 2 --- O --- T --- 3 --- 4 --- N
451 # Tags pushed into the repository generate nice shortlog emails that
452 # summarise the commits between them and the previous tag. However,
453 # those emails don't include the full commit messages that we output
454 # for a branch update. Therefore we still want to output revisions
455 # that have been output on a tag email.
457 # Luckily, git rev-parse includes just the tool. Instead of using
458 # "--all" we use "--branches"; this has the added benefit that
459 # "remotes/" will be ignored as well.
461 # List all of the revisions that were removed by this update, in a
462 # fast-forward update, this list will be empty, because rev-list O
463 # ^N is empty. For a non-fast-forward, O ^N is the list of removed
467 for rev in $
(git rev-list
$newrev..
$oldrev)
469 revtype
=$
(git cat-file
-t "$rev")
470 echol
" discards $rev ($revtype)"
472 if [ -z "$rev" ]; then
476 # List all the revisions from baserev to newrev in a kind of
477 # "table-of-contents"; note this list can include revisions that
478 # have already had notification emails and is present to show the
479 # full detail of the change from rolling back the old revision to
480 # the base revision and then forward to the new revision
481 for rev in $
(git rev-list
$oldrev..
$newrev)
483 revtype
=$
(git cat-file
-t "$rev")
484 echol
" via $rev ($revtype)"
487 if [ "$fast_forward" ]; then
488 echol
" from $oldrev ($oldrev_type)"
490 # 1. Existing revisions were removed. In this case newrev
491 # is a subset of oldrev - this is the reverse of a
492 # fast-forward, a rewind
493 # 2. New revisions were added on top of an old revision,
494 # this is a rewind and addition.
496 # (1) certainly happened, (2) possibly. When (2) hasn't
497 # happened, we set a flag to indicate that no log printout
502 # Find the common ancestor of the old and new revisions and
503 # compare it with newrev
504 baserev
=$
(git merge-base
$oldrev $newrev)
506 if [ "$baserev" = "$newrev" ]; then
507 echol
"This update discarded existing revisions and left the branch pointing at"
508 echol
"a previous point in the repository history."
510 echol
" * -- * -- N ($newrev)"
512 echol
" O -- O -- O ($oldrev)"
514 echol
"The removed revisions are not necessarily gone - if another reference"
515 echol
"still refers to them they will stay in the repository."
518 echol
"This update added new revisions after undoing existing revisions. That is"
519 echol
"to say, the old revision is not a strict subset of the new revision. This"
520 echol
"situation occurs when you --force push a change and generate a repository"
521 echol
"containing something like this:"
523 echol
" * -- * -- B -- O -- O -- O ($oldrev)"
525 echol
" N -- N -- N ($newrev)"
527 echol
"When this happens we assume that you've already had alert emails for all"
528 echol
"of the O revisions, and so we here report only the revisions in the N"
529 echol
"branch from the common base, B."
534 if [ -z "$rewind_only" ]; then
535 echol
"Those revisions listed above that are new to this repository have"
536 echol
"not appeared on any other notification email; so we list those"
537 echol
"revisions in full, below."
543 # XXX: Need a way of detecting whether git rev-list actually
544 # outputted anything, so that we can issue a "no new
545 # revisions added by this update" message
549 echol
"No new revisions were added by this update."
552 # The diffstat is shown from the old revision to the new revision.
553 # This is to show the truth of what happened in this change.
554 # There's no point showing the stat from the base to the new
555 # revision because the base is effectively a random revision at this
556 # point - the user will be interested in what this revision changed
557 # - including the undoing of previous revisions in the case of
558 # non-fast-forward updates.
560 echol
"Summary of changes:"
561 git diff-tree
--no-color --stat=72 --summary -B --find-copies-harder $oldrev..
$newrev
565 # Called for the deletion of a branch
567 generate_delete_branch_email
()
572 git diff-tree
--no-color --date=$datefmt -s --abbrev-commit --abbrev=$habbr --always --encoding=UTF-8
--pretty=oneline
$oldrev
576 # --------------- Annotated tags
579 # Called for the creation of an annotated tag
581 generate_create_atag_email
()
583 echol
" at $newrev ($newrev_type)"
589 # Called for the update of an annotated tag (this is probably a rare event
590 # and may not even be allowed)
592 generate_update_atag_email
()
594 echol
" to $newrev ($newrev_type)"
595 echol
" from $oldrev (which is now obsolete)"
601 # Called when an annotated tag is created or changed
603 generate_atag_email
()
605 # Use read_tag_fields to pull out the individual fields from the
606 # tag and git cat-file --batch-check to fully peel the tag if needed
609 read_tag_fields
"$tagrev"
610 if [ "$tagtype" = "tag" ]; then
614 info
="$(echo "$tagrev^
{}" | git cat-file --batch-check='
615 peeledobject=%(objectname)
616 peeledtype=%(objecttype)'
618 case "$info" in *type=*) eval "$info";; *)
622 peeledobject
="$tagobject"
623 peeledtype
="$tagtype"
626 echol
" tagging $peeledobject ($peeledtype)"
627 case "$peeledtype" in
630 # If the tagged object is a commit, then we assume this is a
631 # release, and so we calculate which tag this tag is
633 prevtag
=$
(git describe
--abbrev=0 "$peeledobject^" 2>/dev
/null
)
635 if [ -n "$prevtag" ]; then
636 echol
" replaces $prevtag"
640 echol
" length $(git cat-file -s "$peeledobject" 2>/dev/null) bytes"
643 echol
" tagged by $taggername"
644 echol
" on $taggerdate"
652 echol
"Object: $tagobject ($tagtype)"
653 [ -z "$taggername" ] || \
654 echol
"Tagger: $taggername"
655 [ -z "$taggerdate" ] || \
656 echol
"Date: $taggerdate"
657 echol
"URL: <$projurl/$tagrev16>"
660 # Show the content of the tag message; this might contain a change
661 # log or release notes so is worth displaying.
662 git cat-file tag
"$tagrev" | LC_ALL
=C
sed -e '1,/^$/d;s/^/ /;'
664 [ "$tagtype" = "tag" ]
667 scratch
="${tagrev#????????????????}"
668 tagrev16
="${tagrev%$scratch}"
669 read_tag_fields
"$tagrev" ||
break
672 case "$peeledtype" in
674 # Only commit tags make sense to have rev-list operations
676 if [ -n "$prevtag" ]; then
677 # Show changes since the previous release
678 git shortlog
"$prevtag..$newrev"
680 # No previous tag, show all the changes since time
686 # XXX: Is there anything useful we can do for non-commit
695 # Called for the deletion of an annotated tag
697 generate_delete_atag_email
()
702 git diff-tree
--no-color --date=$datefmt -s --abbrev-commit --abbrev=$habbr --always --encoding=UTF-8
--pretty=oneline
$oldrev
706 # --------------- General references
709 # Called when any other type of reference is created (most likely a
712 generate_create_general_email
()
714 echol
" at $newrev ($newrev_type)"
716 generate_general_email
720 # Called when any other type of reference is updated (most likely a
723 generate_update_general_email
()
725 echol
" to $newrev ($newrev_type)"
726 echol
" from $oldrev"
728 generate_general_email
732 # Called for creation or update of any other type of reference
734 generate_general_email
()
736 # Unannotated tags are more about marking a point than releasing a
737 # version; therefore we don't do the shortlog summary that we do for
738 # annotated tags above - we simply show that the point has been
739 # marked, and print the log message for the marked point for
742 # Note this section also catches any other reference type (although
743 # there aren't any) and deals with them in the same way.
746 if [ "$newrev_type" = "commit" ]; then
748 git diff-tree
--no-color --date=$datefmt --root -s --always --encoding=UTF-8
--format="$pfmt1$projurlesc/$newrev16$pfmt2" $newrev
751 # What can we do here? The tag marks an object that is not
752 # a commit, so there is no log for us to display. It's
753 # probably not wise to output git cat-file as it could be a
754 # binary blob. We'll just say how big it is
755 echol
"$newrev is a $newrev_type, and is $(git cat-file -s $newrev) bytes long."
760 # Called for the deletion of any other type of reference
762 generate_delete_general_email
()
767 git diff-tree
--no-color --date=$datefmt -s --abbrev-commit --abbrev=$habbr --always --encoding=UTF-8
--pretty=oneline
$oldrev
772 # --------------- Miscellaneous utilities
775 # Show new revisions as the user would like to see them in the email.
779 # This shows all log entries that are not already covered by
780 # another ref - i.e. commits that are now accessible from this
781 # ref that were previously not accessible
782 # (see generate_update_branch_email for the explanation of this
785 # Revision range passed to rev-list differs for new vs. updated
787 if [ "$change_type" = create
]
789 # Show all revisions exclusive to this (new) branch.
792 # Branch update; show revisions not part of $oldrev.
793 revspec
=$oldrev..
$newrev
796 other_branches
=$
(git for-each-ref
--format='%(refname)' refs
/heads
/ |
797 LC_ALL
=C
grep -F -v $refname)
798 git rev-parse
--not $other_branches |
799 # if [ -z "$custom_showrev" ]
801 # git rev-list --pretty --stdin $revspec
803 git
--no-pager log
--stdin --no-color --format=tformat
:"%H %p" $revspec |
804 LC_ALL
=C
awk '{print $1 " " NF-1}' |
805 while read onerev pcnt
807 if [ -n "$custom_showrev" ]; then
808 eval $
(printf "$custom_showrev" $onerev)
810 if [ ${summaryonly:-false} = false
]; then
811 if [ ${pcnt:-1} -gt 1 ]; then
814 opts
="-p --stat=72 --summary"
817 if [ ${pcnt:-1} -gt 1 ]; then
820 opts
="--stat=72 --summary"
823 scratch
="${onerev#????????????????}"
824 onerev16
="${onerev%$scratch}"
825 git diff-tree
--no-color --date=$datefmt $opts --always --encoding=UTF-8
--format="$pfmt1$projurlesc/$onerev16$pfmt2" --abbrev=$habbr -B -C --root $onerev
836 while IFS
= read -r line
; do
837 # Include size of RFC 822 trailing CR+LF on each line
838 size
=$
(($size+${#line}+2))
839 if [ $size -gt $1 ]; then
840 echol
"...e-mail trimmed, has been too large."
856 if [ -n "$cfg_sender" ]; then
857 "${cfg_sendmail_bin:-/usr/sbin/sendmail}" -i -t -f "$cfg_sender"
859 "${cfg_sendmail_bin:-/usr/sbin/sendmail}" -i -t
863 # ---------------------------- main()
866 LOGBEGIN
="- Log -----------------------------------------------------------------"
867 LOGEND
="-----------------------------------------------------------------------"
872 # Git formatting to use
876 # strftime formatting to use (empty is default rfc2822 format)
879 # This is --pretty=medium in two parts with a URL: line added
880 pfmt1
='format:commit %H%nAuthor: %an <%ae>%nDate: %ad%nURL: <'
881 pfmt2
='>%n%n%w(0,4,4)%s%n%n%b'
883 git_add_config core.abbrev
=$habbr
885 # Set GIT_DIR either from the working directory, or from the environment
887 GIT_DIR
=$
(git rev-parse
--git-dir 2>/dev
/null
)
888 if [ -z "$GIT_DIR" ]; then
889 echol
>&2 "fatal: post-receive: GIT_DIR not set"
894 ! [ -s "$GIT_DIR/description" ] || projectdesc
=$
(LC_ALL
=C
sed -ne '1p' "$GIT_DIR/description")
895 # Check if the description is unchanged from it's default, and shorten it to
896 # a more manageable length if it is
897 if [ -z "$projectdesc" ] || LC_ALL
=C
expr "$projectdesc" : "Unnamed repository.*$" >/dev
/null
899 projectdesc
="UNNAMED PROJECT"
902 # If --stdout is first argument send all output there instead of mailing
903 if [ "$1" = "--stdout" ]; then
905 cfg_sendmail_bin
="sendmail_to_stdout"
908 projectname
="${4%.git}"
909 if [ -n "$projectname" ]; then
910 projectname
="$projectname.git"
911 projectowner
="$(config_get owner)"
913 projectname
="$(basename "$PWD")"
915 projectboth
="$projectname (\"$projectdesc\")"
916 projurl
="$cfg_gitweburl/$projectname"
917 projurlesc
="$(printf '%s\n' "$projurl" | sed -e 's/%/%%/g')"
920 emailextraheader
="$6"
922 recipients
=$
(git config hooks.mailinglist
)
923 summaryonly
=$
(git config
--bool hooks.summaryonly
2>/dev
/null ||
:)
924 announcerecipients
=$
(git config hooks.announcelist
)
925 envelopesender
=$
(git config hooks.envelopesender
)
926 emailprefix
=$
(git config hooks.emailprefix || echol
"[$cfg_name] ")
927 custom_showrev
=$
(git config hooks.showrev
)
930 # Allow dual mode: run from the command line just like the update hook, or
931 # if no arguments are given then run as a hook script
932 # If --stdout is first argument send all output there instead (handled above)
933 # Optional 4th (projectname), 5th (sender) and 6th (extra header) arguments
934 if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
935 # Handle a single update rather than a batch on stdin
936 # Output will still be sent to sendmail unless --stdout is used
937 # Same 3 args as update hook (<refname> <old> <new>)
938 if prep_for_email
$2 $3 $1; then
939 PAGER
= generate_email | size_limit $
((256*1024)) | send_mail
942 # Same input as pre-receive hook (each line is <old> <new> <refname>)
943 while read oldrev newrev refname
945 prep_for_email
$oldrev $newrev $refname ||
continue
946 PAGER
= generate_email | size_limit $
((256*1024)) | send_mail