Re: Issues with envelopesender and empty log messages using contrib/hooks/post-receive-email
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 20, 2007, 23:42 UTC
- Message-ID
- <7vsl6drcwp.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <20070820225323.GA25430@ares>
Matthew Gwynne <mathew.gwynne@gmail.com> writes:
> I've recently encountered 2 problems with use of the example > post-receive-mail script in contrib/hooks/post-receive-email.
The script's author Andy Parkins Cc'ed.
Show 18 quoted lines
> Firstly I found that having set hooks.envelopesender, the script ended > up sending mail with the envelope sender set to the email address > given literally surrounded by single quotes which caused the mail > server to complain about invalid address syntax. > ... > diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email > index c589a39..a733d0c 100644 > --- a/contrib/hooks/post-receive-email > +++ b/contrib/hooks/post-receive-email > @@ -608,7 +608,7 @@ if [ -n "$1" -a -n "$2" -a -n "$3" ]; then > PAGER= generate_email $2 $3 $1 > else > if [ -n "$envelopesender" ]; then > - envelopesender="-f '$envelopesender'" > + envelopesender="-f \"$envelopesender\"" > fi > > while read oldrev newrev refname
I do not think this is a correct fix either.
Suppose you have envelope sender "A B <c@d.xz>" and have original or your version to massage that string.
A few lines below the part you quoted does this:
/usr/sbin/sendmail -t $envelopesender
which would expand and split at $IFS into
/usr/sbin/sendmail -t -f 'A B <c@d.xz>'
$0 $1 $2 $3 $4 $5 which is wrong, but then your fixed version would read as:
/usr/sbin/sendmail -t -f '"A B <c@d.xz>"'
$0 $1 $2 $3 $4 $5 which looks just as wrong.
Perhaps you would need something like this (untested) patch.
---
contrib/hooks/post-receive-email | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email index c589a39..f1efd5f 100644 --- a/contrib/hooks/post-receive-email +++ b/contrib/hooks/post-receive-email @@ -607,13 +607,10 @@ 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 + /usr/sbin/sendmail -t ${envelopesender:+"-f"} \ + ${envelopesender:+"$envelopesender"} done fi