Mailing List Archive

Help with Post-receive hook for Git
I have a question regarding the Git post-receive hook.

Per the Trac Repository Admin guide (link below), the suggested post-receive hook is:

#!/bin/sh
tracenv=/path/to/env # set to your Trac environment's path
repos= # set to your repository's name
while read oldrev newrev refname; do
if [ "$oldrev" = 0000000000000000000000000000000000000000 ]; then
git rev-list --reverse "$newrev" --
else
git rev-list --reverse "$newrev" "^$oldrev" --
fi | xargs trac-admin "$tracenv" changeset added "$repos"
done

https://trac.edgewall.org/wiki/TracRepositoryAdmin

Per the ticket below in Trac Edgewall, the above hook is dangerous and the recommended hook is:

#!/bin/sh
tracenv=/path/to/env # change with your Trac environment's path
repos= # change with your repository's name
while read oldrev newrev refname; do
if expr "$oldrev" : '0*$' >/dev/null; then
branches=`git for-each-ref --format="%(refname)" | grep -vw "$refname"`
git rev-list --reverse "$newrev" --not $branches --
elif expr "$newrev" : '0*$' >/dev/null; then
: # do nothing upon removing a branch
else
git rev-list --reverse "$newrev" "^$oldrev" --
fi | xargs --no-run-if-empty trac-admin "$tracenv" changeset added "$repos"

done

https://trac.edgewall.org/ticket/12763

Can you please tell me which hook I should be using.
I read through the different comments on that ticket, as well as #10730, but I really did not see any conclusion.
As I understand it, the danger of the first script is generating many commits at once, as well as lots of email notifications.
However, the problem with the 2nd script is it won't work when pushing multiple branches.
Please advise.

Below is the environment:
* Trac 1.2.3
* Babel 1.3
* Docutils 0.12
* Genshi 0.7 (with speedups)
* GIT 2.7.4
* mod_python 3.3.1
* Pygments 2.1
* pysqlite 2.7.0
* Python 2.7.12
* Pytz 2014.10
* setuptools 20.7.0
* SQLite 3.11.0
* jQuery 1.11.3
* jQuery UI 1.11.4
* jQuery Timepicker 1.5.5
* Apache2 2.4.18


Best,
Patty Cottrill


*** CONFIDENTIALITY NOTICE: This email and any attachments from IMCI Technologies are for the sole use of the intended recipient and may contain material that is proprietary, confidential, privileged or otherwise legally protected or restricted under applicable government laws. Any review, disclosure, distributing or other use without expressed permission of the sender is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies without reading, printing, or saving. ***

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/MN2PR15MB316876BBE1C12D7B5137D4C9C213A%40MN2PR15MB3168.namprd15.prod.outlook.com.