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

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...

Previous: David D. KilzerNext: David D. Kilzer
Message 2 of 7 in “git-send-email: show all headers when sending mail”
  1. git-send-email: show all headers when sending mailDavid D. Kilzer, Nov 12, 2007
  2. Junio C HamanoNov 13, 2007
  3. git-send-email: show all headers when sending mailDavid D. Kilzer, Nov 19, 2007
  4. Junio C HamanoNov 19, 2007
  5. Don't print an empty Cc header in SMTP mode when there's no cc recipient definedAsk Bjørn Hansen, Nov 19, 2007
  6. David D. KilzerNov 19, 2007
  7. Ask Bjørn HansenNov 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.