Re: [PATCH] post-receive-email: allow customizing of subject/intro/footer
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 21, 2010, 20:09 UTC
- Message-ID
- <7v636vp6cw.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <201001211259.30704.vapier@gentoo.org>
Mike Frysinger <vapier@gentoo.org> writes:
Show 24 quoted lines
>> So, overall, why not make generate_email_header() be simply:
>>
>> generate_email_header()
>> {
>> # --- Email (all stdout will be the email)
>> # Generate header
>> subst_vars <<-EOF
>> To: $recipients
>> Subject: ${emailprefix}${emailsubject}
>> X-Git-Refname: @refname@
>> X-Git-Reftype: @refname_type@
>> X-Git-Oldrev: @oldrev@
>> X-Git-Newrev: @newrev@
>>
>> ${emailbodyintro}
>>
>> EOF
>> }
>>
>> This would also let you simply subst_vars() so that it needn't support
>> piped invocations, no? (Not a very drastic simplification, but still...)
>
> if emailbodyintro is empty, this adds two useless newlines. otherwise, this
> would be fine i think.I haven't looked at the original that is being improved upon (because I am not very interested in this sample script myself), but I have two comments on the above.
- You can do something like this to fix that "empty line" issue, no?
LF='
' ;# newline
subst_vars <<-EOF
... ${emailbodyintro:+"$emailbodyinto$LF"}
EOF- If you are using shell variable interpolation anyway, why do you still need @special_name@ interpolated with perl or sed or whatever you are using in subst_vars (which I didn't look at)? If you have $refname, $refname_type and friends, can't the above become "cat <<-EOF"?