{"thread":{"id":"10833","subject":"[PATCH] git-send-email: show all headers when sending mail","startedAt":"2007-11-12T16:01:57Z","lastAt":"2007-11-20T01:53:57Z","messageCount":7,"participants":["David D. Kilzer","Junio C Hamano","Ask Bjørn Hansen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"59509","messageId":"1194883317-11161-1-git-send-email-ddkilzer@kilzer.net","threadId":"10833","inReplyTo":null,"subject":"[PATCH] git-send-email: show all headers when sending mail","fromName":"David D. Kilzer","fromEmail":"ddkilzer@kilzer.net","sentAt":"2007-11-12T16:01:57Z","receivedAt":"2007-11-12T16:01:57Z","isPatch":true,"sender":{"key":"ddkilzer@kilzer.net","avatar":"https://avatars.githubusercontent.com/u/263571?v=4"},"body":"As a git newbie, it was confusing to set an In-Reply-To header but then\nnot see it printed when the git-send-email command was run.\n\nThis patch prints all headers that would be sent to sendmail or an SMTP\nserver instead of only printing From, Subject, Cc, To.  It also removes\nthe now-extraneous Date header after the \"Log says\" line.\n\nAdded test to t/t9001-send-email.sh.\n\nSigned-off-by: David D. Kilzer <ddkilzer@kilzer.net>\n---\n\nI'd like to see this applied to the maint branch.\n\n git-send-email.perl   |    4 ++--\n t/t9001-send-email.sh |   38 ++++++++++++++++++++++++++++++++++++++\n 2 files changed, 40 insertions(+), 2 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 8760cf8..e3ea786 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -573,7 +573,7 @@ X-Mailer: git-send-email $gitversion\n \tif ($quiet) {\n \t\tprintf (($dry_run ? \"Dry-\" : \"\").\"Sent %s\\n\", $subject);\n \t} else {\n-\t\tprint (($dry_run ? \"Dry-\" : \"\").\"OK. Log says:\\nDate: $date\\n\");\n+\t\tprint (($dry_run ? \"Dry-\" : \"\").\"OK. Log says:\\n\");\n \t\tif ($smtp_server !~ m#^/#) {\n \t\t\tprint \"Server: $smtp_server\\n\";\n \t\t\tprint \"MAIL FROM:<$raw_from>\\n\";\n@@ -581,7 +581,7 @@ X-Mailer: git-send-email $gitversion\n \t\t} else {\n \t\t\tprint \"Sendmail: $smtp_server \".join(' ',@sendmail_parameters).\"\\n\";\n \t\t}\n-\t\tprint \"From: $sanitized_sender\\nSubject: $subject\\nCc: $cc\\nTo: $to\\n\\n\";\n+\t\tprint $header, \"\\n\";\n \t\tif ($smtp) {\n \t\t\tprint \"Result: \", $smtp->code, ' ',\n \t\t\t\t($smtp->message =~ /\\n([^\\n]+\\n)$/s), \"\\n\";\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 83f9470..fc03e40 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -41,4 +41,42 @@ test_expect_success \\\n     'Verify commandline' \\\n     'diff commandline expected'\n \n+cat >expected-show-all-headers <<\\EOF\n+0001-Second.patch\n+(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'\n+Dry-OK. Log says:\n+Server: relay.example.com\n+MAIL FROM:<from@example.com>\n+RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<bcc@example.com>\n+From: Example <from@example.com>\n+To: to@example.com\n+Cc: cc@example.com, A <author@example.com>\n+Subject: [PATCH 1/1] Second.\n+Date: Mon, 12 Nov 2007 15:01:19 +0000\n+Message-Id: <1194879679-15720-1-git-send-email-from@example.com>\n+X-Mailer: git-send-email 1.5.3.5.38.gb33cf-dirty\n+In-Reply-To: <unique-message-id@example.com>\n+References: <unique-message-id@example.com>\n+\n+Result: OK\n+EOF\n+\n+replace_header () {\n+\tEXPECTED=expected-show-all-headers &&\n+\tACTUAL=actual-show-all-headers &&\n+\tREPLACEMENT=`cat ${ACTUAL} | grep \"^$1:\"` &&\n+\tif [ ! -z \"${REPLACEMENT}\" ]; then \\\n+\t\tcat ${EXPECTED} | sed -e \"s/^$1: .*\\$/${REPLACEMENT}/\" > ${EXPECTED}.$$ && \\\n+\t\tmv -f ${EXPECTED}.$$ ${EXPECTED}\n+\tfi\n+}\n+\n+test_expect_success 'Show all headers' '\n+\tgit 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-server relay.example.com $patches > actual-show-all-headers &&\n+\treplace_header \"Date\" &&\n+\treplace_header \"Message-Id\" &&\n+\treplace_header \"X-Mailer\" &&\n+\tdiff -u expected-show-all-headers actual-show-all-headers\n+'\n+\n test_done\n-- \n1.5.3.4\n"},{"id":"59623","messageId":"7vbq9ywqmq.fsf@gitster.siamese.dyndns.org","threadId":"10833","inReplyTo":"1194883317-11161-1-git-send-email-ddkilzer@kilzer.net","subject":"Re: [PATCH] git-send-email: show all headers when sending mail","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-13T07:28:45Z","receivedAt":"2007-11-13T07:28:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"David D. Kilzer\" <ddkilzer@kilzer.net> writes:\n\n> +replace_header () {\n> +\tEXPECTED=expected-show-all-headers &&\n> +\tACTUAL=actual-show-all-headers &&\n> +\tREPLACEMENT=`cat ${ACTUAL} | grep \"^$1:\"` &&\n> +\tif [ ! -z \"${REPLACEMENT}\" ]; then \\\n> +\t\tcat ${EXPECTED} | sed -e \"s/^$1: .*\\$/${REPLACEMENT}/\" > ${EXPECTED}.$$ && \\\n> +\t\tmv -f ${EXPECTED}.$$ ${EXPECTED}\n> +\tfi\n> +}\n\nIf the actual output did not have an asked-for field,\nREPLACEMENT will be empty and the breakage will go unnoticed,\nwon't it?\n\nIt would probably be better to write it this way:\n\n\ttest_expect_success 'Show all headers' '\n\n\t\tgit send-email \\\n                \t--dry-run \\\n                        --from=\"Example <from@example.com>\" \\\n                        --to=to@example.com \\\n                        --cc=cc@example.com \\\n                        --bcc=bcc@example.com \\\n                        --in-reply-to=\"<unique-message-id@example.com>\" \\\n                        --smtp-sever relay.example.com \\\n                        $patches |\n\t\tsed\t-e \"s/^\\(Date:\\).*/1 DATE-STRING/\" \\\n                \t-e \"s/^\\(Message-Id:\\).*/1 ID-STRING/\" \\\n                        -e \"s/^\\(X-Mailer:\\).*/1 X-MAILER-STRING/\" \\\n\t\t\t>actual &&\n\t\tdiff -u expected actual\n\n        '\n\nand prepare the expected output with the varying field already\nreplaced with the placeholder string.\n\nOh, by the way, do not cat a single file and pipe it to another\ncommand.  There may still be a few such stupidity in our test\nscripts but let's not add even more of them...\n"},{"id":"60266","messageId":"1195445695-27262-1-git-send-email-ddkilzer@kilzer.net","threadId":"10833","inReplyTo":"7vbq9ywqmq.fsf@gitster.siamese.dyndns.org","subject":"[PATCH v2] git-send-email: show all headers when sending mail","fromName":"David D. Kilzer","fromEmail":"ddkilzer@kilzer.net","sentAt":"2007-11-19T04:14:55Z","receivedAt":"2007-11-19T04:14:55Z","isPatch":true,"sender":{"key":"ddkilzer@kilzer.net","avatar":"https://avatars.githubusercontent.com/u/263571?v=4"},"body":"As a git newbie, it was confusing to set an In-Reply-To header but then\nnot see it printed when the git-send-email command was run.\n\nThis patch prints all headers that would be sent to sendmail or an SMTP\nserver instead of only printing From, Subject, Cc, To.  It also removes\nthe now-extraneous Date header after the \"Log says\" line.\n\nAdded test to t/t9001-send-email.sh.\n\nSigned-off-by: David D. Kilzer <ddkilzer@kilzer.net>\n---\n\nUpdated t/t9001-send-email.sh per feedback from Junio C Hamano.\n\n git-send-email.perl   |    4 ++--\n t/t9001-send-email.sh |   37 +++++++++++++++++++++++++++++++++++++\n 2 files changed, 39 insertions(+), 2 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 2b1f1b5..f4539a0 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -575,7 +575,7 @@ X-Mailer: git-send-email $gitversion\n \tif ($quiet) {\n \t\tprintf (($dry_run ? \"Dry-\" : \"\").\"Sent %s\\n\", $subject);\n \t} else {\n-\t\tprint (($dry_run ? \"Dry-\" : \"\").\"OK. Log says:\\nDate: $date\\n\");\n+\t\tprint (($dry_run ? \"Dry-\" : \"\").\"OK. Log says:\\n\");\n \t\tif ($smtp_server !~ m#^/#) {\n \t\t\tprint \"Server: $smtp_server\\n\";\n \t\t\tprint \"MAIL FROM:<$raw_from>\\n\";\n@@ -583,7 +583,7 @@ X-Mailer: git-send-email $gitversion\n \t\t} else {\n \t\t\tprint \"Sendmail: $smtp_server \".join(' ',@sendmail_parameters).\"\\n\";\n \t\t}\n-\t\tprint \"From: $sanitized_sender\\nSubject: $subject\\nCc: $cc\\nTo: $to\\n\\n\";\n+\t\tprint $header, \"\\n\";\n \t\tif ($smtp) {\n \t\t\tprint \"Result: \", $smtp->code, ' ',\n \t\t\t\t($smtp->message =~ /\\n([^\\n]+\\n)$/s), \"\\n\";\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 83f9470..659f9c7 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -41,4 +41,41 @@ test_expect_success \\\n     'Verify commandline' \\\n     'diff commandline expected'\n \n+cat >expected-show-all-headers <<\\EOF\n+0001-Second.patch\n+(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'\n+Dry-OK. Log says:\n+Server: relay.example.com\n+MAIL FROM:<from@example.com>\n+RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<bcc@example.com>\n+From: Example <from@example.com>\n+To: to@example.com\n+Cc: cc@example.com, A <author@example.com>\n+Subject: [PATCH 1/1] Second.\n+Date: DATE-STRING\n+Message-Id: MESSAGE-ID-STRING\n+X-Mailer: X-MAILER-STRING\n+In-Reply-To: <unique-message-id@example.com>\n+References: <unique-message-id@example.com>\n+\n+Result: OK\n+EOF\n+\n+test_expect_success 'Show all headers' '\n+\tgit send-email \\\n+\t\t--dry-run \\\n+\t\t--from=\"Example <from@example.com>\" \\\n+\t\t--to=to@example.com \\\n+\t\t--cc=cc@example.com \\\n+\t\t--bcc=bcc@example.com \\\n+\t\t--in-reply-to=\"<unique-message-id@example.com>\" \\\n+\t\t--smtp-server relay.example.com \\\n+\t\t$patches |\n+\tsed\t-e \"s/^\\(Date:\\).*/\\1 DATE-STRING/\" \\\n+\t\t-e \"s/^\\(Message-Id:\\).*/\\1 MESSAGE-ID-STRING/\" \\\n+\t\t-e \"s/^\\(X-Mailer:\\).*/\\1 X-MAILER-STRING/\" \\\n+\t\t>actual-show-all-headers &&\n+\tdiff -u expected-show-all-headers actual-show-all-headers\n+'\n+\n test_done\n-- \n1.5.3.4\n"},{"id":"60277","messageId":"7voddqodhs.fsf@gitster.siamese.dyndns.org","threadId":"10833","inReplyTo":"1195445695-27262-1-git-send-email-ddkilzer@kilzer.net","subject":"Re: [PATCH v2] git-send-email: show all headers when sending mail","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-19T08:17:51Z","receivedAt":"2007-11-19T08:17:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.  Looks nice and obviously correct.\n\nOne thing that has been bugging me for a long time now stands\nout like a sore thumb much more: empty Cc: is shown.\n\n    $ git-send-email --dry-run --to=junio@my.isp.net 0001-branch-contains.txt\n    Who should the emails appear to be from? [Junio C Hamano <gitster@pobox.com>]\n    Emails will be sent from: Junio C Hamano <gitster@pobox.com>\n    Message-ID to be used as In-Reply-To for the first email?\n    0001-branch-contains.txt\n    Dry-OK. Log says:\n    Date: Mon, 19 Nov 2007 00:10:04 -0800\n    Server: my.isp.net\n    MAIL FROM:<gitster@pobox.com>\n    RCPT TO:<junio@my.isp.net>\n    From: Junio C Hamano <gitster@pobox.com>\n    Subject: [PATCH] branch --contains=<commit>\n    Cc:\n    To: junkio@cox.net\n\n    Result: OK\n"},{"id":"60287","messageId":"1195469295-5774-1-git-send-email-ask@develooper.com","threadId":"10833","inReplyTo":"7voddqodhs.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] Don't print an empty Cc header in SMTP mode when there's no cc recipient defined","fromName":"Ask Bjørn Hansen","fromEmail":"ask@develooper.com","sentAt":"2007-11-19T10:48:14Z","receivedAt":"2007-11-19T10:48:14Z","isPatch":true,"sender":{"key":"ask@develooper.com","avatar":"https://gravatar.com/avatar/05ce68433216df7d04bb0d82b7d93b11957e2137e6ed23c4b5bc061d78635f2f?d=mp&s=160"},"body":"\nSigned-off-by: Ask Bjørn Hansen <ask@develooper.com>\n---\n\nThere's some duplicate code between \"what we do for sendmail\"\nand \"what we do for SMTP\" paths that should be fixed - this doesn't\ndo that, it only makes the SMTP path skip empty Cc lines...\n\n git-send-email.perl |    6 +++++-\n 1 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex fd0a4ad..65620ab 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -651,7 +651,11 @@ X-Mailer: git-send-email $gitversion\n \t\t} else {\n \t\t\tprint \"Sendmail: $smtp_server \".join(' ',@sendmail_parameters).\"\\n\";\n \t\t}\n-\t\tprint \"From: $sanitized_sender\\nSubject: $subject\\nCc: $cc\\nTo: $to\\n\\n\";\n+\t\tprint \"From: $sanitized_sender\\n\"\n+\t\t     . \"Subject: $subject\\n\"\n+\t\t     . ($cc ? \"Cc: $cc\\n\" : \"\")\n+\t\t     . \"To: $to\\n\"\n+\t\t     . \"\\n\";\n \t\tif ($smtp) {\n \t\t\tprint \"Result: \", $smtp->code, ' ',\n \t\t\t\t($smtp->message =~ /\\n([^\\n]+\\n)$/s), \"\\n\";\n-- \n1.5.3.5.561.g140d\n"},{"id":"60351","messageId":"327906.50991.qm@web52410.mail.re2.yahoo.com","threadId":"10833","inReplyTo":"7voddqodhs.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v2] git-send-email: show all headers when sending mail","fromName":"David D. Kilzer","fromEmail":"ddkilzer@kilzer.net","sentAt":"2007-11-19T18:50:27Z","receivedAt":"2007-11-19T18:50:27Z","isPatch":true,"sender":{"key":"ddkilzer@kilzer.net","avatar":"https://avatars.githubusercontent.com/u/263571?v=4"},"body":"I can't seem to reproduce this.  Could you send me (off-list)\n0001-branch-contains.txt and any relevant config bits?\n\nDave\n\n\nJunio C Hamano <gitster@pobox.com> wrote:\n\n> Thanks.  Looks nice and obviously correct.\n> \n> One thing that has been bugging me for a long time now stands\n> out like a sore thumb much more: empty Cc: is shown.\n> \n>     $ git-send-email --dry-run --to=junio@my.isp.net 0001-branch-contains.txt\n>     Who should the emails appear to be from? [Junio C Hamano\n> <gitster@pobox.com>]\n>     Emails will be sent from: Junio C Hamano <gitster@pobox.com>\n>     Message-ID to be used as In-Reply-To for the first email?\n>     0001-branch-contains.txt\n>     Dry-OK. Log says:\n>     Date: Mon, 19 Nov 2007 00:10:04 -0800\n>     Server: my.isp.net\n>     MAIL FROM:<gitster@pobox.com>\n>     RCPT TO:<junio@my.isp.net>\n>     From: Junio C Hamano <gitster@pobox.com>\n>     Subject: [PATCH] branch --contains=<commit>\n>     Cc:\n>     To: junkio@cox.net\n> \n>     Result: OK\n"},{"id":"60385","messageId":"9B3C2B93-5C6D-42B9-9063-3DF911DF7D8F@develooper.com","threadId":"10833","inReplyTo":"327906.50991.qm@web52410.mail.re2.yahoo.com","subject":"Re: [PATCH v2] git-send-email: show all headers when sending mail","fromName":"Ask Bjørn Hansen","fromEmail":"ask@develooper.com","sentAt":"2007-11-20T01:53:57Z","receivedAt":"2007-11-20T01:53:57Z","isPatch":true,"sender":{"key":"ask@develooper.com","avatar":"https://gravatar.com/avatar/05ce68433216df7d04bb0d82b7d93b11957e2137e6ed23c4b5bc061d78635f2f?d=mp&s=160"},"body":"\nOn Nov 19, 2007, at 10:50, David D. Kilzer wrote:\n\n> Junio C Hamano <gitster@pobox.com> wrote:\n>\n>> Thanks.  Looks nice and obviously correct.\n>>\n>> One thing that has been bugging me for a long time now stands\n>> out like a sore thumb much more: empty Cc: is shown.\n>\n> I can't seem to reproduce this.  Could you send me (off-list)\n> 0001-branch-contains.txt and any relevant config bits?\n\nYou need to make git-send-email not have an implicit Cc (from signed- \noff-by or some such), then it'll appear.\n\nI sent a patch yesterday for it,\n\nSubject: [PATCH] Don't print an empty Cc header in SMTP mode when  \nthere's no cc recipient defined\nMessage-Id: <1195469295-5774-1-git-send-email-ask@develooper.com>\n\n\n\n  - ask\n\n-- \nhttp://develooper.com/ - http://askask.com/\n"}]}