From: Lars Noschinski <lars@public.noschinski.de>
To: git@vger.kernel.org
Cc: andyparkins@gmail.com, pape@smarden.org, gitster@pobox.com,
Lars Noschinski <lars@public.noschinski.de>
Subject: [PATCH] post-receive-email: do not call sendmail if no mail was generated
Date: Tue, 8 Sep 2009 21:00:18 +0200 [thread overview]
Message-ID: <1252436418-7660-1-git-send-email-lars@public.noschinski.de> (raw)
In-Reply-To: <20090908185555.GA3858@lars.home.noschinski.de>
contrib/hooks/post-receive-email used to call the send_mail function
(and thus, /usr/sbin/sendmail), even if generate_mail generated no
output. This is problematic, as the sendmail binary provided by exim4
generates an error mail if provided with an empty input.
Therefore, we now read one line ourselves and use the result to decide
if we really want to call /usr/sbin/sendmail.
---
contrib/hooks/post-receive-email | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
Two things changed:
- we do not read the whole mail in a shell variable
- the decision whether to call sendmail is based on the output generated
by generate_mail, not its return code
diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
index 2a66063..c855c31 100755
--- a/contrib/hooks/post-receive-email
+++ b/contrib/hooks/post-receive-email
@@ -637,6 +637,16 @@ show_new_revisions()
send_mail()
{
+ OIFS=$IFS
+ IFS='
+'
+ read FIRSTLINE || exit 1
+ (printf $FIRSTLINE'\n'; cat) | call_sendmail
+ IFS=$OLD_IFS
+}
+
+call_sendmail()
+{
if [ -n "$envelopesender" ]; then
/usr/sbin/sendmail -t -f "$envelopesender"
else
@@ -644,6 +654,7 @@ send_mail()
fi
}
+
# ---------------------------- main()
# --- Constants
--
1.6.3.3
next prev parent reply other threads:[~2009-09-08 19:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-28 17:39 [PATCH] post-receive-email: do not call sendmail if no mail was generated Lars Noschinski
2009-09-08 9:20 ` Lars Noschinski
2009-09-08 16:57 ` Junio C Hamano
2009-09-08 18:55 ` Lars Noschinski
2009-09-08 19:00 ` Lars Noschinski [this message]
2009-09-08 20:15 ` Junio C Hamano
2009-09-08 20:59 ` Lars Noschinski
2009-09-08 21:49 ` Junio C Hamano
2009-09-08 21:12 ` Andy Parkins
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=1252436418-7660-1-git-send-email-lars@public.noschinski.de \
--to=lars@public.noschinski.de \
--cc=andyparkins@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pape@smarden.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).