[Fusionforge-commits] FusionForge branch master updated. 767da94774d4d733ba407e552a687fa3545c578b

Thorsten Glaser mirabilos at fusionforge.org
Wed May 21 14:12:03 CEST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  767da94774d4d733ba407e552a687fa3545c578b (commit)
       via  44c542e82f37e537f6509693f7fb993c4113920c (commit)
       via  28a9dc74a5b7b1ffb36966c772dd5ecfe7a29600 (commit)
       via  06e9c1349a868e6dc6969b9625c7f91d3dde1bc0 (commit)
       via  a6cd1aaa5e981b487a5b5d535c9f50e2d215f72f (commit)
       via  208fd516a40192f133347df0b549b9428965dc55 (commit)
       via  c745d18861305bd7e27d917f4477e4f0a13dba9a (commit)
       via  bdf60da26684983e2143f302098f6a17e5b7a829 (commit)
       via  e97fa3ac0007b36537ace4375ed027fb2c25c827 (commit)
       via  d8ad4be33179a44e43b4e2d6f2684a45e1c63324 (commit)
       via  291678e4c2b19921d6aae32b968b0444e5bb8fa3 (commit)
       via  74752ee0cb9fd4cf86f53affd8e13e63c4c1db04 (commit)
       via  6d9c1b42da35a88a56cbdb17912980daf943a96d (commit)
       via  6a8210c74b82c091b12b5cc7a107dd1b9fd03a39 (commit)
       via  32ca415570efb66aca251066e9795d969ca0ac00 (commit)
       via  6a72b96e14aab331cbdaff7788b47cdbb913a864 (commit)
       via  b57addb59e2ff939b05b4ce49de568b55ae7ecd2 (commit)
       via  e9bdc995c5dd67bdac1431665ee1bfbc8d964cdb (commit)
       via  caa081600305eebdc05c00405048964888c3e39f (commit)
       via  d85eca5ba73e4344e54ad05c58637d416945a48a (commit)
       via  1096089cb45b1a7ab0942045155c32cb8250a5a1 (commit)
       via  b61cfcd1f0fb9248300459bcb88c999d1ada936e (commit)
       via  6c1790d161a95c4e0272d43c8fe17173d74fe558 (commit)
       via  78fe6337bfd33d32227e60a3b693061e89bf8809 (commit)
       via  23beea685962a807c78d8e4e2bef7b9cf94d8452 (commit)
       via  b98d98220078b9a596de722ae71fa1989f13eaf4 (commit)
       via  dca582fbca9860b5c9e006cbbaaa798e4a366475 (commit)
       via  adb644b29d4df15b8a7201572c821734dbe38dda (commit)
       via  7254ecb5a45fdd192506ebbff805c7adda0e00af (commit)
       via  7647b25b07755839137b65192261e5e3340f0dc9 (commit)
       via  c206232b77e854d80e3aeec218934ca5427cb2d6 (commit)
       via  e0accbdfc52e8b107f9b61522499d13acde7824c (commit)
       via  513c5768c2a9518c8d88736c9c8236a438bd439d (commit)
       via  afeaeb13fb95b49434f19c2b7758eeee0d7008fa (commit)
       via  0866c461831be884455f419386c7d64dd509e405 (commit)
       via  172dd4929678a95fe0f6eef8a5895f6af70ce72b (commit)
       via  b2f5a56756ca884340a3c921156f678b5436f77c (commit)
       via  2cd6cdef715131b46cdf62a60ffc97174aa85ae8 (commit)
       via  3814641b08ca2aa296380c175f663a1e0b752add (commit)
       via  3b3594a9eb8c324d37c06caf047b702b28b2bef9 (commit)
       via  96ff8748ae4dc4e595c5c2f6c043ab7bacd16c13 (commit)
       via  270a0c3a52afd535ead9c5704b7ce8c4700deaa9 (commit)
       via  08c61ac1caa15a79abae9f4eb6e1a5a179bb14af (commit)
       via  d2735a5bd1326cebafcc6f07948adb2b47f9037a (commit)
       via  8d7131c4bd9d832f8505df9e75a9131f17a08937 (commit)
       via  30f2269ba7c1d8a079ed6dceefd361ecd56a6693 (commit)
       via  034bfa94f1e5b66077a3450f7fe38c852d8b5a9c (commit)
       via  3e1527da3000e9ba091808bab5d04bd7d948cdcf (commit)
       via  8591396babfad4903fa6b72ab64b1def3eb8567a (commit)
       via  4e2873fdaa4fe4dd500921c062870e7282bccb33 (commit)
       via  8de832eaa4536bb256f0b8b2650656cd62df9498 (commit)
       via  c7250f98535a85712cb98475a0416e2e7fd7f4ba (commit)
       via  6ea66972be087069d02483174ddc298768d2bba1 (commit)
       via  a35442bafc0d09c555af36eefa80f1e077ddcd89 (commit)
       via  7fc31c6fa5143dd2a1da0023e75b4a829817a981 (commit)
       via  0dc46f303fe1ff95c3bafb234ece2816dcffdf90 (commit)
       via  5e621031f41c5d5e07fa13caf2ceb3e620fdf5ed (commit)
       via  7e0daa9d931d90abbb0cd15baf643ea3b7abfedf (commit)
       via  ad8e89bffc15956f052440e25db71e9b7a259b89 (commit)
       via  18ae76502a82fa944d0f54563571356de71513ed (commit)
       via  b64330d7fb7b81499c3265d175f1d056b71c0cc2 (commit)
       via  6fac0ce8f371762c3ef4010b5651e4cd93d4dda2 (commit)
       via  42e534f95a0ce7d1b759e7ce7591ead4ee4aeb91 (commit)
       via  1ddc5267c3078b45e3fd7db747042279284dd117 (commit)
       via  881aa53d5b8b64c43138a6577363d834845027f9 (commit)
       via  4a254b5f208c6fd5f42d2671f5dd02d6f877f736 (commit)
       via  80e22d4b4c43d7f675fed2a9c3618ad68bdcf599 (commit)
      from  29359e7ce8162181504e7bf8a8cbf2cf2986c9a8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 767da94774d4d733ba407e552a687fa3545c578b
Merge: 29359e7 44c542e
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Wed May 21 14:10:18 2014 +0200

    subtree-merge updated git post-receive hook from Evolvis
    
    • including full history
    • rename the script and adjust the caller accordingly

diff --cc src/plugins/scmhook/library/scmgit/hooks/postreceiveemail/LICENCE
index 0000000,083c2da..083c2da
mode 000000,100644..100644
--- a/src/plugins/scmhook/library/scmgit/hooks/postreceiveemail/LICENCE
+++ b/src/plugins/scmhook/library/scmgit/hooks/postreceiveemail/LICENCE
diff --cc src/plugins/scmhook/library/scmgit/hooks/postreceiveemail/README
index 0000000,cd6877e..cd6877e
mode 000000,100644..100644
--- a/src/plugins/scmhook/library/scmgit/hooks/postreceiveemail/README
+++ b/src/plugins/scmhook/library/scmgit/hooks/postreceiveemail/README
diff --cc src/plugins/scmhook/library/scmgit/postReceiveEmail.class.php
index 96ef367,0000000..e724d29
mode 100644,000000..100644
--- a/src/plugins/scmhook/library/scmgit/postReceiveEmail.class.php
+++ b/src/plugins/scmhook/library/scmgit/postReceiveEmail.class.php
@@@ -1,67 -1,0 +1,67 @@@
 +<?php
 +/**
 + * scmhook postReceiveEmail Plugin Class
 + * Copyright 2013, Benoit Debaenst - TrivialDev
 + *
 + * This file is part of FusionForge. FusionForge is free software;
 + * you can redistribute it and/or modify it under the terms of the
 + * GNU General Public License as published by the Free Software
 + * Foundation; either version 2 of the Licence, or (at your option)
 + * any later version.
 + *
 + * FusionForge is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License along
 + * with FusionForge; if not, write to the Free Software Foundation, Inc.,
 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 + */
 +
 +global $gfplugins;
 +require_once $gfplugins.'scmhook/common/scmhook.class.php';
 +
 +class GitPostReceiveEmail extends scmhook {
 +	var $group;
 +	var $disabledMessage;
 +
 +	function __construct() {
 +		$this->group = $GLOBALS['group'];
 +		$this->name = "Post Receive Email";
 +		$this->description = _('Commit message log is pushed to commit mailing-list of the project');
 +		$this->classname = "postReceiveEmail";
 +		$this->hooktype = "post-receive";
 +		$this->label = "scmgit";
 +		$this->unixname = "postreceiveemail";
 +		$this->needcopy = 0;
- 		$this->command = '/bin/sh '.forge_get_config('plugins_path').'/scmhook/library/'.$this->label.'/hooks/'.$this->unixname.'/postreceiveemail <<eoc '."\n".'$PARAMS'."\n".'eoc';
++		$this->command = '/bin/sh '.forge_get_config('plugins_path').'/scmhook/library/'.$this->label.'/hooks/'.$this->unixname.'/post-receive-email <<eoc '."\n".'$PARAMS'."\n".'eoc';
 +	}
 +
 +	function isAvailable() {
 +		global $gfcommon;
 +		require_once $gfcommon.'mail/MailingList.class.php';
 +		require_once $gfcommon.'mail/MailingListFactory.class.php';
 +
 +		if ($this->group->usesMail() && forge_get_config('use_ssh','scmgit')) {
 +			$mlFactory = new MailingListFactory($this->group);
 +			$mlArray = $mlFactory->getMailingLists();
 +			$mlCount = count($mlArray);
 +			for ($j = 0; $j < $mlCount; $j++) {
 +				$currentList =& $mlArray[$j];
 +				if ($currentList->getListEmail() == $this->group->getUnixName().'-commits@'.forge_get_config('lists_host'))
 +					return true;
 +			}
 +			$this->disabledMessage = _('Hook not available due to missing dependency: Project has no commit mailing-list: ').$this->group->getUnixName().'-commits';
 +		} elseif (!$this->group->usesMail()) {
 +			$this->disabledMessage = _('Hook not available due to missing dependency: Project not using mailing-list.');
 +		} elseif (!forge_get_config('use_ssh','scm_git')) {
 +			$this->disabledMessage = _('Hook not available due to missing dependency: Forge not using SSH for Git.');
 +		}
 +		return false;
 +	}
 +
 +	function getDisabledMessage() {
 +		return $this->disabledMessage;
 +	}
 +}

commit 44c542e82f37e537f6509693f7fb993c4113920c
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Fri Apr 11 14:15:09 2014 +0200

    branch and instructions for merging

diff --git a/README b/README
index bb028c0..cd6877e 100644
--- a/README
+++ b/README
@@ -15,7 +15,13 @@ tarent, FreeWRT (now The MirOS Project), Teckids.
 • https://evolvis.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=evolvis-platfrm/recvhook.githttps://github.com/mirabilos/recvhook
 
-Please do steer new contributions to Evolvis.
+Please do steer new contributions to Evolvis. Development will
+be done in the “standalone” branch which can then be merged to
+both “master” (for visibility) and “forge” (further integrati‐
+ve and development work). Ensure the live branches and release
+tags always only have the hook script (not this README file or
+the LICENCE file) in them, since other repositories merge them
+using the subtree strategy regularily.
 
 Links:
 • https://evolvis.org/
@@ -29,6 +35,9 @@ Links:
 • http://mako.cc/writing/hill-free_tools.html
   ‣ why you should *not* be using github!
 • http://mako.cc/copyrighteous/freedom-for-users-not-for-software
+  ‣ more on that
+• https://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html
+  ‣ merge this script into your own repository
 
 ┌───────────────┐
 │ Documentation │

commit 28a9dc74a5b7b1ffb36966c772dd5ecfe7a29600
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Fri Apr 11 14:07:48 2014 +0200

    add README and LICENCE, for push to github, for popularity
    as discussed in FusionForge meeting

diff --git a/LICENCE b/LICENCE
new file mode 100644
index 0000000..083c2da
--- /dev/null
+++ b/LICENCE
@@ -0,0 +1,360 @@
+The post-receive-email script is derived from the one
+shipping with the git software, and thus comes under
+the following licence:
+
+# Copyright © 2013
+#	Thorsten “mirabilos” Glaser <thorsten.glaser at teckids.org>
+# Copyright © 2011, 2012, 2013, 2014
+#	Thorsten “mirabilos” Glaser <t.glaser at tarent.de>
+#
+# Copyright (c) 2007 Andy Parkins
+#
+# This code is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+
+Yes, this does mean no later version.
+
+Here’s a copy of the GNU GPL version 2 for reference:
+
+────────────────────────────────────────────────────────────────────────
+
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                            NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/README b/README
new file mode 100644
index 0000000..bb028c0
--- /dev/null
+++ b/README
@@ -0,0 +1,62 @@
+┌──────────┐
+│ recvhook │
+└──────────┘
+
+This git repository took out the contributed post-receive hook
+from git.git with its full history and aims to continue to fix
+and develop it. There is also FusionForge/Evolvis integration,
+in a separate branch.
+
+This repository is hosted on evolvis.org (a public FusionForge
+instance by tarent). We mirror it on github for popularity, as
+shown below. Development of the hook is partially sponsored by
+tarent, FreeWRT (now The MirOS Project), Teckids.
+
+• https://evolvis.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=evolvis-platfrm/recvhook.git
+• https://github.com/mirabilos/recvhook
+
+Please do steer new contributions to Evolvis.
+
+Links:
+• https://evolvis.org/
+  ‣ start page of the public Evolvis instance
+• https://evolvis.org/projects/evolvis-platfrm/
+  ‣ project page for developing Evolvis itself
+• https://fusionforge.org/
+  ‣ EvolvisForge’s upstream, FusionForge
+• http://www.tarent.de/
+  ‣ tarent solutions GmbH, sponsoring part of this
+• http://mako.cc/writing/hill-free_tools.html
+  ‣ why you should *not* be using github!
+• http://mako.cc/copyrighteous/freedom-for-users-not-for-software
+
+┌───────────────┐
+│ Documentation │
+└───────────────┘
+
+This script is basically a replacement for the script
+that came with git, except you will not see the annoying
+“[SCM] ” præfix in eMails any more, and have to change
+a few configuration settings:
+
+• hooks.showrev ⇒ clear this, use our default
+• hooks.diffopts ⇒ clear this, use our default
+
+There are notable new settings:
+
+• hooks.replyto (sets a Reply-To: header)
+• hooks.shortdesc (used in the Subject: header instead
+  of the content of the description file)
+• hooks.kgbconffile (full path to a configuration file
+  for kgb-client, triggers on-push IRC notifications)
+
+There’s also noticeable effort to fix umlauts and
+other nōn-ASCII characters in eMails – as long as
+you use UTF-8 in your commits, of course.
+
+For more information, please read the script directly.
+If there will ever be frequently asked questions, I’ll
+amend this documentation section though ☺
+
+bye,
+//mirabilos

commit 06e9c1349a868e6dc6969b9625c7f91d3dde1bc0
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Fri Mar 28 18:44:18 2014 +0100

    default emailprefix to empty

diff --git a/post-receive-email b/post-receive-email
index 84ac1d2..e083bbb 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -70,8 +70,8 @@
 #   If set then the -f option is passed to sendmail to allow the envelope
 #   sender address to be set.  This is also used as Header From.
 # hooks.emailprefix
-#   All emails have their subjects prefixed with this prefix, or "[SCM]"
-#   if emailprefix is unset, to aid filtering.
+#   If set, e.g. to '[SCM] ', all eMails have their subjects prefixed
+#   with this string to aid filtering.
 # hooks.shortdesc
 #   If set, this is used in the Subject instead of the description file.
 # hooks.showrev
@@ -789,7 +789,7 @@ fi
 recipients=$(git config hooks.mailinglist)
 announcerecipients=$(git config hooks.announcelist)
 envelopesender=$(git config hooks.envelopesender)
-emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')
+emailprefix=$(git config hooks.emailprefix)
 custom_showrev=$(git config hooks.showrev)
 maxlines=$(git config hooks.emailmaxlines)
 diffopts=$(git config hooks.diffopts)

commit a6cd1aaa5e981b487a5b5d535c9f50e2d215f72f
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Fri Mar 28 18:32:52 2014 +0100

    permit using a shorter project desc for the eMail Subject

diff --git a/post-receive-email b/post-receive-email
index 1e1fe03..84ac1d2 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -71,7 +71,9 @@
 #   sender address to be set.  This is also used as Header From.
 # hooks.emailprefix
 #   All emails have their subjects prefixed with this prefix, or "[SCM]"
-#   if emailprefix is unset, to aid filtering
+#   if emailprefix is unset, to aid filtering.
+# hooks.shortdesc
+#   If set, this is used in the Subject instead of the description file.
 # hooks.showrev
 #   The shell command used to format each revision in the email, with
 #   "%s" replaced with the commit id.  Defaults to "git rev-list -1
@@ -293,7 +295,7 @@ generate_email_header()
 	X-Git-Reftype: $refname_type
 	X-Git-Oldrev: $oldrev
 	X-Git-Newrev: $newrev
-	$(perl -Mutf8 -MEncode -e "print encode('MIME-Q', 'Subject: ${emailprefix}$projectdesc $refname_type $short_refname ${change_type}d. $describe');")
+	$(perl -Mutf8 -MEncode -e "print encode('MIME-Q', 'Subject: ${emailprefix}$shortdesc $refname_type $short_refname ${change_type}d. $describe');")
 	Auto-Submitted: auto-generated
 
 	This is an automated email from the git hooks/post-receive script. It was
@@ -794,6 +796,8 @@ diffopts=$(git config hooks.diffopts)
 : ${diffopts:="-p --stat --summary --find-copies-harder"}
 kgbconffile=$(git config hooks.kgbconffile)
 replyto=$(git config hooks.replyto)
+shortdesc=$(git config hooks.shortdesc)
+: ${shortdesc:=$projectdesc}
 
 # --- Main loop
 # Allow dual mode: run from the command line just like the update hook, or

commit 208fd516a40192f133347df0b549b9428965dc55
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Fri Mar 28 18:30:00 2014 +0100

    add replyto config; fix envelope sender (docs and when empty)

diff --git a/post-receive-email b/post-receive-email
index d4bd229..1e1fe03 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -64,9 +64,11 @@
 #   This is the list that all pushes of annotated tags will go to.  Leave it
 #   blank to default to the mailinglist field.  The announce emails lists
 #   the short log summary of the changes since the last annotated tag.
+# hooks.replyto
+#   If set, replies are requested to be directed to this eMail address.
 # hooks.envelopesender
 #   If set then the -f option is passed to sendmail to allow the envelope
-#   sender address to be set
+#   sender address to be set.  This is also used as Header From.
 # hooks.emailprefix
 #   All emails have their subjects prefixed with this prefix, or "[SCM]"
 #   if emailprefix is unset, to aid filtering
@@ -277,12 +279,16 @@ generate_email_header()
 {
 	# --- Email (all stdout will be the email)
 	# Generate header
+
+	routing_headers="To: $recipients"
+	[[ -n $envelopesender ]] && routing_headers="From: $envelopesender${nl}$routing_headers"
+	[[ -n $replyto ]] && routing_headers="$routing_headers${nl}Reply-To: $replyto"
+
 	cat <<-EOF
 	MIME-Version: 1.0
 	Content-Type: text/plain; charset=UTF-8
 	Content-Transfer-Encoding: 8bit
-	From: $envelopesender
-	To: $recipients
+	$routing_headers
 	X-Git-Refname: $refname
 	X-Git-Reftype: $refname_type
 	X-Git-Oldrev: $oldrev
@@ -787,6 +793,7 @@ maxlines=$(git config hooks.emailmaxlines)
 diffopts=$(git config hooks.diffopts)
 : ${diffopts:="-p --stat --summary --find-copies-harder"}
 kgbconffile=$(git config hooks.kgbconffile)
+replyto=$(git config hooks.replyto)
 
 # --- Main loop
 # Allow dual mode: run from the command line just like the update hook, or

commit c745d18861305bd7e27d917f4477e4f0a13dba9a
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Fri Mar 28 18:23:44 2014 +0100

    include envelope sender as header From, from Evolvis
    
    rationale: allows 'Foo Bar <baz at example.com>' as envelope sender
    iff sendmail(8)’s -f option permits

diff --git a/post-receive-email b/post-receive-email
index cebc043..d4bd229 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -281,6 +281,7 @@ generate_email_header()
 	MIME-Version: 1.0
 	Content-Type: text/plain; charset=UTF-8
 	Content-Transfer-Encoding: 8bit
+	From: $envelopesender
 	To: $recipients
 	X-Git-Refname: $refname
 	X-Git-Reftype: $refname_type

commit bdf60da26684983e2143f302098f6a17e5b7a829
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Fri Mar 28 18:23:20 2014 +0100

    move MIME stuff first, to ease interpretation of stuff below

diff --git a/post-receive-email b/post-receive-email
index 4f6b323..cebc043 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -278,10 +278,10 @@ generate_email_header()
 	# --- Email (all stdout will be the email)
 	# Generate header
 	cat <<-EOF
-	To: $recipients
 	MIME-Version: 1.0
 	Content-Type: text/plain; charset=UTF-8
 	Content-Transfer-Encoding: 8bit
+	To: $recipients
 	X-Git-Refname: $refname
 	X-Git-Reftype: $refname_type
 	X-Git-Oldrev: $oldrev

commit e97fa3ac0007b36537ace4375ed027fb2c25c827
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Fri Mar 28 17:22:36 2014 +0100

    always show a diff; document configuration related to this
    
    also document what diffs there are

diff --git a/post-receive-email b/post-receive-email
index 515e820..4f6b323 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -75,7 +75,11 @@
 #   "%s" replaced with the commit id.  Defaults to "git rev-list -1
 #   --pretty %s", displaying the commit id, author, date and log
 #   message.  To list full patches separated by a blank line, you
-#   could set this to "git show -C %s; echo".
+#   could set this to "git show -C %s; echo". If you do that, make
+#   sure to remove the "-p" from hooks.diffopts to avoid getting
+#   two sets of diffs (the showrev diff is per commit, whereas the
+#   diffopts patch will show what really happened in the push as
+#   one diff).
 #   To list a gitweb/cgit URL *and* a full patch for each change set, use this:
 #     "t=%s; printf 'http://.../?id=%%s' \$t; echo;echo; git show -C \$t; echo"
 #   Be careful if "..." contains things that will be expanded by shell "eval"
@@ -87,9 +91,9 @@
 #   line is added indicating the number of suppressed lines.
 # hooks.diffopts
 #   Alternate options for the git diff-tree invocation that shows changes.
-#   Default is "--stat --summary --find-copies-harder". Add -p to those
-#   options to include a unified diff of changes in addition to the usual
-#   summary output.
+#   Default is "-p --stat --summary --find-copies-harder". Remove -p from
+#   those options to skil including a unified diff of changes in addition
+#   to the summary output. See hooks.showrev for more discussion on this.
 # hooks.kgbconffile
 #   Full path to a configuration file for kgb-client, or unset/empty.
 #   If set, kgb-client will be invoked.
@@ -780,7 +784,7 @@ emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')
 custom_showrev=$(git config hooks.showrev)
 maxlines=$(git config hooks.emailmaxlines)
 diffopts=$(git config hooks.diffopts)
-: ${diffopts:="--stat --summary --find-copies-harder"}
+: ${diffopts:="-p --stat --summary --find-copies-harder"}
 kgbconffile=$(git config hooks.kgbconffile)
 
 # --- Main loop

commit d8ad4be33179a44e43b4e2d6f2684a45e1c63324
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Fri Mar 28 17:12:59 2014 +0100

    fix Content-Type charset, from Evolvis

diff --git a/post-receive-email b/post-receive-email
index 48a02de..515e820 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -276,7 +276,7 @@ generate_email_header()
 	cat <<-EOF
 	To: $recipients
 	MIME-Version: 1.0
-	Content-Type: text/plain; charset=utf-8
+	Content-Type: text/plain; charset=UTF-8
 	Content-Transfer-Encoding: 8bit
 	X-Git-Refname: $refname
 	X-Git-Reftype: $refname_type

commit 291678e4c2b19921d6aae32b968b0444e5bb8fa3
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Fri Mar 28 16:58:10 2014 +0100

    merge from Teckids: properly encode the Subject (RFC2047)

diff --git a/post-receive-email b/post-receive-email
index 1cd57bc..48a02de 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -275,7 +275,6 @@ generate_email_header()
 	# Generate header
 	cat <<-EOF
 	To: $recipients
-	Subject: ${emailprefix}$projectdesc $refname_type $short_refname ${change_type}d. $describe
 	MIME-Version: 1.0
 	Content-Type: text/plain; charset=utf-8
 	Content-Transfer-Encoding: 8bit
@@ -283,6 +282,7 @@ generate_email_header()
 	X-Git-Reftype: $refname_type
 	X-Git-Oldrev: $oldrev
 	X-Git-Newrev: $newrev
+	$(perl -Mutf8 -MEncode -e "print encode('MIME-Q', 'Subject: ${emailprefix}$projectdesc $refname_type $short_refname ${change_type}d. $describe');")
 	Auto-Submitted: auto-generated
 
 	This is an automated email from the git hooks/post-receive script. It was

commit 74752ee0cb9fd4cf86f53affd8e13e63c4c1db04
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Fri Mar 28 17:09:35 2014 +0100

    merge from Evolvis: Gerrit support

diff --git a/post-receive-email b/post-receive-email
index e2024a8..1cd57bc 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -180,6 +180,11 @@ prep_for_email()
 			refname_type="branch"
 			short_refname=${refname##refs/heads/}
 			;;
+		refs/changes/*,commit)
+			# Gerrit
+			refname_type="review change"
+			short_refname=${refname##refs/}
+			;;
 		refs/remotes/*,commit)
 			# tracking branch
 			refname_type="tracking branch"

commit 6d9c1b42da35a88a56cbdb17912980daf943a96d
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Fri Mar 28 17:14:22 2014 +0100

    prevent sending out empty emails, from Evolvis

diff --git a/post-receive-email b/post-receive-email
index 9163218..e2024a8 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -733,7 +733,12 @@ limit_lines()
 
 send_mail()
 {
-	if [ -n "$envelopesender" ]; then
+	local x=$(cat; echo x)
+
+	x=${x%x}
+	[[ -n $x ]] || return 1
+
+	print -nr -- "$x" | if [ -n "$envelopesender" ]; then
 		/usr/sbin/sendmail -t -f "$envelopesender"
 	else
 		/usr/sbin/sendmail -t

commit 6a8210c74b82c091b12b5cc7a107dd1b9fd03a39
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Fri Mar 28 17:05:36 2014 +0100

    integrate kgb-client support; inspired by Teckids change

diff --git a/post-receive-email b/post-receive-email
index 85074cb..9163218 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -90,6 +90,9 @@
 #   Default is "--stat --summary --find-copies-harder". Add -p to those
 #   options to include a unified diff of changes in addition to the usual
 #   summary output.
+# hooks.kgbconffile
+#   Full path to a configuration file for kgb-client, or unset/empty.
+#   If set, kgb-client will be invoked.
 #
 # Notes
 # -----
@@ -768,6 +771,7 @@ custom_showrev=$(git config hooks.showrev)
 maxlines=$(git config hooks.emailmaxlines)
 diffopts=$(git config hooks.diffopts)
 : ${diffopts:="--stat --summary --find-copies-harder"}
+kgbconffile=$(git config hooks.kgbconffile)
 
 # --- Main loop
 # Allow dual mode: run from the command line just like the update hook, or
@@ -778,9 +782,15 @@ if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
 	# themselves
 	prep_for_email $2 $3 $1 && PAGER= generate_email
 else
+	ilines=
 	while read oldrev newrev refname
 	do
+		ilines="$ilines$oldrev $newrev $refname$nl"
 		prep_for_email $oldrev $newrev $refname || continue
 		generate_email $maxlines | send_mail
 	done
+	if [[ -n $kgbconffile && -s $kgbconffile ]]; then
+		print -nr -- "$ilines" | kgb-client \
+		    --conf "$kgbconffile" --repository git --git-reflog -
+	fi
 fi

commit 32ca415570efb66aca251066e9795d969ca0ac00
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Fri Mar 28 16:56:35 2014 +0100

    merge from Teckids and EvolvisForge: environment; locale sanitisation

diff --git a/post-receive-email b/post-receive-email
index 61c1b2f..85074cb 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -1,4 +1,9 @@
-#!/bin/sh
+#!/bin/mksh
+#
+# Copyright © 2013
+#	Thorsten “mirabilos” Glaser <thorsten.glaser at teckids.org>
+# Copyright © 2011, 2012, 2013, 2014
+#	Thorsten “mirabilos” Glaser <t.glaser at tarent.de>
 #
 # Copyright (c) 2007 Andy Parkins
 #
@@ -34,6 +39,9 @@
 #  ln -sf /etc/gforge/plugins/scmgit/post-receive-email.sh hooks/post-receive
 #  # but that can only be used for a Forge-controlled repository
 #
+# This hook script needs the “en_US.UTF-8” locale set up on the server.
+# The MirBSD Korn Shell (mksh) must be installed as /bin/mksh and usable.
+#
 # This hook script assumes it is enabled on the central repository of a
 # project, with all users pushing only to it and not between each other.  It
 # will still work if you don't operate in that style, but it would become
@@ -90,6 +98,16 @@
 # give information for debugging.
 #
 
+# ---------------------------- Environment Sanitisation
+
+nl='
+'
+unset LANGUAGE LC_ALL
+export LANG=C LC_ADDRESS=C LC_COLLATE=C LC_CTYPE=en_US.UTF-8 \
+    LC_IDENTIFICATION=C LC_MEASUREMENT=C LC_MESSAGES=C \
+    LC_MONETARY=C LC_NAME=C LC_NUMERIC=C LC_PAPER=C \
+    LC_TELEPHONE=C LC_TIME=C
+
 # ---------------------------- Functions
 
 #

commit 6a72b96e14aab331cbdaff7788b47cdbb913a864
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Fri Mar 28 17:07:31 2014 +0100

    FusionForge paths

diff --git a/post-receive-email b/post-receive-email
index 0c2f975..61c1b2f 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -23,12 +23,16 @@
 # This hook is stored in the contrib/hooks directory.  Your distribution
 # will have put this somewhere standard.  You should make this script
 # executable then link to it in the repository you would like to use it in.
-# For example, on debian the hook is stored in
-# /usr/share/git-core/contrib/hooks/post-receive-email:
+# For example, on Debian the hook is stored in
+# /usr/share/git-core/contrib/hooks/post-receive-email
+# but as /etc/gforge/plugins/scmgit/post-receive-email.sh in FusionForge.
 #
 #  chmod a+x post-receive-email
 #  cd /path/to/your/repository.git
 #  ln -sf /usr/share/git-core/contrib/hooks/post-receive-email hooks/post-receive
+#  # or
+#  ln -sf /etc/gforge/plugins/scmgit/post-receive-email.sh hooks/post-receive
+#  # but that can only be used for a Forge-controlled repository
 #
 # This hook script assumes it is enabled on the central repository of a
 # project, with all users pushing only to it and not between each other.  It

commit b57addb59e2ff939b05b4ce49de568b55ae7ecd2
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Fri Mar 28 16:40:58 2014 +0100

    use --encoding=UTF-8 with “git shortlog”
    
    this comes from Debian wheezy but never was upstreamed

diff --git a/post-receive-email b/post-receive-email
index dfec53a..0c2f975 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -554,11 +554,11 @@ generate_atag_email()
 		# performed on them
 		if [ -n "$prevtag" ]; then
 			# Show changes since the previous release
-			git shortlog "$prevtag..$newrev"
+			git shortlog --encoding=UTF-8 "$prevtag..$newrev"
 		else
 			# No previous tag, show all the changes since time
 			# began
-			git shortlog $newrev
+			git shortlog --encoding=UTF-8 $newrev
 		fi
 		;;
 	*)

commit e9bdc995c5dd67bdac1431665ee1bfbc8d964cdb
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Fri Mar 28 16:40:19 2014 +0100

    revert part of an upstream commit removing a comment about chmod +x

diff --git a/post-receive-email b/post-receive-email
index 4add9a2..dfec53a 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -26,6 +26,7 @@
 # For example, on debian the hook is stored in
 # /usr/share/git-core/contrib/hooks/post-receive-email:
 #
+#  chmod a+x post-receive-email
 #  cd /path/to/your/repository.git
 #  ln -sf /usr/share/git-core/contrib/hooks/post-receive-email hooks/post-receive
 #

commit caa081600305eebdc05c00405048964888c3e39f
Author: Thorsten Glaser <t.glaser at tarent.de>
Date:   Fri Mar 28 17:42:17 2014 +0100

    tack on GPLv2-only licencing information from git.git

diff --git a/post-receive-email b/post-receive-email
index 8747b84..4add9a2 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -2,6 +2,10 @@
 #
 # Copyright (c) 2007 Andy Parkins
 #
+# This code is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
 # An example hook script to mail out commit update information.
 #
 # NOTE: This script is no longer under active development.  There

commit d85eca5ba73e4344e54ad05c58637d416945a48a
Author: Jonathan Nieder <jrnieder at gmail.com>
Date:   Mon Nov 25 12:55:30 2013 -0800

    mark contributed hooks executable
    
    The docs in contrib/hooks/pre-auto-gc-battery suggest:
    
    	For example, if the hook is stored in
    	/usr/share/git-core/contrib/hooks/pre-auto-gc-battery:
    
    	chmod a+x pre-auto-gc-battery
    	cd /path/to/your/repository.git
    	ln -sf /usr/share/git-core/contrib/hooks/pre-auto-gc-battery \
    	     hooks/pre-auto-gc
    
    Unfortunately on multi-user systems most users do not have write
    access to /usr.  Better to mark the sample hooks executable in
    the first place so users do not have to tweak their permissions to
    use them by symlinking into .git/hooks/.
    
    Reported-by: Olivier Berger <olivier.berger at it-sudparis.eu>
    Signed-off-by: Jonathan Nieder <jrnieder at gmail.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 8ee410f..8747b84 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -22,7 +22,6 @@
 # For example, on debian the hook is stored in
 # /usr/share/git-core/contrib/hooks/post-receive-email:
 #
-#  chmod a+x post-receive-email
 #  cd /path/to/your/repository.git
 #  ln -sf /usr/share/git-core/contrib/hooks/post-receive-email hooks/post-receive
 #

commit 1096089cb45b1a7ab0942045155c32cb8250a5a1
Author: Gerrit Pape <pape at smarden.org>
Date:   Thu Dec 11 20:27:21 2008 +0000

    hooks/post-receive-email: set declared encoding to utf-8
    
    Some email clients (e.g., claws-mail) display the message body
    incorrectly when the charset is not defined explicitly in a
    Content-Type header.  "git log" generates logs in UTF-8 encoding by
    default, so add a Content-Type header declaring that encoding to
    the emails the post-receive-email example hook sends.
    
    [jn: also setting the Content-Transfer-Encoding so MTAs know what
     kind of mangling might be needed when sending to a non 8-bit clean
     SMTP host]
    
    Requested-by: Alexander Gerasiov <gq at debian.org>
    Signed-off-by: Jonathan Nieder <jrnieder at gmail.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index ba93a0d..8ee410f 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -242,6 +242,9 @@ generate_email_header()
 	cat <<-EOF
 	To: $recipients
 	Subject: ${emailprefix}$projectdesc $refname_type $short_refname ${change_type}d. $describe
+	MIME-Version: 1.0
+	Content-Type: text/plain; charset=utf-8
+	Content-Transfer-Encoding: 8bit
 	X-Git-Refname: $refname
 	X-Git-Reftype: $refname_type
 	X-Git-Oldrev: $oldrev

commit b61cfcd1f0fb9248300459bcb88c999d1ada936e
Author: Jonathan Nieder <jrnieder at gmail.com>
Date:   Fri Aug 2 16:23:38 2013 -0700

    hooks/post-receive-email: force log messages in UTF-8
    
    Git commands write commit messages in UTF-8 by default, but that
    default can be overridden by the [i18n] commitEncoding and
    logOutputEncoding settings.  With such a setting, the emails written
    by the post-receive-email hook use a mixture of encodings:
    
     1. Log messages use the configured log output encoding, which is
        meant to be whatever encoding works best with local terminals
        (and does not have much to do with what encoding should be used
        for email)
    
     2. Filenames are left as is: on Linux, usually UTF-8, and in the Mingw
        port (which uses Unicode filesystem APIs), always UTF-8
    
     3. The "This is an automated email" preface uses a project description
        from .git/description, which is typically in UTF-8 to support
        gitweb.
    
    So (1) is configurable, and (2) and (3) are unconfigurable and
    typically UTF-8.  Override the log output encoding to always use UTF-8
    when writing the email to get the best chance of a comprehensible
    single-encoding email.
    
    Signed-off-by: Jonathan Nieder <jrnieder at gmail.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 7208451..ba93a0d 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -471,7 +471,7 @@ generate_delete_branch_email()
 	echo "       was  $oldrev"
 	echo ""
 	echo $LOGBEGIN
-	git diff-tree -s --always --pretty=oneline $oldrev
+	git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev
 	echo $LOGEND
 }
 
@@ -571,7 +571,7 @@ generate_delete_atag_email()
 	echo "       was  $oldrev"
 	echo ""
 	echo $LOGBEGIN
-	git diff-tree -s --always --pretty=oneline $oldrev
+	git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev
 	echo $LOGEND
 }
 
@@ -617,7 +617,7 @@ generate_general_email()
 	echo ""
 	if [ "$newrev_type" = "commit" ]; then
 		echo $LOGBEGIN
-		git diff-tree -s --always --pretty=medium $newrev
+		git diff-tree -s --always --encoding=UTF-8 --pretty=medium $newrev
 		echo $LOGEND
 	else
 		# What can we do here?  The tag marks an object that is not
@@ -636,7 +636,7 @@ generate_delete_general_email()
 	echo "       was  $oldrev"
 	echo ""
 	echo $LOGBEGIN
-	git diff-tree -s --always --pretty=oneline $oldrev
+	git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev
 	echo $LOGEND
 }
 

commit 6c1790d161a95c4e0272d43c8fe17173d74fe558
Author: Jonathan Nieder <jrnieder at gmail.com>
Date:   Fri Aug 2 16:22:08 2013 -0700

    hooks/post-receive-email: use plumbing instead of git log/show
    
    This way the hook doesn't have to keep being tweaked as porcelain
    learns new features like color and pagination.
    
    While at it, replace the "git rev-list | git shortlog" idiom with
    plain "git shortlog" for simplicity.
    
    Except for depending less on the value of settings like '[log]
    abbrevCommit', no change in output intended.
    
    Signed-off-by: Jonathan Nieder <jrnieder at gmail.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 1531150..7208451 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -471,7 +471,7 @@ generate_delete_branch_email()
 	echo "       was  $oldrev"
 	echo ""
 	echo $LOGBEGIN
-	git show -s --pretty=oneline $oldrev
+	git diff-tree -s --always --pretty=oneline $oldrev
 	echo $LOGEND
 }
 
@@ -547,11 +547,11 @@ generate_atag_email()
 		# performed on them
 		if [ -n "$prevtag" ]; then
 			# Show changes since the previous release
-			git rev-list --pretty=short "$prevtag..$newrev" | git shortlog
+			git shortlog "$prevtag..$newrev"
 		else
 			# No previous tag, show all the changes since time
 			# began
-			git rev-list --pretty=short $newrev | git shortlog
+			git shortlog $newrev
 		fi
 		;;
 	*)
@@ -571,7 +571,7 @@ generate_delete_atag_email()
 	echo "       was  $oldrev"
 	echo ""
 	echo $LOGBEGIN
-	git show -s --pretty=oneline $oldrev
+	git diff-tree -s --always --pretty=oneline $oldrev
 	echo $LOGEND
 }
 
@@ -617,7 +617,7 @@ generate_general_email()
 	echo ""
 	if [ "$newrev_type" = "commit" ]; then
 		echo $LOGBEGIN
-		git show --no-color --root -s --pretty=medium $newrev
+		git diff-tree -s --always --pretty=medium $newrev
 		echo $LOGEND
 	else
 		# What can we do here?  The tag marks an object that is not
@@ -636,7 +636,7 @@ generate_delete_general_email()
 	echo "       was  $oldrev"
 	echo ""
 	echo $LOGBEGIN
-	git show -s --pretty=oneline $oldrev
+	git diff-tree -s --always --pretty=oneline $oldrev
 	echo $LOGEND
 }
 

commit 78fe6337bfd33d32227e60a3b693061e89bf8809
Author: Michael Haggerty <mhagger at alum.mit.edu>
Date:   Sun Jul 14 10:09:03 2013 +0200

    post-receive-email: deprecate script in favor of git-multimail
    
    Add a notice to the top of post-receive-email explaining that the
    script is no longer under active development and pointing the user to
    git-multimail.
    
    Signed-off-by: Michael Haggerty <mhagger at alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 0e5b72d..1531150 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -2,10 +2,19 @@
 #
 # Copyright (c) 2007 Andy Parkins
 #
-# An example hook script to mail out commit update information.  This hook
-# sends emails listing new revisions to the repository introduced by the
-# change being reported.  The rule is that (for branch updates) each commit
-# will appear on one email and one email only.
+# An example hook script to mail out commit update information.
+#
+# NOTE: This script is no longer under active development.  There
+# is another script, git-multimail, which is more capable and
+# configurable and is largely backwards-compatible with this script;
+# please see "contrib/hooks/multimail/".  For instructions on how to
+# migrate from post-receive-email to git-multimail, please see
+# "README.migrate-from-post-receive-email" in that directory.
+#
+# This hook sends emails listing new revisions to the repository
+# introduced by the change being reported.  The rule is that (for
+# branch updates) each commit will appear on one email and one email
+# only.
 #
 # This hook is stored in the contrib/hooks directory.  Your distribution
 # will have put this somewhere standard.  You should make this script

commit 23beea685962a807c78d8e4e2bef7b9cf94d8452
Author: Chris Hiestand <chiestand at salk.edu>
Date:   Wed Jan 16 09:29:14 2013 -0800

    Add Auto-Submitted header to post-receive-email
    
    This conforms to RFC3834 and is useful in preventing eg
    vacation auto-responders from replying by default
    
    Signed-off-by: Chris Hiestand <chiestand at salk.edu>
    Reviewed-by: Jonathan Nieder <jrnieder at gmail.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index b2171a0..0e5b72d 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -237,6 +237,7 @@ generate_email_header()
 	X-Git-Reftype: $refname_type
 	X-Git-Oldrev: $oldrev
 	X-Git-Newrev: $newrev
+	Auto-Submitted: auto-generated
 
 	This is an automated email from the git hooks/post-receive script. It was
 	generated because a ref change was pushed to the repository containing

commit b98d98220078b9a596de722ae71fa1989f13eaf4
Author: Richard Fearn <richardfearn at gmail.com>
Date:   Sat Oct 13 23:32:50 2012 +0100

    Fix spelling error in post-receive-email hook
    
    Signed-off-by: Richard Fearn <richardfearn at gmail.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 01af9df..b2171a0 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -403,7 +403,7 @@ generate_update_branch_email()
 			echo "            \\"
 			echo "             O -- O -- O ($oldrev)"
 			echo ""
-			echo "The removed revisions are not necessarilly gone - if another reference"
+			echo "The removed revisions are not necessarily gone - if another reference"
 			echo "still refers to them they will stay in the repository."
 			rewind_only=1
 		else

commit dca582fbca9860b5c9e006cbbaaa798e4a366475
Author: Michael Haggerty <mhagger at alum.mit.edu>
Date:   Mon Feb 27 19:34:10 2012 +0100

    post-receive-email: match up $LOGBEGIN..$LOGEND pairs correctly
    
    Signed-off-by: Michael Haggerty <mhagger at alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index ac2e0ed..01af9df 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -460,7 +460,7 @@ generate_delete_branch_email()
 {
 	echo "       was  $oldrev"
 	echo ""
-	echo $LOGEND
+	echo $LOGBEGIN
 	git show -s --pretty=oneline $oldrev
 	echo $LOGEND
 }
@@ -560,7 +560,7 @@ generate_delete_atag_email()
 {
 	echo "       was  $oldrev"
 	echo ""
-	echo $LOGEND
+	echo $LOGBEGIN
 	git show -s --pretty=oneline $oldrev
 	echo $LOGEND
 }
@@ -625,7 +625,7 @@ generate_delete_general_email()
 {
 	echo "       was  $oldrev"
 	echo ""
-	echo $LOGEND
+	echo $LOGBEGIN
 	git show -s --pretty=oneline $oldrev
 	echo $LOGEND
 }

commit adb644b29d4df15b8a7201572c821734dbe38dda
Author: Michael Haggerty <mhagger at alum.mit.edu>
Date:   Mon Feb 27 19:34:09 2012 +0100

    post-receive-email: remove unused variable
    
    prep_for_email neither is passed a fourth argument nor uses it.
    
    Signed-off-by: Michael Haggerty <mhagger at alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index ba077c1..ac2e0ed 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -85,7 +85,6 @@ prep_for_email()
 	oldrev=$(git rev-parse $1)
 	newrev=$(git rev-parse $2)
 	refname="$3"
-	maxlines=$4
 
 	# --- Interpret
 	# 0000->1234 (create)

commit 7254ecb5a45fdd192506ebbff805c7adda0e00af
Author: Gerrit Pape <pape at smarden.org>
Date:   Mon Sep 26 12:58:35 2011 +0000

    contrib/hooks: adapt comment about Debian install location for contrib hooks
    
    Placing the contrib hooks into /usr/share/doc/ wasn't a good idea in the
    first place.  According to the Debian policy they should be located in
    /usr/share/git-core/, so let's put them there.
    
    Thanks to Bill Allombert for reporting this through
     http://bugs.debian.org/640949
    
    Signed-off-by: Gerrit Pape <pape at smarden.org>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index fa6d41a..ba077c1 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -11,11 +11,11 @@
 # will have put this somewhere standard.  You should make this script
 # executable then link to it in the repository you would like to use it in.
 # For example, on debian the hook is stored in
-# /usr/share/doc/git-core/contrib/hooks/post-receive-email:
+# /usr/share/git-core/contrib/hooks/post-receive-email:
 #
 #  chmod a+x post-receive-email
 #  cd /path/to/your/repository.git
-#  ln -sf /usr/share/doc/git-core/contrib/hooks/post-receive-email hooks/post-receive
+#  ln -sf /usr/share/git-core/contrib/hooks/post-receive-email hooks/post-receive
 #
 # This hook script assumes it is enabled on the central repository of a
 # project, with all users pushing only to it and not between each other.  It

commit 7647b25b07755839137b65192261e5e3340f0dc9
Author: Jon Jensen <jon at endpoint.com>
Date:   Wed Aug 3 21:36:08 2011 -0600

    Add option hooks.diffopts to customize change summary in post-receive-email
    
    This makes it easy to customize the git diff-tree options, for example
    to include -p to include inline diffs.
    
    It defaults to the current options "--stat --summary --find-copies-harder"
    and thus is backward-compatible.
    
    Signed-off-by: Jon Jensen <jon at endpoint.com>
    Improved-by: Junio C Hamano <gitster at pobox.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 21989fc..fa6d41a 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -60,6 +60,11 @@
 #   email body. If not specified, there is no limit.
 #   Lines beyond the limit are suppressed and counted, and a final
 #   line is added indicating the number of suppressed lines.
+# hooks.diffopts
+#   Alternate options for the git diff-tree invocation that shows changes.
+#   Default is "--stat --summary --find-copies-harder". Add -p to those
+#   options to include a unified diff of changes in addition to the usual
+#   summary output.
 #
 # Notes
 # -----
@@ -446,7 +451,7 @@ generate_update_branch_email()
 	# non-fast-forward updates.
 	echo ""
 	echo "Summary of changes:"
-	git diff-tree --stat --summary --find-copies-harder $oldrev..$newrev
+	git diff-tree $diffopts $oldrev..$newrev
 }
 
 #
@@ -723,6 +728,8 @@ envelopesender=$(git config hooks.envelopesender)
 emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')
 custom_showrev=$(git config hooks.showrev)
 maxlines=$(git config hooks.emailmaxlines)
+diffopts=$(git config hooks.diffopts)
+: ${diffopts:="--stat --summary --find-copies-harder"}
 
 # --- Main loop
 # Allow dual mode: run from the command line just like the update hook, or

commit c206232b77e854d80e3aeec218934ca5427cb2d6
Author: Sitaram Chamarty <sitaramc at gmail.com>
Date:   Thu Feb 3 06:30:32 2011 +0530

    post-receive-email: suppress error if description file missing
    
    Signed-off-by: Sitaram Chamarty <sitaramc at gmail.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index f99ea95..21989fc 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -709,7 +709,7 @@ if [ -z "$GIT_DIR" ]; then
 	exit 1
 fi
 
-projectdesc=$(sed -ne '1p' "$GIT_DIR/description")
+projectdesc=$(sed -ne '1p' "$GIT_DIR/description" 2>/dev/null)
 # Check if the description is unchanged from it's default, and shorten it to
 # a more manageable length if it is
 if expr "$projectdesc" : "Unnamed repository.*$" >/dev/null

commit e0accbdfc52e8b107f9b61522499d13acde7824c
Merge: afeaeb1 513c576
Author: Junio C Hamano <gitster at pobox.com>
Date:   Thu Dec 9 10:45:53 2010 -0800

    Merge branch 'maint'
    
    * maint:
      contrib/hooks/post-receive-email: fix return values from prep_for_email


commit 513c5768c2a9518c8d88736c9c8236a438bd439d
Author: Alan Raison <alan at theraisons.me.uk>
Date:   Thu Dec 9 16:03:05 2010 +0000

    contrib/hooks/post-receive-email: fix return values from prep_for_email
    
    The function was returning 0 for failure and 1 for success which was
    breaking the logic in the main loop.  It now also returns in all
    cases, rather than exiting.
    
    Signed-off-by: Alan Raison <alan at theraisons.me.uk>
    Acked-by: Kevin P. Fleming <kpfleming at digium.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 85724bf..f99ea95 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -144,13 +144,13 @@ prep_for_email()
 			short_refname=${refname##refs/remotes/}
 			echo >&2 "*** Push-update of tracking branch, $refname"
 			echo >&2 "***  - no email generated."
-			exit 0
+			return 1
 			;;
 		*)
 			# Anything else (is there anything else?)
 			echo >&2 "*** Unknown type of update to $refname ($rev_type)"
 			echo >&2 "***  - no email generated"
-			return 0
+			return 1
 			;;
 	esac
 
@@ -166,10 +166,10 @@ prep_for_email()
 		esac
 		echo >&2 "*** $config_name is not set so no email will be sent"
 		echo >&2 "*** for $refname update $oldrev->$newrev"
-		return 0
+		return 1
 	fi
 
-	return 1
+	return 0
 }
 
 #

commit afeaeb13fb95b49434f19c2b7758eeee0d7008fa
Merge: 172dd49 0866c46
Author: Junio C Hamano <gitster at pobox.com>
Date:   Wed Nov 24 13:24:49 2010 -0800

    Merge branch 'maint'
    
    * maint:
      imap-send: link against libcrypto for HMAC and others
      git-send-email.perl: Deduplicate "to:" and "cc:" entries with names
      mingw: do not set errno to 0 on success


commit 0866c461831be884455f419386c7d64dd509e405
Merge: 2cd6cde b2f5a56
Author: Junio C Hamano <gitster at pobox.com>
Date:   Wed Nov 24 12:45:39 2010 -0800

    Merge branch 'kf/post-receive-sample-hook' into maint
    
    * kf/post-receive-sample-hook:
      post-receive-email: ensure sent messages are not empty


commit 172dd4929678a95fe0f6eef8a5895f6af70ce72b
Merge: 2cd6cde b2f5a56
Author: Junio C Hamano <gitster at pobox.com>
Date:   Tue Oct 26 21:41:18 2010 -0700

    Merge branch 'kf/post-receive-sample-hook'
    
    * kf/post-receive-sample-hook:
      post-receive-email: ensure sent messages are not empty


commit b2f5a56756ca884340a3c921156f678b5436f77c
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Fri Sep 10 11:09:39 2010 -0500

    post-receive-email: ensure sent messages are not empty
    
    Changes the logic in the script to determine whether an email message
    will be sent before invoking the send_mail() function; otherwise, if
    the logic determines that a message will not be sent, send_mail() will
    cause an empty email to be sent. In addition, ensures that if multiple
    refs are updated and a message cannot be sent for one of them,
    the others are still processed normally.
    
    Signed-off-by: Kevin P. Fleming <kpfleming at digium.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 11e51ec..1a88804 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -71,19 +71,10 @@
 # ---------------------------- Functions
 
 #
-# Top level email generation function.  This decides what type of update
-# this is and calls the appropriate body-generation routine after outputting
-# the common header
+# Function to prepare for email generation. This decides what type
+# of update this is and whether an email should even be generated.
 #
-# Note this function doesn't actually generate any email output, that is
-# taken care of by the functions it calls:
-#  - generate_email_header
-#  - generate_create_XXXX_email
-#  - generate_update_XXXX_email
-#  - generate_delete_XXXX_email
-#  - generate_email_footer
-#
-generate_email()
+prep_for_email()
 {
 	# --- Arguments
 	oldrev=$(git rev-parse $1)
@@ -159,7 +150,7 @@ generate_email()
 			# Anything else (is there anything else?)
 			echo >&2 "*** Unknown type of update to $refname ($rev_type)"
 			echo >&2 "***  - no email generated"
-			exit 1
+			return 0
 			;;
 	esac
 
@@ -175,9 +166,32 @@ generate_email()
 		esac
 		echo >&2 "*** $config_name is not set so no email will be sent"
 		echo >&2 "*** for $refname update $oldrev->$newrev"
-		exit 0
+		return 0
 	fi
 
+	return 1
+}
+
+#
+# Top level email generation function.  This calls the appropriate
+# body-generation routine after outputting the common header.
+#
+# Note this function doesn't actually generate any email output, that is
+# taken care of by the functions it calls:
+#  - generate_email_header
+#  - generate_create_XXXX_email
+#  - generate_update_XXXX_email
+#  - generate_delete_XXXX_email
+#  - generate_email_footer
+#
+# Note also that this function cannot 'exit' from the script; when this
+# function is running (in hook script mode), the send_mail() function
+# is already executing in another process, connected via a pipe, and
+# if this function exits without, whatever has been generated to that
+# point will be sent as an email... even if nothing has been generated.
+#
+generate_email()
+{
 	# Email parameters
 	# The email subject will contain the best description of the ref
 	# that we can build from the parameters
@@ -717,10 +731,11 @@ if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
 	# Output to the terminal in command line mode - if someone wanted to
 	# resend an email; they could redirect the output to sendmail
 	# themselves
-	PAGER= generate_email $2 $3 $1
+	prep_for_email $2 $3 $1 && PAGER= generate_email
 else
 	while read oldrev newrev refname
 	do
-		generate_email $oldrev $newrev $refname $maxlines | send_mail
+		prep_for_email $oldrev $newrev $refname || continue
+		generate_email $maxlines | send_mail
 	done
 fi

commit 2cd6cdef715131b46cdf62a60ffc97174aa85ae8
Merge: 3814641 3b3594a
Author: Junio C Hamano <gitster at pobox.com>
Date:   Wed Aug 18 12:16:50 2010 -0700

    Merge branch 'kf/post-receive-sample-hook'
    
    * kf/post-receive-sample-hook:
      post-receive-email: optional message line count limit


commit 3814641b08ca2aa296380c175f663a1e0b752add
Author: Matthieu Moy <Matthieu.Moy at imag.fr>
Date:   Wed Aug 11 10:14:13 2010 +0200

    post-receive-email: remove spurious commas in email subject
    
    The previous form produced subjects like
    
      [SCM] project.git branch, foo, updated. ...
    
    The new one will produce the lighter
    
      [SCM] project.git branch foo updated. ...
    
    Signed-off-by: Matthieu Moy <Matthieu.Moy at imag.fr>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 30ae63d..09c5241 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -203,7 +203,7 @@ generate_email_header()
 	# Generate header
 	cat <<-EOF
 	To: $recipients
-	Subject: ${emailprefix}$projectdesc $refname_type, $short_refname, ${change_type}d. $describe
+	Subject: ${emailprefix}$projectdesc $refname_type $short_refname ${change_type}d. $describe
 	X-Git-Refname: $refname
 	X-Git-Reftype: $refname_type
 	X-Git-Oldrev: $oldrev

commit 3b3594a9eb8c324d37c06caf047b702b28b2bef9
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Fri Jul 16 14:16:23 2010 -0500

    post-receive-email: optional message line count limit
    
    We have become used to the features of svnmailer when used with Subversion,
    and one of those useful features is that it can limit the maximum length
    (in lines) of a commit email message. This is terribly useful since once the
    goes beyond a reasonable number of lines, nobody is going to read the remainder,
    and if they really want the entire contents of the commits, they can use
    git itself to get them using the revision IDs present in the message already.
    
    Change the post-receive-email script to respond to an 'emailmaxlines' config key
    which, if specified, will limit the number of lines generated (including
    headers); any lines beyond the limit are suppressed, and a final line is added
    indicating the number that were suppressed.
    
    Signed-off-by: Kevin P. Fleming <kpfleming at digium.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 30ae63d..11e51ec 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -55,6 +55,11 @@
 #     "t=%s; printf 'http://.../?id=%%s' \$t; echo;echo; git show -C \$t; echo"
 #   Be careful if "..." contains things that will be expanded by shell "eval"
 #   or printf.
+# hooks.emailmaxlines
+#   The maximum number of lines that should be included in the generated
+#   email body. If not specified, there is no limit.
+#   Lines beyond the limit are suppressed and counted, and a final
+#   line is added indicating the number of suppressed lines.
 #
 # Notes
 # -----
@@ -84,6 +89,7 @@ generate_email()
 	oldrev=$(git rev-parse $1)
 	newrev=$(git rev-parse $2)
 	refname="$3"
+	maxlines=$4
 
 	# --- Interpret
 	# 0000->1234 (create)
@@ -192,7 +198,12 @@ generate_email()
 		fn_name=atag
 		;;
 	esac
-	generate_${change_type}_${fn_name}_email
+
+	if [ -z "$maxlines" ]; then
+		generate_${change_type}_${fn_name}_email
+	else
+		generate_${change_type}_${fn_name}_email | limit_lines $maxlines
+	fi
 
 	generate_email_footer
 }
@@ -642,6 +653,24 @@ show_new_revisions()
 }
 
 
+limit_lines()
+{
+	lines=0
+	skipped=0
+	while IFS="" read -r line; do
+		lines=$((lines + 1))
+		if [ $lines -gt $1 ]; then
+			skipped=$((skipped + 1))
+		else
+			printf "%s\n" "$line"
+		fi
+	done
+	if [ $skipped -ne 0 ]; then
+		echo "... $skipped lines suppressed ..."
+	fi
+}
+
+
 send_mail()
 {
 	if [ -n "$envelopesender" ]; then
@@ -679,6 +708,7 @@ announcerecipients=$(git config hooks.announcelist)
 envelopesender=$(git config hooks.envelopesender)
 emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')
 custom_showrev=$(git config hooks.showrev)
+maxlines=$(git config hooks.emailmaxlines)
 
 # --- Main loop
 # Allow dual mode: run from the command line just like the update hook, or
@@ -691,6 +721,6 @@ if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
 else
 	while read oldrev newrev refname
 	do
-		generate_email $oldrev $newrev $refname | send_mail
+		generate_email $oldrev $newrev $refname $maxlines | send_mail
 	done
 fi

commit 96ff8748ae4dc4e595c5c2f6c043ab7bacd16c13
Author: Jonathan Nieder <jrnieder at gmail.com>
Date:   Wed May 19 14:01:47 2010 -0500

    post-receive-email: document command-line mode
    
    According to the default hooks/post-receive file, the hook is called
    with three arguments on stdin:
    
      <oldrev> <newrev> <refname>
    
    In command-line mode, the arguments come in a different order, because
    the email hook instead calls:
    
      generate_email $2 $3 $1
    
    Add a comment to explain why, based on comments from the mailing list
    and the commit message to v1.5.1~9.  Thanks to Andy for the
    explanation.
    
    Requested-by: martin f. krafft <madduck at debian.org>
    Cc: Andy Parkins <andyparkins at gmail.com>
    Signed-off-by: Jonathan Nieder <jrnieder at gmail.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 58a35c8..30ae63d 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -23,6 +23,13 @@
 # possible for the email to be from someone other than the person doing the
 # push.
 #
+# To help with debugging and use on pre-v1.5.1 git servers, this script will
+# also obey the interface of hooks/update, taking its arguments on the
+# command line.  Unfortunately, hooks/update is called once for each ref.
+# To avoid firing one email per ref, this script just prints its output to
+# the screen when used in this mode.  The output can then be redirected if
+# wanted.
+#
 # Config
 # ------
 # hooks.mailinglist

commit 270a0c3a52afd535ead9c5704b7ce8c4700deaa9
Author: Felipe Contreras <felipe.contreras at gmail.com>
Date:   Sat Oct 24 11:31:32 2009 +0300

    Use 'fast-forward' all over the place
    
    It's a compound word.
    
    Signed-off-by: Felipe Contreras <felipe.contreras at gmail.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 2a66063..58a35c8 100755
--- a/post-receive-email
+++ b/post-receive-email
@@ -315,8 +315,8 @@ generate_update_branch_email()
 	# "remotes/" will be ignored as well.
 
 	# List all of the revisions that were removed by this update, in a
-	# fast forward update, this list will be empty, because rev-list O
-	# ^N is empty.  For a non fast forward, O ^N is the list of removed
+	# fast-forward update, this list will be empty, because rev-list O
+	# ^N is empty.  For a non-fast-forward, O ^N is the list of removed
 	# revisions
 	fast_forward=""
 	rev=""
@@ -411,7 +411,7 @@ generate_update_branch_email()
 	# revision because the base is effectively a random revision at this
 	# point - the user will be interested in what this revision changed
 	# - including the undoing of previous revisions in the case of
-	# non-fast forward updates.
+	# non-fast-forward updates.
 	echo ""
 	echo "Summary of changes:"
 	git diff-tree --stat --summary --find-copies-harder $oldrev..$newrev

commit 08c61ac1caa15a79abae9f4eb6e1a5a179bb14af
Author: Jim Meyering <jim at meyering.net>
Date:   Sat May 23 14:26:44 2009 +0200

    post-receive-email: hooks.showrev: show how to include both web link and patch
    
    Add a comment showing how to include a web link (i.e. gitweb/cgit)
    and a patch in the email that is sent for each pushed commit.
    
    The quoting was tricky enough that it's worth documenting.  To add
    two blank lines (i.e. put \n\n in the printf), you would need to
    say \\\\n\\\\n, and in the end, the pair of "echo" statements seemed
    better.  This is used in glibc.git repository:
    
      http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=summary
    
    push-triggered messages have been sent to this list since May 21:
    
      http://sourceware.org/ml/glibc-cvs/2009-q2/
    
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
old mode 100644
new mode 100755
index 60cbab6..2a66063
--- a/post-receive-email
+++ b/post-receive-email
@@ -44,6 +44,10 @@
 #   --pretty %s", displaying the commit id, author, date and log
 #   message.  To list full patches separated by a blank line, you
 #   could set this to "git show -C %s; echo".
+#   To list a gitweb/cgit URL *and* a full patch for each change set, use this:
+#     "t=%s; printf 'http://.../?id=%%s' \$t; echo;echo; git show -C \$t; echo"
+#   Be careful if "..." contains things that will be expanded by shell "eval"
+#   or printf.
 #
 # Notes
 # -----

commit d2735a5bd1326cebafcc6f07948adb2b47f9037a
Author: Pat Notz <pknotz at sandia.gov>
Date:   Tue Feb 10 09:43:30 2009 -0700

    Fix contrib/hooks/post-receive-email for new duplicate branch
    
    In the show_new_revisions function, the original code:
    
      git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
    
    isn't quite right since one can create a new branch and push it
    without any new commits.  In that case, two refs will have the same
    sha1 but both would get filtered by the 'grep'.  In the end, we'll
    show ALL the history which is not what we want.  Instead, we should
    list the branches by name and remove the branch being updated and THEN
    pass that list through rev-parse.
    
    Revised as suggested by Jakub Narebski and Junio C Hamano to use
    git-for-each-ref instead of git-branch.  (Thanks!)
    
    Signed-off-by: Pat Notz <pknotz at sandia.gov>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 28a3c0e..60cbab6 100644
--- a/post-receive-email
+++ b/post-receive-email
@@ -615,7 +615,9 @@ show_new_revisions()
 		revspec=$oldrev..$newrev
 	fi
 
-	git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
+	other_branches=$(git for-each-ref --format='%(refname)' refs/heads/ |
+	    grep -F -v $refname)
+	git rev-parse --not $other_branches |
 	if [ -z "$custom_showrev" ]
 	then
 		git rev-list --pretty --stdin $revspec

commit 8d7131c4bd9d832f8505df9e75a9131f17a08937
Author: Pete Harlan <pgit at pcharlan.com>
Date:   Mon Nov 3 23:19:54 2008 -0800

    contrib/hooks/post-receive-email: Make revision display configurable
    
    Add configuration option hooks.showrev, letting the user override how
    revisions will be shown in the commit email.
    
    Signed-off-by: Pete Harlan <pgit at pcharlan.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 2cd373d..28a3c0e 100644
--- a/post-receive-email
+++ b/post-receive-email
@@ -38,6 +38,12 @@
 # hooks.emailprefix
 #   All emails have their subjects prefixed with this prefix, or "[SCM]"
 #   if emailprefix is unset, to aid filtering
+# hooks.showrev
+#   The shell command used to format each revision in the email, with
+#   "%s" replaced with the commit id.  Defaults to "git rev-list -1
+#   --pretty %s", displaying the commit id, author, date and log
+#   message.  To list full patches separated by a blank line, you
+#   could set this to "git show -C %s; echo".
 #
 # Notes
 # -----
@@ -610,7 +616,16 @@ show_new_revisions()
 	fi
 
 	git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
-	git rev-list --pretty --stdin $revspec
+	if [ -z "$custom_showrev" ]
+	then
+		git rev-list --pretty --stdin $revspec
+	else
+		git rev-list --stdin $revspec |
+		while read onerev
+		do
+			eval $(printf "$custom_showrev" $onerev)
+		done
+	fi
 }
 
 
@@ -650,6 +665,7 @@ recipients=$(git config hooks.mailinglist)
 announcerecipients=$(git config hooks.announcelist)
 envelopesender=$(git config hooks.envelopesender)
 emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')
+custom_showrev=$(git config hooks.showrev)
 
 # --- Main loop
 # Allow dual mode: run from the command line just like the update hook, or

commit 30f2269ba7c1d8a079ed6dceefd361ecd56a6693
Author: Pete Harlan <pgit at pcharlan.com>
Date:   Mon Nov 3 23:19:53 2008 -0800

    contrib/hooks/post-receive-email: Put rev display in separate function
    
    The display of a revision in an email-appropriate format is done in
    two places with similar code.  In preparation for making that display
    more complex, move it into a separate function that handles both cases.
    
    Signed-off-by: Pete Harlan <pgit at pcharlan.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 4136895..2cd373d 100644
--- a/post-receive-email
+++ b/post-receive-email
@@ -224,13 +224,7 @@ generate_create_branch_email()
 	echo ""
 
 	echo $LOGBEGIN
-	# This shows all log entries that are not already covered by
-	# another ref - i.e. commits that are now accessible from this
-	# ref that were previously not accessible
-	# (see generate_update_branch_email for the explanation of this
-	# command)
-	git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
-	git rev-list --pretty --stdin $newrev
+	show_new_revisions
 	echo $LOGEND
 }
 
@@ -390,8 +384,7 @@ generate_update_branch_email()
 
 		echo ""
 		echo $LOGBEGIN
-		git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
-		git rev-list --pretty --stdin $oldrev..$newrev
+		show_new_revisions
 
 		# XXX: Need a way of detecting whether git rev-list actually
 		# outputted anything, so that we can issue a "no new
@@ -591,6 +584,36 @@ generate_delete_general_email()
 	echo $LOGEND
 }
 
+
+# --------------- Miscellaneous utilities
+
+#
+# Show new revisions as the user would like to see them in the email.
+#
+show_new_revisions()
+{
+	# This shows all log entries that are not already covered by
+	# another ref - i.e. commits that are now accessible from this
+	# ref that were previously not accessible
+	# (see generate_update_branch_email for the explanation of this
+	# command)
+
+	# Revision range passed to rev-list differs for new vs. updated
+	# branches.
+	if [ "$change_type" = create ]
+	then
+		# Show all revisions exclusive to this (new) branch.
+		revspec=$newrev
+	else
+		# Branch update; show revisions not part of $oldrev.
+		revspec=$oldrev..$newrev
+	fi
+
+	git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
+	git rev-list --pretty --stdin $revspec
+}
+
+
 send_mail()
 {
 	if [ -n "$envelopesender" ]; then

commit 034bfa94f1e5b66077a3450f7fe38c852d8b5a9c
Merge: 8591396 3e1527d
Author: Junio C Hamano <gitster at pobox.com>
Date:   Tue Apr 22 00:10:20 2008 -0700

    Merge branch 'maint'
    
    * maint:
      post-receive-email: fix accidental removal of a trailing space in signature line
      Escape project names before creating pathinfo URLs
      Escape project name in regexp
      bash: Add completion for git diff --base --ours --theirs
      diff-options.txt: document the new "--dirstat" option


commit 3e1527da3000e9ba091808bab5d04bd7d948cdcf
Author: Andy Parkins <andyparkins at gmail.com>
Date:   Mon Apr 21 14:44:44 2008 +0100

    post-receive-email: fix accidental removal of a trailing space in signature line
    
    post-receive-email adds a signature to the end of emails in
    generate_email_footer().  The signature was separated from the main email
    body using the standard string "-- ". (see RFC 3676)
    
    a6080a0 (War on whitespace, 2007-06-07) removed the trailing whitespace
    from "-- ", leaving it as "--", which is not a correct signature
    separator.
    
    This patch restores the missing space, but does it in a way that will
    not set off the trailing whitespace alarms.
    
    Signed-off-by: Andy Parkins <andyparkins at gmail.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 62a740c..4136895 100644
--- a/post-receive-email
+++ b/post-receive-email
@@ -202,11 +202,12 @@ generate_email_header()
 
 generate_email_footer()
 {
+	SPACE=" "
 	cat <<-EOF
 
 
 	hooks/post-receive
-	--
+	--${SPACE}
 	$projectdesc
 	EOF
 }

commit 8591396babfad4903fa6b72ab64b1def3eb8567a
Author: Denis Cheng <crquan at gmail.com>
Date:   Sun Mar 2 17:05:52 2008 +0800

    specify explicit "--pretty=medium" with `git log/show/whatchanged`
    
    The following patch will introduce a new configuration variable,
    "format.pretty", from then on the pretty format without specifying
    "--pretty" might not be the default "--pretty=medium", it depends on
    the user's config. So all kinds of Shell/Perl/Emacs scripts that needs
    the default medium pretty format must specify it explicitly.
    
    Signed-off-by: Denis Cheng <crquan at gmail.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 77c88eb..62a740c 100644
--- a/post-receive-email
+++ b/post-receive-email
@@ -567,7 +567,7 @@ generate_general_email()
 	echo ""
 	if [ "$newrev_type" = "commit" ]; then
 		echo $LOGBEGIN
-		git show --no-color --root -s $newrev
+		git show --no-color --root -s --pretty=medium $newrev
 		echo $LOGEND
 	else
 		# What can we do here?  The tag marks an object that is not

commit 4e2873fdaa4fe4dd500921c062870e7282bccb33
Author: Dan McGee <dpmcgee at gmail.com>
Date:   Sun Jan 13 22:51:01 2008 -0600

    Remove usage of git- (dash) commands from email hook
    
    Switch all git command calls to use the git (space) command format, and
    remove the use of git-repo-config in place of git config.
    
    Signed-off-by: Dan McGee <dpmcgee at gmail.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 7511ea0..77c88eb 100644
--- a/post-receive-email
+++ b/post-receive-email
@@ -248,24 +248,24 @@ generate_update_branch_email()
 	# In this case we want to issue an email containing only revisions
 	# 3, 4, and N.  Given (almost) by
 	#
-	#  git-rev-list N ^O --not --all
+	#  git rev-list N ^O --not --all
 	#
 	# The reason for the "almost", is that the "--not --all" will take
 	# precedence over the "N", and effectively will translate to
 	#
-	#  git-rev-list N ^O ^X ^N
+	#  git rev-list N ^O ^X ^N
 	#
-	# So, we need to build up the list more carefully.  git-rev-parse
-	# will generate a list of revs that may be fed into git-rev-list.
+	# So, we need to build up the list more carefully.  git rev-parse
+	# will generate a list of revs that may be fed into git rev-list.
 	# We can get it to make the "--not --all" part and then filter out
 	# the "^N" with:
 	#
-	#  git-rev-parse --not --all | grep -v N
+	#  git rev-parse --not --all | grep -v N
 	#
-	# Then, using the --stdin switch to git-rev-list we have effectively
+	# Then, using the --stdin switch to git rev-list we have effectively
 	# manufactured
 	#
-	#  git-rev-list N ^O ^X
+	#  git rev-list N ^O ^X
 	#
 	# This leaves a problem when someone else updates the repository
 	# while this script is running.  Their new value of the ref we're
@@ -274,10 +274,10 @@ generate_update_branch_email()
 	# all of our commits.  What we really want is to exclude the current
 	# value of $refname from the --not list, rather than N itself.  So:
 	#
-	#  git-rev-parse --not --all | grep -v $(git-rev-parse $refname)
+	#  git rev-parse --not --all | grep -v $(git rev-parse $refname)
 	#
 	# Get's us to something pretty safe (apart from the small time
-	# between refname being read, and git-rev-parse running - for that,
+	# between refname being read, and git rev-parse running - for that,
 	# I give up)
 	#
 	#
@@ -295,7 +295,7 @@ generate_update_branch_email()
 	# As above, we need to take into account the presence of X; if
 	# another branch is already in the repository and points at some of
 	# the revisions that we are about to output - we don't want them.
-	# The solution is as before: git-rev-parse output filtered.
+	# The solution is as before: git rev-parse output filtered.
 	#
 	# Finally, tags: 1 --- 2 --- O --- T --- 3 --- 4 --- N
 	#
@@ -305,7 +305,7 @@ generate_update_branch_email()
 	# for a branch update.  Therefore we still want to output revisions
 	# that have been output on a tag email.
 	#
-	# Luckily, git-rev-parse includes just the tool.  Instead of using
+	# Luckily, git rev-parse includes just the tool.  Instead of using
 	# "--all" we use "--branches"; this has the added benefit that
 	# "remotes/" will be ignored as well.
 
@@ -454,7 +454,7 @@ generate_update_atag_email()
 #
 generate_atag_email()
 {
-	# Use git-for-each-ref to pull out the individual fields from the
+	# Use git for-each-ref to pull out the individual fields from the
 	# tag
 	eval $(git for-each-ref --shell --format='
 	tagobject=%(*objectname)
@@ -572,7 +572,7 @@ generate_general_email()
 	else
 		# What can we do here?  The tag marks an object that is not
 		# a commit, so there is no log for us to display.  It's
-		# probably not wise to output git-cat-file as it could be a
+		# probably not wise to output git cat-file as it could be a
 		# binary blob.  We'll just say how big it is
 		echo "$newrev is a $newrev_type, and is $(git cat-file -s $newrev) bytes long."
 	fi
@@ -622,10 +622,10 @@ then
 	projectdesc="UNNAMED PROJECT"
 fi
 
-recipients=$(git repo-config hooks.mailinglist)
-announcerecipients=$(git repo-config hooks.announcelist)
-envelopesender=$(git-repo-config hooks.envelopesender)
-emailprefix=$(git-repo-config hooks.emailprefix || echo '[SCM] ')
+recipients=$(git config hooks.mailinglist)
+announcerecipients=$(git config hooks.announcelist)
+envelopesender=$(git config hooks.envelopesender)
+emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')
 
 # --- Main loop
 # Allow dual mode: run from the command line just like the update hook, or

commit 8de832eaa4536bb256f0b8b2650656cd62df9498
Author: Gerrit Pape <pape at smarden.org>
Date:   Thu Nov 8 12:11:57 2007 +0000

    contrib/hooks/post-receive-email: remove cruft, $committer is not used
    
    Signed-off-by: Gerrit Pape <pape at smarden.org>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 3904c18..7511ea0 100644
--- a/post-receive-email
+++ b/post-receive-email
@@ -156,10 +156,6 @@ generate_email()
 	fi
 
 	# Email parameters
-	# The committer will be obtained from the latest existing rev; so
-	# for a deletion it will be the oldrev, for the others, then newrev
-	committer=$(git show --pretty=full -s $rev | sed -ne "s/^Commit: //p" |
-		sed -ne 's/\(.*\) </"\1" </p')
 	# The email subject will contain the best description of the ref
 	# that we can build from the parameters
 	describe=$(git describe $rev 2>/dev/null)

commit c7250f98535a85712cb98475a0416e2e7fd7f4ba
Author: Gerrit Pape <pape at smarden.org>
Date:   Tue Nov 6 13:49:30 2007 +0000

    contrib/hooks/post-receive-email: make subject prefix configurable
    
    Email subjects are prefixed with "[SCM] " by default, make this optionally
    configurable through the hooks.emailprefix config option.
    
    Suggested by martin f krafft through
     http://bugs.debian.org/428418
    
    Signed-off-by: Gerrit Pape <pape at smarden.org>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 9b9a977..3904c18 100644
--- a/post-receive-email
+++ b/post-receive-email
@@ -35,10 +35,12 @@
 # hooks.envelopesender
 #   If set then the -f option is passed to sendmail to allow the envelope
 #   sender address to be set
+# hooks.emailprefix
+#   All emails have their subjects prefixed with this prefix, or "[SCM]"
+#   if emailprefix is unset, to aid filtering
 #
 # Notes
 # -----
-# All emails have their subjects prefixed with "[SCM]" to aid filtering.
 # All emails include the headers "X-Git-Refname", "X-Git-Oldrev",
 # "X-Git-Newrev", and "X-Git-Reftype" to enable fine tuned filtering and
 # give information for debugging.
@@ -188,7 +190,7 @@ generate_email_header()
 	# Generate header
 	cat <<-EOF
 	To: $recipients
-	Subject: ${EMAILPREFIX}$projectdesc $refname_type, $short_refname, ${change_type}d. $describe
+	Subject: ${emailprefix}$projectdesc $refname_type, $short_refname, ${change_type}d. $describe
 	X-Git-Refname: $refname
 	X-Git-Reftype: $refname_type
 	X-Git-Oldrev: $oldrev
@@ -604,7 +606,6 @@ send_mail()
 # ---------------------------- main()
 
 # --- Constants
-EMAILPREFIX="[SCM] "
 LOGBEGIN="- Log -----------------------------------------------------------------"
 LOGEND="-----------------------------------------------------------------------"
 
@@ -628,6 +629,7 @@ fi
 recipients=$(git repo-config hooks.mailinglist)
 announcerecipients=$(git repo-config hooks.announcelist)
 envelopesender=$(git-repo-config hooks.envelopesender)
+emailprefix=$(git-repo-config hooks.emailprefix || echo '[SCM] ')
 
 # --- Main loop
 # Allow dual mode: run from the command line just like the update hook, or

commit 6ea66972be087069d02483174ddc298768d2bba1
Author: Gerrit Pape <pape at smarden.org>
Date:   Tue Nov 6 13:48:34 2007 +0000

    contrib/hooks/post-receive-email: reformat to wrap comments at 76 chars
    
    Signed-off-by: Gerrit Pape <pape at smarden.org>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 379cedc..9b9a977 100644
--- a/post-receive-email
+++ b/post-receive-email
@@ -2,24 +2,26 @@
 #
 # Copyright (c) 2007 Andy Parkins
 #
-# An example hook script to mail out commit update information.  This hook sends emails
-# listing new revisions to the repository introduced by the change being reported.  The
-# rule is that (for branch updates) each commit will appear on one email and one email
-# only.
+# An example hook script to mail out commit update information.  This hook
+# sends emails listing new revisions to the repository introduced by the
+# change being reported.  The rule is that (for branch updates) each commit
+# will appear on one email and one email only.
 #
-# This hook is stored in the contrib/hooks directory.  Your distribution will have put
-# this somewhere standard.  You should make this script executable then link to it in
-# the repository you would like to use it in.  For example, on debian the hook is stored
-# in /usr/share/doc/git-core/contrib/hooks/post-receive-email:
+# This hook is stored in the contrib/hooks directory.  Your distribution
+# will have put this somewhere standard.  You should make this script
+# executable then link to it in the repository you would like to use it in.
+# For example, on debian the hook is stored in
+# /usr/share/doc/git-core/contrib/hooks/post-receive-email:
 #
 #  chmod a+x post-receive-email
 #  cd /path/to/your/repository.git
 #  ln -sf /usr/share/doc/git-core/contrib/hooks/post-receive-email hooks/post-receive
 #
-# This hook script assumes it is enabled on the central repository of a project, with
-# all users pushing only to it and not between each other.  It will still work if you
-# don't operate in that style, but it would become possible for the email to be from
-# someone other than the person doing the push.
+# This hook script assumes it is enabled on the central repository of a
+# project, with all users pushing only to it and not between each other.  It
+# will still work if you don't operate in that style, but it would become
+# possible for the email to be from someone other than the person doing the
+# push.
 #
 # Config
 # ------
@@ -28,11 +30,11 @@
 #   emails for every ref update.
 # hooks.announcelist
 #   This is the list that all pushes of annotated tags will go to.  Leave it
-#   blank to default to the mailinglist field.  The announce emails lists the
-#   short log summary of the changes since the last annotated tag.
+#   blank to default to the mailinglist field.  The announce emails lists
+#   the short log summary of the changes since the last annotated tag.
 # hooks.envelopesender
-#   If set then the -f option is passed to sendmail to allow the envelope sender
-#   address to be set
+#   If set then the -f option is passed to sendmail to allow the envelope
+#   sender address to be set
 #
 # Notes
 # -----
@@ -49,8 +51,8 @@
 # this is and calls the appropriate body-generation routine after outputting
 # the common header
 #
-# Note this function doesn't actually generate any email output, that is taken
-# care of by the functions it calls:
+# Note this function doesn't actually generate any email output, that is
+# taken care of by the functions it calls:
 #  - generate_email_header
 #  - generate_create_XXXX_email
 #  - generate_update_XXXX_email
@@ -225,8 +227,9 @@ generate_create_branch_email()
 	echo $LOGBEGIN
 	# This shows all log entries that are not already covered by
 	# another ref - i.e. commits that are now accessible from this
-	# ref that were previously not accessible (see generate_update_branch_email
-	# for the explanation of this command)
+	# ref that were previously not accessible
+	# (see generate_update_branch_email for the explanation of this
+	# command)
 	git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
 	git rev-list --pretty --stdin $newrev
 	echo $LOGEND
@@ -254,9 +257,10 @@ generate_update_branch_email()
 	#
 	#  git-rev-list N ^O ^X ^N
 	#
-	# So, we need to build up the list more carefully.  git-rev-parse will
-	# generate a list of revs that may be fed into git-rev-list.  We can get
-	# it to make the "--not --all" part and then filter out the "^N" with:
+	# So, we need to build up the list more carefully.  git-rev-parse
+	# will generate a list of revs that may be fed into git-rev-list.
+	# We can get it to make the "--not --all" part and then filter out
+	# the "^N" with:
 	#
 	#  git-rev-parse --not --all | grep -v N
 	#
@@ -266,16 +270,17 @@ generate_update_branch_email()
 	#  git-rev-list N ^O ^X
 	#
 	# This leaves a problem when someone else updates the repository
-	# while this script is running.  Their new value of the ref we're working
-	# on would be included in the "--not --all" output; and as our $newrev
-	# would be an ancestor of that commit, it would exclude all of our
-	# commits.  What we really want is to exclude the current value of
-	# $refname from the --not list, rather than N itself.  So:
+	# while this script is running.  Their new value of the ref we're
+	# working on would be included in the "--not --all" output; and as
+	# our $newrev would be an ancestor of that commit, it would exclude
+	# all of our commits.  What we really want is to exclude the current
+	# value of $refname from the --not list, rather than N itself.  So:
 	#
 	#  git-rev-parse --not --all | grep -v $(git-rev-parse $refname)
 	#
-	# Get's us to something pretty safe (apart from the small time between
-	# refname being read, and git-rev-parse running - for that, I give up)
+	# Get's us to something pretty safe (apart from the small time
+	# between refname being read, and git-rev-parse running - for that,
+	# I give up)
 	#
 	#
 	# Next problem, consider this:
@@ -283,18 +288,18 @@ generate_update_branch_email()
 	#          \
 	#           * --- X --- * --- N ($newrev)
 	#
-	# That is to say, there is no guarantee that oldrev is a strict subset of
-	# newrev (it would have required a --force, but that's allowed).  So, we
-	# can't simply say rev-list $oldrev..$newrev.  Instead we find the common
-	# base of the two revs and list from there.
+	# That is to say, there is no guarantee that oldrev is a strict
+	# subset of newrev (it would have required a --force, but that's
+	# allowed).  So, we can't simply say rev-list $oldrev..$newrev.
+	# Instead we find the common base of the two revs and list from
+	# there.
 	#
-	# As above, we need to take into account the presence of X; if another
-	# branch is already in the repository and points at some of the revisions
-	# that we are about to output - we don't want them.  The solution is as
-	# before: git-rev-parse output filtered.
+	# As above, we need to take into account the presence of X; if
+	# another branch is already in the repository and points at some of
+	# the revisions that we are about to output - we don't want them.
+	# The solution is as before: git-rev-parse output filtered.
 	#
-	# Finally, tags:
-	#   1 --- 2 --- O --- T --- 3 --- 4 --- N
+	# Finally, tags: 1 --- 2 --- O --- T --- 3 --- 4 --- N
 	#
 	# Tags pushed into the repository generate nice shortlog emails that
 	# summarise the commits between them and the previous tag.  However,
@@ -302,13 +307,14 @@ generate_update_branch_email()
 	# for a branch update.  Therefore we still want to output revisions
 	# that have been output on a tag email.
 	#
-	# Luckily, git-rev-parse includes just the tool.  Instead of using "--all"
-	# we use "--branches"; this has the added benefit that "remotes/" will
-	# be ignored as well.
-
-	# List all of the revisions that were removed by this update, in a fast forward
-	# update, this list will be empty, because rev-list O ^N is empty.  For a non
-	# fast forward, O ^N is the list of removed revisions
+	# Luckily, git-rev-parse includes just the tool.  Instead of using
+	# "--all" we use "--branches"; this has the added benefit that
+	# "remotes/" will be ignored as well.
+
+	# List all of the revisions that were removed by this update, in a
+	# fast forward update, this list will be empty, because rev-list O
+	# ^N is empty.  For a non fast forward, O ^N is the list of removed
+	# revisions
 	fast_forward=""
 	rev=""
 	for rev in $(git rev-list $newrev..$oldrev)
@@ -321,10 +327,10 @@ generate_update_branch_email()
 	fi
 
 	# List all the revisions from baserev to newrev in a kind of
-	# "table-of-contents"; note this list can include revisions that have
-	# already had notification emails and is present to show the full detail
-	# of the change from rolling back the old revision to the base revision and
-	# then forward to the new revision
+	# "table-of-contents"; note this list can include revisions that
+	# have already had notification emails and is present to show the
+	# full detail of the change from rolling back the old revision to
+	# the base revision and then forward to the new revision
 	for rev in $(git rev-list $oldrev..$newrev)
 	do
 		revtype=$(git cat-file -t "$rev")
@@ -334,19 +340,20 @@ generate_update_branch_email()
 	if [ "$fast_forward" ]; then
 		echo "      from  $oldrev ($oldrev_type)"
 	else
-		#  1. Existing revisions were removed.  In this case newrev is a
-		#     subset of oldrev - this is the reverse of a fast-forward,
-		#     a rewind
-		#  2. New revisions were added on top of an old revision, this is
-		#     a rewind and addition.
+		#  1. Existing revisions were removed.  In this case newrev
+		#     is a subset of oldrev - this is the reverse of a
+		#     fast-forward, a rewind
+		#  2. New revisions were added on top of an old revision,
+		#     this is a rewind and addition.
 
-		# (1) certainly happened, (2) possibly.  When (2) hasn't happened,
-		# we set a flag to indicate that no log printout is required.
+		# (1) certainly happened, (2) possibly.  When (2) hasn't
+		# happened, we set a flag to indicate that no log printout
+		# is required.
 
 		echo ""
 
-		# Find the common ancestor of the old and new revisions and compare
-		# it with newrev
+		# Find the common ancestor of the old and new revisions and
+		# compare it with newrev
 		baserev=$(git merge-base $oldrev $newrev)
 		rewind_only=""
 		if [ "$baserev" = "$newrev" ]; then
@@ -387,21 +394,22 @@ generate_update_branch_email()
 		git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
 		git rev-list --pretty --stdin $oldrev..$newrev
 
-		# XXX: Need a way of detecting whether git rev-list actually outputted
-		# anything, so that we can issue a "no new revisions added by this
-		# update" message
+		# XXX: Need a way of detecting whether git rev-list actually
+		# outputted anything, so that we can issue a "no new
+		# revisions added by this update" message
 
 		echo $LOGEND
 	else
 		echo "No new revisions were added by this update."
 	fi
 
-	# The diffstat is shown from the old revision to the new revision.  This
-	# is to show the truth of what happened in this change.  There's no point
-	# showing the stat from the base to the new revision because the base
-	# is effectively a random revision at this point - the user will be
-	# interested in what this revision changed - including the undoing of
-	# previous revisions in the case of non-fast forward updates.
+	# The diffstat is shown from the old revision to the new revision.
+	# This is to show the truth of what happened in this change.
+	# There's no point showing the stat from the base to the new
+	# revision because the base is effectively a random revision at this
+	# point - the user will be interested in what this revision changed
+	# - including the undoing of previous revisions in the case of
+	# non-fast forward updates.
 	echo ""
 	echo "Summary of changes:"
 	git diff-tree --stat --summary --find-copies-harder $oldrev..$newrev
@@ -448,7 +456,8 @@ generate_update_atag_email()
 #
 generate_atag_email()
 {
-	# Use git-for-each-ref to pull out the individual fields from the tag
+	# Use git-for-each-ref to pull out the individual fields from the
+	# tag
 	eval $(git for-each-ref --shell --format='
 	tagobject=%(*objectname)
 	tagtype=%(*objecttype)
@@ -459,8 +468,10 @@ generate_atag_email()
 	echo "   tagging  $tagobject ($tagtype)"
 	case "$tagtype" in
 	commit)
+
 		# If the tagged object is a commit, then we assume this is a
-		# release, and so we calculate which tag this tag is replacing
+		# release, and so we calculate which tag this tag is
+		# replacing
 		prevtag=$(git describe --abbrev=0 $newrev^ 2>/dev/null)
 
 		if [ -n "$prevtag" ]; then
@@ -477,25 +488,27 @@ generate_atag_email()
 	echo ""
 	echo $LOGBEGIN
 
-	# Show the content of the tag message; this might contain a change log
-	# or release notes so is worth displaying.
+	# Show the content of the tag message; this might contain a change
+	# log or release notes so is worth displaying.
 	git cat-file tag $newrev | sed -e '1,/^$/d'
 
 	echo ""
 	case "$tagtype" in
 	commit)
-		# Only commit tags make sense to have rev-list operations performed
-		# on them
+		# Only commit tags make sense to have rev-list operations
+		# performed on them
 		if [ -n "$prevtag" ]; then
 			# Show changes since the previous release
 			git rev-list --pretty=short "$prevtag..$newrev" | git shortlog
 		else
-			# No previous tag, show all the changes since time began
+			# No previous tag, show all the changes since time
+			# began
 			git rev-list --pretty=short $newrev | git shortlog
 		fi
 		;;
 	*)
-		# XXX: Is there anything useful we can do for non-commit objects?
+		# XXX: Is there anything useful we can do for non-commit
+		# objects?
 		;;
 	esac
 
@@ -544,13 +557,14 @@ generate_update_general_email()
 #
 generate_general_email()
 {
-	# Unannotated tags are more about marking a point than releasing a version;
-	# therefore we don't do the shortlog summary that we do for annotated tags
-	# above - we simply show that the point has been marked, and print the log
-	# message for the marked point for reference purposes
+	# Unannotated tags are more about marking a point than releasing a
+	# version; therefore we don't do the shortlog summary that we do for
+	# annotated tags above - we simply show that the point has been
+	# marked, and print the log message for the marked point for
+	# reference purposes
 	#
-	# Note this section also catches any other reference type (although there
-	# aren't any) and deals with them in the same way.
+	# Note this section also catches any other reference type (although
+	# there aren't any) and deals with them in the same way.
 
 	echo ""
 	if [ "$newrev_type" = "commit" ]; then
@@ -558,10 +572,10 @@ generate_general_email()
 		git show --no-color --root -s $newrev
 		echo $LOGEND
 	else
-		# What can we do here?  The tag marks an object that is not a commit,
-		# so there is no log for us to display.  It's probably not wise to
-		# output git-cat-file as it could be a binary blob.  We'll just say how
-		# big it is
+		# What can we do here?  The tag marks an object that is not
+		# a commit, so there is no log for us to display.  It's
+		# probably not wise to output git-cat-file as it could be a
+		# binary blob.  We'll just say how big it is
 		echo "$newrev is a $newrev_type, and is $(git cat-file -s $newrev) bytes long."
 	fi
 }
@@ -604,8 +618,8 @@ if [ -z "$GIT_DIR" ]; then
 fi
 
 projectdesc=$(sed -ne '1p' "$GIT_DIR/description")
-# Check if the description is unchanged from it's default, and shorten it to a
-# more manageable length if it is
+# Check if the description is unchanged from it's default, and shorten it to
+# a more manageable length if it is
 if expr "$projectdesc" : "Unnamed repository.*$" >/dev/null
 then
 	projectdesc="UNNAMED PROJECT"
@@ -616,11 +630,12 @@ announcerecipients=$(git repo-config hooks.announcelist)
 envelopesender=$(git-repo-config hooks.envelopesender)
 
 # --- Main loop
-# Allow dual mode: run from the command line just like the update hook, or if
-# no arguments are given then run as a hook script
+# Allow dual mode: run from the command line just like the update hook, or
+# if no arguments are given then run as a hook script
 if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
 	# Output to the terminal in command line mode - if someone wanted to
-	# resend an email; they could redirect the output to sendmail themselves
+	# resend an email; they could redirect the output to sendmail
+	# themselves
 	PAGER= generate_email $2 $3 $1
 else
 	while read oldrev newrev refname

commit a35442bafc0d09c555af36eefa80f1e077ddcd89
Author: Gerrit Pape <pape at smarden.org>
Date:   Tue Nov 6 13:48:07 2007 +0000

    contrib/hooks/post-receive-email: fix typo
    
    Signed-off-by: Gerrit Pape <pape at smarden.org>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 2aa9bb5..379cedc 100644
--- a/post-receive-email
+++ b/post-receive-email
@@ -30,7 +30,7 @@
 #   This is the list that all pushes of annotated tags will go to.  Leave it
 #   blank to default to the mailinglist field.  The announce emails lists the
 #   short log summary of the changes since the last annotated tag.
-# hook.envelopesender
+# hooks.envelopesender
 #   If set then the -f option is passed to sendmail to allow the envelope sender
 #   address to be set
 #

commit 7fc31c6fa5143dd2a1da0023e75b4a829817a981
Merge: 5e62103 0dc46f3
Author: Shawn O. Pearce <spearce at spearce.org>
Date:   Thu Oct 18 03:11:17 2007 -0400

    Merge branch 'maint'
    
    * maint:
      Yet more 1.5.3.5 fixes mentioned in release notes
      cvsserver: Use exit 1 instead of die when req_Root fails.
      git-blame shouldn't crash if run in an unmerged tree
      git-config: print error message if the config file cannot be read
      fixing output of non-fast-forward output of post-receive-email


commit 0dc46f303fe1ff95c3bafb234ece2816dcffdf90
Author: Robert Schiele <rschiele at gmail.com>
Date:   Thu Oct 18 00:27:51 2007 +0200

    fixing output of non-fast-forward output of post-receive-email
    
    post-receive-email has one place where the variable fast_forward is not
    spelled correctly.  At the same place the logic was reversed.  The
    combination of both bugs made the script work correctly for fast-forward
    commits but not for non-fast-forward ones.  This change fixes this to
    be correct in both cases.
    
    Signed-off-by: Robert Schiele <rschiele at gmail.com>
    Signed-off-by: Shawn O. Pearce <spearce at spearce.org>

diff --git a/post-receive-email b/post-receive-email
index cbbd02f..28a06c7 100644
--- a/post-receive-email
+++ b/post-receive-email
@@ -323,7 +323,7 @@ generate_update_branch_email()
 		echo "       via  $rev ($revtype)"
 	done
 
-	if [ -z "$fastforward" ]; then
+	if [ "$fast_forward" ]; then
 		echo "      from  $oldrev ($oldrev_type)"
 	else
 		#  1. Existing revisions were removed.  In this case newrev is a

commit 5e621031f41c5d5e07fa13caf2ceb3e620fdf5ed
Author: Jeff Muizelaar <jeff at infidigm.net>
Date:   Thu Oct 11 17:49:21 2007 -0400

    fix contrib/hooks/post-receive-email hooks.recipients error message
    
    Have the error message for missing recipients actually report the
    missing config variable and not a fictional one.
    
    Signed-off-by: Lars Hjemli <hjemli at gmail.com>
    Signed-off-by: Shawn O. Pearce <spearce at spearce.org>

diff --git a/post-receive-email b/post-receive-email
index cbbd02f..b188aa3 100644
--- a/post-receive-email
+++ b/post-receive-email
@@ -138,7 +138,15 @@ generate_email()
 
 	# Check if we've got anyone to send to
 	if [ -z "$recipients" ]; then
-		echo >&2 "*** hooks.recipients is not set so no email will be sent"
+		case "$refname_type" in
+			"annotated tag")
+				config_name="hooks.announcelist"
+				;;
+			*)
+				config_name="hooks.mailinglist"
+				;;
+		esac
+		echo >&2 "*** $config_name is not set so no email will be sent"
 		echo >&2 "*** for $refname update $oldrev->$newrev"
 		exit 0
 	fi

commit 7e0daa9d931d90abbb0cd15baf643ea3b7abfedf
Merge: 18ae765 ad8e89b
Author: Junio C Hamano <gitster at pobox.com>
Date:   Mon Oct 1 02:09:09 2007 -0700

    Merge branch 'maint'
    
    * maint:
      Whip post 1.5.3.3 maintenance series into shape.
      git stash: document apply's --index switch
      post-receive-hook: Remove the From field from the generated email header so that the pusher's name is used


commit ad8e89bffc15956f052440e25db71e9b7a259b89
Author: Andy Parkins <andyparkins at gmail.com>
Date:   Fri Sep 28 15:24:26 2007 +0100

    post-receive-hook: Remove the From field from the generated email header so that the pusher's name is used
    
    Using the name of the committer of the revision at the tip of the
    updated ref is not sensible.  That information is available in the email
    itself should it be wanted, and by supplying a "From", we were
    effectively hiding the person who performed the push - which is useful
    information in itself.
    
    Signed-off-by: Andy Parkins <andyparkins at gmail.com>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index 1f88099..cbbd02f 100644
--- a/post-receive-email
+++ b/post-receive-email
@@ -177,7 +177,6 @@ generate_email_header()
 	# --- Email (all stdout will be the email)
 	# Generate header
 	cat <<-EOF
-	From: $committer
 	To: $recipients
 	Subject: ${EMAILPREFIX}$projectdesc $refname_type, $short_refname, ${change_type}d. $describe
 	X-Git-Refname: $refname

commit 18ae76502a82fa944d0f54563571356de71513ed
Merge: 6fac0ce b64330d
Author: Junio C Hamano <gitster at pobox.com>
Date:   Tue Sep 25 00:30:33 2007 -0700

    Merge branch 'maint'
    
    * maint:
      Do not over-quote the -f envelopesender value.
      unexpected Make output (e.g. from --debug) causes build failure
      Fixed minor typo in t/t9001-send-email.sh test command line.


commit b64330d7fb7b81499c3265d175f1d056b71c0cc2
Author: Jim Meyering <jim at meyering.net>
Date:   Tue Sep 25 08:48:59 2007 +0200

    Do not over-quote the -f envelopesender value.
    
    Without this, the value passed to sendmail would have an extra set of
    single quotes.  At least exim's sendmail emulation would object to that:
    
        exim: bad -f address "'list-addr at example.org'": malformed address: ' \
          may not follow 'list-addr at example.org
        error: hooks/post-receive exited with error code 1
    
    Signed-off-by: Jim Meyering <jim at meyering.net>
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index c589a39..1f88099 100644
--- a/post-receive-email
+++ b/post-receive-email
@@ -571,6 +571,15 @@ generate_delete_general_email()
 	echo $LOGEND
 }
 
+send_mail()
+{
+	if [ -n "$envelopesender" ]; then
+		/usr/sbin/sendmail -t -f "$envelopesender"
+	else
+		/usr/sbin/sendmail -t
+	fi
+}
+
 # ---------------------------- main()
 
 # --- Constants
@@ -607,13 +616,8 @@ if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
 	# resend an email; they could redirect the output to sendmail themselves
 	PAGER= generate_email $2 $3 $1
 else
-	if [ -n "$envelopesender" ]; then
-		envelopesender="-f '$envelopesender'"
-	fi
-
 	while read oldrev newrev refname
 	do
-		generate_email $oldrev $newrev $refname |
-		/usr/sbin/sendmail -t $envelopesender
+		generate_email $oldrev $newrev $refname | send_mail
 	done
 fi

commit 6fac0ce8f371762c3ef4010b5651e4cd93d4dda2
Author: Junio C Hamano <gitster at pobox.com>
Date:   Thu Jun 7 00:04:01 2007 -0700

    War on whitespace
    
    This uses "git-apply --whitespace=strip" to fix whitespace errors that have
    crept in to our source files over time.  There are a few files that need
    to have trailing whitespaces (most notably, test vectors).  The results
    still passes the test, and build result in Documentation/ area is unchanged.
    
    Signed-off-by: Junio C Hamano <gitster at pobox.com>

diff --git a/post-receive-email b/post-receive-email
index d1bef91..c589a39 100644
--- a/post-receive-email
+++ b/post-receive-email
@@ -199,7 +199,7 @@ generate_email_footer()
 
 
 	hooks/post-receive
-	-- 
+	--
 	$projectdesc
 	EOF
 }

commit 42e534f95a0ce7d1b759e7ce7591ead4ee4aeb91
Author: Andy Parkins <andyparkins at gmail.com>
Date:   Thu Apr 26 22:37:16 2007 +0100

    post-receive-email example hook: sed command for getting description was wrong
    
    The sed command that extracted the first line of the project description
    didn't include the -n switch and hence the project name was being
    printed twice.  This was ruining the email header generation because it
    was assumed that the description was only one line and was included in
    the subject.  This turned the subject into a two line item and
    prematurely finished the header.
    
    Signed-off-by: Andy Parkins <andyparkins at gmail.com>
    Signed-off-by: Junio C Hamano <junkio at cox.net>

diff --git a/post-receive-email b/post-receive-email
index e175b42..d1bef91 100644
--- a/post-receive-email
+++ b/post-receive-email
@@ -587,7 +587,7 @@ if [ -z "$GIT_DIR" ]; then
 	exit 1
 fi
 
-projectdesc=$(sed -e '1p' "$GIT_DIR/description")
+projectdesc=$(sed -ne '1p' "$GIT_DIR/description")
 # Check if the description is unchanged from it's default, and shorten it to a
 # more manageable length if it is
 if expr "$projectdesc" : "Unnamed repository.*$" >/dev/null

commit 1ddc5267c3078b45e3fd7db747042279284dd117
Author: Andy Parkins <andyparkins at gmail.com>
Date:   Thu Apr 26 22:36:24 2007 +0100

    post-receive-email example hook: detect rewind-only updates and output sensible message
    
    Sometimes a non-fast-forward update doesn't add new commits, it merely
    removes old commits.  This patch adds support for detecting that and
    outputting a more correct message.
    
    Signed-off-by: Andy Parkins <andyparkins at gmail.com>
    Signed-off-by: Junio C Hamano <junkio at cox.net>

diff --git a/post-receive-email b/post-receive-email
index edb30f6..e175b42 100644
--- a/post-receive-email
+++ b/post-receive-email
@@ -327,36 +327,67 @@ generate_update_branch_email()
 	if [ -z "$fastforward" ]; then
 		echo "      from  $oldrev ($oldrev_type)"
 	else
+		#  1. Existing revisions were removed.  In this case newrev is a
+		#     subset of oldrev - this is the reverse of a fast-forward,
+		#     a rewind
+		#  2. New revisions were added on top of an old revision, this is
+		#     a rewind and addition.
+
+		# (1) certainly happened, (2) possibly.  When (2) hasn't happened,
+		# we set a flag to indicate that no log printout is required.
+
 		echo ""
-		echo "This update added new revisions after undoing old revisions.  That is to"
-		echo "say, the old revision is not a strict subset of the new revision.  This"
-		echo "situation occurs when you --force push a change and generate a"
-		echo "repository containing something like this:"
-		echo ""
-		echo " * -- * -- B -- O -- O -- O ($oldrev)"
-		echo "            \\"
-		echo "             N -- N -- N ($newrev)"
-		echo ""
-		echo "When this happens we assume that you've already had alert emails for all"
-		echo "of the O revisions, and so we here report only the revisions in the N"
-		echo "branch from the common base, B."
+
+		# Find the common ancestor of the old and new revisions and compare
+		# it with newrev
+		baserev=$(git merge-base $oldrev $newrev)
+		rewind_only=""
+		if [ "$baserev" = "$newrev" ]; then
+			echo "This update discarded existing revisions and left the branch pointing at"
+			echo "a previous point in the repository history."
+			echo ""
+			echo " * -- * -- N ($newrev)"
+			echo "            \\"
+			echo "             O -- O -- O ($oldrev)"
+			echo ""
+			echo "The removed revisions are not necessarilly gone - if another reference"
+			echo "still refers to them they will stay in the repository."
+			rewind_only=1
+		else
+			echo "This update added new revisions after undoing existing revisions.  That is"
+			echo "to say, the old revision is not a strict subset of the new revision.  This"
+			echo "situation occurs when you --force push a change and generate a repository"
+			echo "containing something like this:"
+			echo ""
+			echo " * -- * -- B -- O -- O -- O ($oldrev)"
+			echo "            \\"
+			echo "             N -- N -- N ($newrev)"
+			echo ""
+			echo "When this happens we assume that you've already had alert emails for all"
+			echo "of the O revisions, and so we here report only the revisions in the N"
+			echo "branch from the common base, B."
+		fi
 	fi
 
 	echo ""
-	echo "Those revisions listed above that are new to this repository have"
-	echo "not appeared on any other notification email; so we list those"
-	echo "revisions in full, below."
+	if [ -z "$rewind_only" ]; then
+		echo "Those revisions listed above that are new to this repository have"
+		echo "not appeared on any other notification email; so we list those"
+		echo "revisions in full, below."
 
-	echo ""
-	echo $LOGBEGIN
-	git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
-	git rev-list --pretty --stdin $oldrev..$newrev
+		echo ""
+		echo $LOGBEGIN
+		git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
+		git rev-list --pretty --stdin $oldrev..$newrev
 
-	# XXX: Need a way of detecting whether git rev-list actually outputted
-	# anything, so that we can issue a "no new revisions added by this
-	# update" message
+		# XXX: Need a way of detecting whether git rev-list actually outputted
+		# anything, so that we can issue a "no new revisions added by this
+		# update" message
 
-	echo $LOGEND
+		echo $LOGEND
+	else
+		echo "No new revisions were added by this update."
+	fi
 
 	# The diffstat is shown from the old revision to the new revision.  This
 	# is to show the truth of what happened in this change.  There's no point

commit 881aa53d5b8b64c43138a6577363d834845027f9
Author: Andy Parkins <andyparkins at gmail.com>
Date:   Thu Apr 26 22:35:39 2007 +0100

    post-receive-email example hook: fastforward should have been fast_forward
    
    Signed-off-by: Andy Parkins <andyparkins at gmail.com>
    Signed-off-by: Junio C Hamano <junkio at cox.net>

diff --git a/post-receive-email b/post-receive-email
index 6516015..edb30f6 100644
--- a/post-receive-email
+++ b/post-receive-email
@@ -302,7 +302,7 @@ generate_update_branch_email()
 	# List all of the revisions that were removed by this update, in a fast forward
 	# update, this list will be empty, because rev-list O ^N is empty.  For a non
 	# fast forward, O ^N is the list of removed revisions
-	fastforward=""
+	fast_forward=""
 	rev=""
 	for rev in $(git rev-list $newrev..$oldrev)
 	do

commit 4a254b5f208c6fd5f42d2671f5dd02d6f877f736
Author: Gerrit Pape <pape at smarden.org>
Date:   Wed Apr 4 11:52:12 2007 +0000

    rename contrib/hooks/post-receieve-email to contrib/hooks/post-receive-email.
    
     $ git grep post-receieve-email
     $ git grep post-receive-email
     templates/hooks--post-receive:#. /usr/share/doc/git-core/contrib/hooks/post-receive-email
     $
    
    Signed-off-by: Gerrit Pape <pape at smarden.org>
    Signed-off-by: Junio C Hamano <junkio at cox.net>

diff --git a/post-receieve-email b/post-receive-email
similarity index 100%
rename from post-receieve-email
rename to post-receive-email

commit 80e22d4b4c43d7f675fed2a9c3618ad68bdcf599
Author: Andy Parkins <andyparkins at gmail.com>
Date:   Fri Mar 30 19:16:26 2007 +0000

    Reimplement emailing part of hooks--update in contrib/hooks/post-receive-email
    
    The update hook is no longer the correct place to generate emails; there
    is now the hooks/post-receive script which is run automatically after a
    ref has been updated.
    
    This patch is to make use of that new location, and to address some
    faults in the old update hook.
    
    The primary problem in the conversion was that in the update hook, the
    ref has not actually been changed, but is about to be.  In the
    post-receive hook the ref has already been updated.  That meant that
    where we previously had lines like:
    
     git rev-list --not --all
    
    would now give the wrong list because "--all" in the post-receive hook
    includes the ref that we are making the email for.  This made it more
    difficult to show only the new revisions added by this update.
    
    The solution is not pretty; however it does work and doesn't need any
    changes to git-rev-list itself.  It also fixes (more accurately: reduces
    the likelihood of) a nasty race when another update occurs while this
    script is running.  The solution, in short, looks like this (see the
    source code for a longer explanation)
    
     git rev-parse --not --all | grep -v $(git rev-parse $refname) |
     git rev-list --pretty --stdin $oldrev..$newrev
    
    This uses git-rev-parse followed by grep to filter out the revision of
    the ref in question before it gets to rev-list and inhibits the output
    of itself.  By using $(git rev-parse $revname) rather than $newrev as the
    filter, it also takes care of the situation where another update to the
    same ref has been made since $refname was $newrev.
    
    The second problem that is addressed is that of tags inhibiting the
    correct output of an update email.  Consider this, with somebranch and
    sometag pointing at the same revision:
    
     git push origin somebranch
     git push origin sometag
    
    That would work fine; the push of the branch would generate an email
    containing all the new commits introduced by the update, then the push
    of the tag would generate the shortlog formatted tag email.  Now
    consider:
    
     git push origin sometag
     git push origin somebranch
    
    When some branch comes to run its "--not --all" line, it will find
    sometag, and filter those commits from the email - leaving nothing.
    That meant that those commits would not show (in full) on any email.
    The fix is to not use "--all", and instead use "--branches" in the
    git-rev-parse command.
    
    Other changes
     * Lose the monstrous one-giant-script layout and put things in easy to
       digest functions.  This makes it much easier to find the place you
       need to change if you wanted to customise the output.  I've also
       tried to write more verbose comments for the same reason.  The hook
       script is big, mainly because of all the different cases that it has
       to handle, so being easy to navigate is important.
     * All uses of "git-command" changed to "git command", to cope better
       if a user decided not to install all the hard links to git;
     * Cleaned up some of the English in the email
     * The fact that the receive hook makes the ref available also allows me
       to use Shawn Pearce's fantastic suggestion that an annotated tag can
       be parsed with git-for-each-ref.  This removes the potentially
       non-portable use of "<<<" heredocs and the nasty messing around with
       "date" to convert numbers of seconds UTC to a real date
     * Deletions are now caught and notified (briefly)
     * To help with debugging, I've retained the command line mode from the
       update hook; but made it so that the output is not emailed, it's just
       printed to the screen.  This could then be redirected if the user
       wanted
     * Removed the "Hello" from the beginning of the email - it's just
       noise, and no one seriously has their day made happier by "friendly"
       programs
     * The fact that it doesn't rely on repository state as an indicator any
       more means that it's far more stable in its output; hopefully the
       same arguments will always generate the same email - even if the
       repository changes in the future.  This means you can easily recreate
       an email should you want to.
     * Included Jim Meyering's envelope sender option for the sendmail call
     * The hook is now so big that it was inappropriate to copy it
       to every repository by keeping it in the templates directory.
       Instead, I've put a comment saying to look in contrib/hooks, and
       given an example of calling the script from that template hook.  The
       advantage of calling the script residing at some fixed location is
       that if a future package of git included a bug fixed version of the
       script, that would be picked up automatically, and the user would not
       have to notice and manually copy the new hook to every repository
       that uses it.
    
    Signed-off-by: Andy Parkins <andyparkins at gmail.com>
    Signed-off-by: Junio C Hamano <junkio at cox.net>

diff --git a/post-receieve-email b/post-receieve-email
new file mode 100644
index 0000000..6516015
--- /dev/null
+++ b/post-receieve-email
@@ -0,0 +1,588 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Andy Parkins
+#
+# An example hook script to mail out commit update information.  This hook sends emails
+# listing new revisions to the repository introduced by the change being reported.  The
+# rule is that (for branch updates) each commit will appear on one email and one email
+# only.
+#
+# This hook is stored in the contrib/hooks directory.  Your distribution will have put
+# this somewhere standard.  You should make this script executable then link to it in
+# the repository you would like to use it in.  For example, on debian the hook is stored
+# in /usr/share/doc/git-core/contrib/hooks/post-receive-email:
+#
+#  chmod a+x post-receive-email
+#  cd /path/to/your/repository.git
+#  ln -sf /usr/share/doc/git-core/contrib/hooks/post-receive-email hooks/post-receive
+#
+# This hook script assumes it is enabled on the central repository of a project, with
+# all users pushing only to it and not between each other.  It will still work if you
+# don't operate in that style, but it would become possible for the email to be from
+# someone other than the person doing the push.
+#
+# Config
+# ------
+# hooks.mailinglist
+#   This is the list that all pushes will go to; leave it blank to not send
+#   emails for every ref update.
+# hooks.announcelist
+#   This is the list that all pushes of annotated tags will go to.  Leave it
+#   blank to default to the mailinglist field.  The announce emails lists the
+#   short log summary of the changes since the last annotated tag.
+# hook.envelopesender
+#   If set then the -f option is passed to sendmail to allow the envelope sender
+#   address to be set
+#
+# Notes
+# -----
+# All emails have their subjects prefixed with "[SCM]" to aid filtering.
+# All emails include the headers "X-Git-Refname", "X-Git-Oldrev",
+# "X-Git-Newrev", and "X-Git-Reftype" to enable fine tuned filtering and
+# give information for debugging.
+#
+
+# ---------------------------- Functions
+
+#
+# Top level email generation function.  This decides what type of update
+# this is and calls the appropriate body-generation routine after outputting
+# the common header
+#
+# Note this function doesn't actually generate any email output, that is taken
+# care of by the functions it calls:
+#  - generate_email_header
+#  - generate_create_XXXX_email
+#  - generate_update_XXXX_email
+#  - generate_delete_XXXX_email
+#  - generate_email_footer
+#
+generate_email()
+{
+	# --- Arguments
+	oldrev=$(git rev-parse $1)
+	newrev=$(git rev-parse $2)
+	refname="$3"
+
+	# --- Interpret
+	# 0000->1234 (create)
+	# 1234->2345 (update)
+	# 2345->0000 (delete)
+	if expr "$oldrev" : '0*$' >/dev/null
+	then
+		change_type="create"
+	else
+		if expr "$newrev" : '0*$' >/dev/null
+		then
+			change_type="delete"
+		else
+			change_type="update"
+		fi
+	fi
+
+	# --- Get the revision types
+	newrev_type=$(git cat-file -t $newrev 2> /dev/null)
+	oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null)
+	case "$change_type" in
+	create|update)
+		rev="$newrev"
+		rev_type="$newrev_type"
+		;;
+	delete)
+		rev="$oldrev"
+		rev_type="$oldrev_type"
+		;;
+	esac
+
+	# The revision type tells us what type the commit is, combined with
+	# the location of the ref we can decide between
+	#  - working branch
+	#  - tracking branch
+	#  - unannoted tag
+	#  - annotated tag
+	case "$refname","$rev_type" in
+		refs/tags/*,commit)
+			# un-annotated tag
+			refname_type="tag"
+			short_refname=${refname##refs/tags/}
+			;;
+		refs/tags/*,tag)
+			# annotated tag
+			refname_type="annotated tag"
+			short_refname=${refname##refs/tags/}
+			# change recipients
+			if [ -n "$announcerecipients" ]; then
+				recipients="$announcerecipients"
+			fi
+			;;
+		refs/heads/*,commit)
+			# branch
+			refname_type="branch"
+			short_refname=${refname##refs/heads/}
+			;;
+		refs/remotes/*,commit)
+			# tracking branch
+			refname_type="tracking branch"
+			short_refname=${refname##refs/remotes/}
+			echo >&2 "*** Push-update of tracking branch, $refname"
+			echo >&2 "***  - no email generated."
+			exit 0
+			;;
+		*)
+			# Anything else (is there anything else?)
+			echo >&2 "*** Unknown type of update to $refname ($rev_type)"
+			echo >&2 "***  - no email generated"
+			exit 1
+			;;
+	esac
+
+	# Check if we've got anyone to send to
+	if [ -z "$recipients" ]; then
+		echo >&2 "*** hooks.recipients is not set so no email will be sent"
+		echo >&2 "*** for $refname update $oldrev->$newrev"
+		exit 0
+	fi
+
+	# Email parameters
+	# The committer will be obtained from the latest existing rev; so
+	# for a deletion it will be the oldrev, for the others, then newrev
+	committer=$(git show --pretty=full -s $rev | sed -ne "s/^Commit: //p" |
+		sed -ne 's/\(.*\) </"\1" </p')
+	# The email subject will contain the best description of the ref
+	# that we can build from the parameters
+	describe=$(git describe $rev 2>/dev/null)
+	if [ -z "$describe" ]; then
+		describe=$rev
+	fi
+
+	generate_email_header
+
+	# Call the correct body generation function
+	fn_name=general
+	case "$refname_type" in
+	"tracking branch"|branch)
+		fn_name=branch
+		;;
+	"annotated tag")
+		fn_name=atag
+		;;
+	esac
+	generate_${change_type}_${fn_name}_email
+
+	generate_email_footer
+}
+
+generate_email_header()
+{
+	# --- Email (all stdout will be the email)
+	# Generate header
+	cat <<-EOF
+	From: $committer
+	To: $recipients
+	Subject: ${EMAILPREFIX}$projectdesc $refname_type, $short_refname, ${change_type}d. $describe
+	X-Git-Refname: $refname
+	X-Git-Reftype: $refname_type
+	X-Git-Oldrev: $oldrev
+	X-Git-Newrev: $newrev
+
+	This is an automated email from the git hooks/post-receive script. It was
+	generated because a ref change was pushed to the repository containing
+	the project "$projectdesc".
+
+	The $refname_type, $short_refname has been ${change_type}d
+	EOF
+}
+
+generate_email_footer()
+{
+	cat <<-EOF
+
+
+	hooks/post-receive
+	-- 
+	$projectdesc
+	EOF
+}
+
+# --------------- Branches
+
+#
+# Called for the creation of a branch
+#
+generate_create_branch_email()
+{
+	# This is a new branch and so oldrev is not valid
+	echo "        at  $newrev ($newrev_type)"
+	echo ""
+
+	echo $LOGBEGIN
+	# This shows all log entries that are not already covered by
+	# another ref - i.e. commits that are now accessible from this
+	# ref that were previously not accessible (see generate_update_branch_email
+	# for the explanation of this command)
+	git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
+	git rev-list --pretty --stdin $newrev
+	echo $LOGEND
+}
+
+#
+# Called for the change of a pre-existing branch
+#
+generate_update_branch_email()
+{
+	# Consider this:
+	#   1 --- 2 --- O --- X --- 3 --- 4 --- N
+	#
+	# O is $oldrev for $refname
+	# N is $newrev for $refname
+	# X is a revision pointed to by some other ref, for which we may
+	#   assume that an email has already been generated.
+	# In this case we want to issue an email containing only revisions
+	# 3, 4, and N.  Given (almost) by
+	#
+	#  git-rev-list N ^O --not --all
+	#
+	# The reason for the "almost", is that the "--not --all" will take
+	# precedence over the "N", and effectively will translate to
+	#
+	#  git-rev-list N ^O ^X ^N
+	#
+	# So, we need to build up the list more carefully.  git-rev-parse will
+	# generate a list of revs that may be fed into git-rev-list.  We can get
+	# it to make the "--not --all" part and then filter out the "^N" with:
+	#
+	#  git-rev-parse --not --all | grep -v N
+	#
+	# Then, using the --stdin switch to git-rev-list we have effectively
+	# manufactured
+	#
+	#  git-rev-list N ^O ^X
+	#
+	# This leaves a problem when someone else updates the repository
+	# while this script is running.  Their new value of the ref we're working
+	# on would be included in the "--not --all" output; and as our $newrev
+	# would be an ancestor of that commit, it would exclude all of our
+	# commits.  What we really want is to exclude the current value of
+	# $refname from the --not list, rather than N itself.  So:
+	#
+	#  git-rev-parse --not --all | grep -v $(git-rev-parse $refname)
+	#
+	# Get's us to something pretty safe (apart from the small time between
+	# refname being read, and git-rev-parse running - for that, I give up)
+	#
+	#
+	# Next problem, consider this:
+	#   * --- B --- * --- O ($oldrev)
+	#          \
+	#           * --- X --- * --- N ($newrev)
+	#
+	# That is to say, there is no guarantee that oldrev is a strict subset of
+	# newrev (it would have required a --force, but that's allowed).  So, we
+	# can't simply say rev-list $oldrev..$newrev.  Instead we find the common
+	# base of the two revs and list from there.
+	#
+	# As above, we need to take into account the presence of X; if another
+	# branch is already in the repository and points at some of the revisions
+	# that we are about to output - we don't want them.  The solution is as
+	# before: git-rev-parse output filtered.
+	#
+	# Finally, tags:
+	#   1 --- 2 --- O --- T --- 3 --- 4 --- N
+	#
+	# Tags pushed into the repository generate nice shortlog emails that
+	# summarise the commits between them and the previous tag.  However,
+	# those emails don't include the full commit messages that we output
+	# for a branch update.  Therefore we still want to output revisions
+	# that have been output on a tag email.
+	#
+	# Luckily, git-rev-parse includes just the tool.  Instead of using "--all"
+	# we use "--branches"; this has the added benefit that "remotes/" will
+	# be ignored as well.
+
+	# List all of the revisions that were removed by this update, in a fast forward
+	# update, this list will be empty, because rev-list O ^N is empty.  For a non
+	# fast forward, O ^N is the list of removed revisions
+	fastforward=""
+	rev=""
+	for rev in $(git rev-list $newrev..$oldrev)
+	do
+		revtype=$(git cat-file -t "$rev")
+		echo "  discards  $rev ($revtype)"
+	done
+	if [ -z "$rev" ]; then
+		fast_forward=1
+	fi
+
+	# List all the revisions from baserev to newrev in a kind of
+	# "table-of-contents"; note this list can include revisions that have
+	# already had notification emails and is present to show the full detail
+	# of the change from rolling back the old revision to the base revision and
+	# then forward to the new revision
+	for rev in $(git rev-list $oldrev..$newrev)
+	do
+		revtype=$(git cat-file -t "$rev")
+		echo "       via  $rev ($revtype)"
+	done
+
+	if [ -z "$fastforward" ]; then
+		echo "      from  $oldrev ($oldrev_type)"
+	else
+		echo ""
+		echo "This update added new revisions after undoing old revisions.  That is to"
+		echo "say, the old revision is not a strict subset of the new revision.  This"
+		echo "situation occurs when you --force push a change and generate a"
+		echo "repository containing something like this:"
+		echo ""
+		echo " * -- * -- B -- O -- O -- O ($oldrev)"
+		echo "            \\"
+		echo "             N -- N -- N ($newrev)"
+		echo ""
+		echo "When this happens we assume that you've already had alert emails for all"
+		echo "of the O revisions, and so we here report only the revisions in the N"
+		echo "branch from the common base, B."
+	fi
+
+	echo ""
+	echo "Those revisions listed above that are new to this repository have"
+	echo "not appeared on any other notification email; so we list those"
+	echo "revisions in full, below."
+
+	echo ""
+	echo $LOGBEGIN
+	git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
+	git rev-list --pretty --stdin $oldrev..$newrev
+
+	# XXX: Need a way of detecting whether git rev-list actually outputted
+	# anything, so that we can issue a "no new revisions added by this
+	# update" message
+
+	echo $LOGEND
+
+	# The diffstat is shown from the old revision to the new revision.  This
+	# is to show the truth of what happened in this change.  There's no point
+	# showing the stat from the base to the new revision because the base
+	# is effectively a random revision at this point - the user will be
+	# interested in what this revision changed - including the undoing of
+	# previous revisions in the case of non-fast forward updates.
+	echo ""
+	echo "Summary of changes:"
+	git diff-tree --stat --summary --find-copies-harder $oldrev..$newrev
+}
+
+#
+# Called for the deletion of a branch
+#
+generate_delete_branch_email()
+{
+	echo "       was  $oldrev"
+	echo ""
+	echo $LOGEND
+	git show -s --pretty=oneline $oldrev
+	echo $LOGEND
+}
+
+# --------------- Annotated tags
+
+#
+# Called for the creation of an annotated tag
+#
+generate_create_atag_email()
+{
+	echo "        at  $newrev ($newrev_type)"
+
+	generate_atag_email
+}
+
+#
+# Called for the update of an annotated tag (this is probably a rare event
+# and may not even be allowed)
+#
+generate_update_atag_email()
+{
+	echo "        to  $newrev ($newrev_type)"
+	echo "      from  $oldrev (which is now obsolete)"
+
+	generate_atag_email
+}
+
+#
+# Called when an annotated tag is created or changed
+#
+generate_atag_email()
+{
+	# Use git-for-each-ref to pull out the individual fields from the tag
+	eval $(git for-each-ref --shell --format='
+	tagobject=%(*objectname)
+	tagtype=%(*objecttype)
+	tagger=%(taggername)
+	tagged=%(taggerdate)' $refname
+	)
+
+	echo "   tagging  $tagobject ($tagtype)"
+	case "$tagtype" in
+	commit)
+		# If the tagged object is a commit, then we assume this is a
+		# release, and so we calculate which tag this tag is replacing
+		prevtag=$(git describe --abbrev=0 $newrev^ 2>/dev/null)
+
+		if [ -n "$prevtag" ]; then
+			echo "  replaces  $prevtag"
+		fi
+		;;
+	*)
+		echo "    length  $(git cat-file -s $tagobject) bytes"
+		;;
+	esac
+	echo " tagged by  $tagger"
+	echo "        on  $tagged"
+
+	echo ""
+	echo $LOGBEGIN
+
+	# Show the content of the tag message; this might contain a change log
+	# or release notes so is worth displaying.
+	git cat-file tag $newrev | sed -e '1,/^$/d'
+
+	echo ""
+	case "$tagtype" in
+	commit)
+		# Only commit tags make sense to have rev-list operations performed
+		# on them
+		if [ -n "$prevtag" ]; then
+			# Show changes since the previous release
+			git rev-list --pretty=short "$prevtag..$newrev" | git shortlog
+		else
+			# No previous tag, show all the changes since time began
+			git rev-list --pretty=short $newrev | git shortlog
+		fi
+		;;
+	*)
+		# XXX: Is there anything useful we can do for non-commit objects?
+		;;
+	esac
+
+	echo $LOGEND
+}
+
+#
+# Called for the deletion of an annotated tag
+#
+generate_delete_atag_email()
+{
+	echo "       was  $oldrev"
+	echo ""
+	echo $LOGEND
+	git show -s --pretty=oneline $oldrev
+	echo $LOGEND
+}
+
+# --------------- General references
+
+#
+# Called when any other type of reference is created (most likely a
+# non-annotated tag)
+#
+generate_create_general_email()
+{
+	echo "        at  $newrev ($newrev_type)"
+
+	generate_general_email
+}
+
+#
+# Called when any other type of reference is updated (most likely a
+# non-annotated tag)
+#
+generate_update_general_email()
+{
+	echo "        to  $newrev ($newrev_type)"
+	echo "      from  $oldrev"
+
+	generate_general_email
+}
+
+#
+# Called for creation or update of any other type of reference
+#
+generate_general_email()
+{
+	# Unannotated tags are more about marking a point than releasing a version;
+	# therefore we don't do the shortlog summary that we do for annotated tags
+	# above - we simply show that the point has been marked, and print the log
+	# message for the marked point for reference purposes
+	#
+	# Note this section also catches any other reference type (although there
+	# aren't any) and deals with them in the same way.
+
+	echo ""
+	if [ "$newrev_type" = "commit" ]; then
+		echo $LOGBEGIN
+		git show --no-color --root -s $newrev
+		echo $LOGEND
+	else
+		# What can we do here?  The tag marks an object that is not a commit,
+		# so there is no log for us to display.  It's probably not wise to
+		# output git-cat-file as it could be a binary blob.  We'll just say how
+		# big it is
+		echo "$newrev is a $newrev_type, and is $(git cat-file -s $newrev) bytes long."
+	fi
+}
+
+#
+# Called for the deletion of any other type of reference
+#
+generate_delete_general_email()
+{
+	echo "       was  $oldrev"
+	echo ""
+	echo $LOGEND
+	git show -s --pretty=oneline $oldrev
+	echo $LOGEND
+}
+
+# ---------------------------- main()
+
+# --- Constants
+EMAILPREFIX="[SCM] "
+LOGBEGIN="- Log -----------------------------------------------------------------"
+LOGEND="-----------------------------------------------------------------------"
+
+# --- Config
+# Set GIT_DIR either from the working directory, or from the environment
+# variable.
+GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
+if [ -z "$GIT_DIR" ]; then
+	echo >&2 "fatal: post-receive: GIT_DIR not set"
+	exit 1
+fi
+
+projectdesc=$(sed -e '1p' "$GIT_DIR/description")
+# Check if the description is unchanged from it's default, and shorten it to a
+# more manageable length if it is
+if expr "$projectdesc" : "Unnamed repository.*$" >/dev/null
+then
+	projectdesc="UNNAMED PROJECT"
+fi
+
+recipients=$(git repo-config hooks.mailinglist)
+announcerecipients=$(git repo-config hooks.announcelist)
+envelopesender=$(git-repo-config hooks.envelopesender)
+
+# --- Main loop
+# Allow dual mode: run from the command line just like the update hook, or if
+# no arguments are given then run as a hook script
+if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
+	# Output to the terminal in command line mode - if someone wanted to
+	# resend an email; they could redirect the output to sendmail themselves
+	PAGER= generate_email $2 $3 $1
+else
+	if [ -n "$envelopesender" ]; then
+		envelopesender="-f '$envelopesender'"
+	fi
+
+	while read oldrev newrev refname
+	do
+		generate_email $oldrev $newrev $refname |
+		/usr/sbin/sendmail -t $envelopesender
+	done
+fi

-----------------------------------------------------------------------

Summary of changes:
 .../library/scmgit/hooks/postreceiveemail/LICENCE} |   21 ++
 .../library/scmgit/hooks/postreceiveemail/README   |   71 +++++++
 .../{postreceiveemail => post-receive-email}       |  220 +++++++++++++++-----
 .../library/scmgit/postReceiveEmail.class.php      |    2 +-
 4 files changed, 264 insertions(+), 50 deletions(-)
 copy src/plugins/{cvstracker/COPYING => scmhook/library/scmgit/hooks/postreceiveemail/LICENCE} (95%)
 create mode 100644 src/plugins/scmhook/library/scmgit/hooks/postreceiveemail/README
 rename src/plugins/scmhook/library/scmgit/hooks/postreceiveemail/{postreceiveemail => post-receive-email} (74%)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list