All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Matthew Gwynne <mathew.gwynne@gmail.com>
Cc: git@vger.kernel.org, Andy Parkins <andyparkins@gmail.com>
Subject: Re: Issues with envelopesender and empty log messages using contrib/hooks/post-receive-email
Date: Mon, 20 Aug 2007 16:42:30 -0700	[thread overview]
Message-ID: <7vsl6drcwp.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20070820225323.GA25430@ares> (Matthew Gwynne's message of "Mon, 20 Aug 2007 23:53:23 +0100")

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.

> 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

      reply	other threads:[~2007-08-20 23:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-19  8:18 [PATCH] Correct documentation of 'reflog show' to explain it shows HEAD Shawn O. Pearce
2007-08-20 22:53 ` Issues with envelopesender and empty log messages using contrib/hooks/post-receive-email Matthew Gwynne
2007-08-20 23:42   ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vsl6drcwp.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=andyparkins@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=mathew.gwynne@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.