git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Matthew Gwynne
Message 3 of 3 in “Correct documentation of 'reflog show' to explain it shows HEAD”
  1. Correct documentation of 'reflog show' to explain it shows HEADShawn O. Pearce, Aug 19, 2007
  2. Issues with envelopesender and empty log messages using contrib/hooks/post-receive-emailMatthew Gwynne, Aug 20, 2007
  3. Junio C HamanoAug 20, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.