Re: [PATCH] git-send-email: show all headers when sending mail
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 13, 2007, 07:28 UTC
- Message-ID
- <7vbq9ywqmq.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <1194883317-11161-1-git-send-email-ddkilzer@kilzer.net>
"David D. Kilzer" <ddkilzer@kilzer.net> writes:
Show 9 quoted lines
> +replace_header () {
> + EXPECTED=expected-show-all-headers &&
> + ACTUAL=actual-show-all-headers &&
> + REPLACEMENT=`cat ${ACTUAL} | grep "^$1:"` &&
> + if [ ! -z "${REPLACEMENT}" ]; then \
> + cat ${EXPECTED} | sed -e "s/^$1: .*\$/${REPLACEMENT}/" > ${EXPECTED}.$$ && \
> + mv -f ${EXPECTED}.$$ ${EXPECTED}
> + fi
> +}If the actual output did not have an asked-for field, REPLACEMENT will be empty and the breakage will go unnoticed, won't it?
It would probably be better to write it this way:
test_expect_success 'Show all headers' '
git send-email \
--dry-run \
--from="Example <from@example.com>" \
--to=to@example.com \
--cc=cc@example.com \
--bcc=bcc@example.com \
--in-reply-to="<unique-message-id@example.com>" \
--smtp-sever relay.example.com \
$patches |
sed -e "s/^\(Date:\).*/1 DATE-STRING/" \
-e "s/^\(Message-Id:\).*/1 ID-STRING/" \
-e "s/^\(X-Mailer:\).*/1 X-MAILER-STRING/" \
>actual &&
diff -u expected actual'
and prepare the expected output with the varying field already replaced with the placeholder string.
Oh, by the way, do not cat a single file and pipe it to another command. There may still be a few such stupidity in our test scripts but let's not add even more of them...