@matheusbsbs / matheus-bagliano / commits / b7f30e0a97
Fork 0

git-send-email: show all headers when sending mail

As a git newbie, it was confusing to set an In-Reply-To header but then not see it printed when the git-send-email command was run. This patch prints all headers that would be sent to sendmail or an SMTP server instead of only printing From, Subject, Cc, To. It also removes the now-extraneous Date header after the "Log says" line. Added test to t/t9001-send-email.sh. Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

David D. Kilzer committed Nov 18, 2007 at 20:14 UTC b7f30e0a972ab90a0f7720a7d6411822eb796ea3
2 files changed +39 -2
git-send-email.perl
+2 -2
@@ -643,7 +643,7 @@ X-Mailer: git-send-email $gitversion
643 if ($quiet) {
644 printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject);
645 } else {
646 - print (($dry_run ? "Dry-" : "")."OK. Log says:\nDate: $date\n");
646 + print (($dry_run ? "Dry-" : "")."OK. Log says:\n");
647 if ($smtp_server !~ m#^/#) {
648 print "Server: $smtp_server\n";
649 print "MAIL FROM:<$raw_from>\n";
@@ -651,7 +651,7 @@ X-Mailer: git-send-email $gitversion
651 } else {
652 print "Sendmail: $smtp_server ".join(' ',@sendmail_parameters)."\n";
653 }
654 - print "From: $sanitized_sender\nSubject: $subject\nCc: $cc\nTo: $to\n\n";
654 + print $header, "\n";
655 if ($smtp) {
656 print "Result: ", $smtp->code, ' ',
657 ($smtp->message =~ /\n([^\n]+\n)$/s), "\n";
t/t9001-send-email.sh
+37
@@ -41,4 +41,41 @@ test_expect_success \
41 'Verify commandline' \
42 'diff commandline expected'
43
44 +cat >expected-show-all-headers <<\EOF
45 +0001-Second.patch
46 +(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
47 +Dry-OK. Log says:
48 +Server: relay.example.com
49 +MAIL FROM:<from@example.com>
50 +RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<bcc@example.com>
51 +From: Example <from@example.com>
52 +To: to@example.com
53 +Cc: cc@example.com, A <author@example.com>
54 +Subject: [PATCH 1/1] Second.
55 +Date: DATE-STRING
56 +Message-Id: MESSAGE-ID-STRING
57 +X-Mailer: X-MAILER-STRING
58 +In-Reply-To: <unique-message-id@example.com>
59 +References: <unique-message-id@example.com>
60 +
61 +Result: OK
62 +EOF
63 +
64 +test_expect_success 'Show all headers' '
65 + git send-email \
66 + --dry-run \
67 + --from="Example <from@example.com>" \
68 + --to=to@example.com \
69 + --cc=cc@example.com \
70 + --bcc=bcc@example.com \
71 + --in-reply-to="<unique-message-id@example.com>" \
72 + --smtp-server relay.example.com \
73 + $patches |
74 + sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
75 + -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
76 + -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
77 + >actual-show-all-headers &&
78 + diff -u expected-show-all-headers actual-show-all-headers
79 +'
80 +
81 test_done