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

Re: [PATCH] post-receive-email: ensure sent messages are not empty

From
KFKevin P. Fleming <kpfleming@digium.com>
Date
Aug 2, 2010, 22:17 UTC
Message-ID
<4C5743F1.5020806@digium.com>
In-Reply-To
<7vk4o8k73w.fsf@alter.siamese.dyndns.org>
On 08/02/2010 05:00 PM, Junio C Hamano wrote:
Show 32 quoted lines
> "Kevin P. Fleming" <kpfleming@digium.com> writes:
> 
>> @@ -687,10 +699,12 @@ if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
>>  	# Output to the terminal in command line mode - if someone wanted to
>>  	# resend an email; they could redirect the output to sendmail
>>  	# themselves
>> -	PAGER= generate_email $2 $3 $1
>> +	prep_for_email $2 $3 $1
>> +	PAGER= generate_email
>>  else
>>  	while read oldrev newrev refname
>>  	do
>> -		generate_email $oldrev $newrev $refname | send_mail
>> +		prep_for_email $oldrev $newrev $refname
>> +		generate_email | send_mail
>>  	done
> 
> As "prep" exits, when this is run as a hook to read many updated refs, any
> inappropriate update to one ref will cause messages for later refs from
> getting sent out.  Earlier such an update may have sent an empty message
> but at least didn't break messages for other refs, if I am reading the
> code correctly.  Is that what you really want?
> 
> Perhaps you would want to do something like this instead, after adjusting
> the exit code from the new "prep" shell function?
> 
> 	while ...
>         do
>         	prep_for_email || continue
>                 generate_email | send_mail
> 	done
> 

You are right; instead of prep_for_email using 'exit 0' to stop the process as was done before, it should just return an exit code to skip the current ref being processed. This was also a bug previously, since generate_email used 'exit 0' to stop the processing of a particular ref, which would actually stop processing of any further refs as well.

-- 
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
skype: kpfleming | jabber: kfleming@digium.com
Check us out at www.digium.com & www.asterisk.org
Previous: Junio C Hamano
Message 3 of 3 in “post-receive-email: ensure sent messages are not empty”
  1. post-receive-email: ensure sent messages are not emptyKevin P. Fleming, Aug 2, 2010
  2. Junio C HamanoAug 2, 2010
  3. Kevin P. FlemingAug 2, 2010

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.