From ce903018f1ed0283fdaa3de1ec3ad29fccf25c96 Mon Sep 17 00:00:00 2001 From: Ryan Anderson Date: Mon, 29 May 2006 12:30:15 -0700 Subject: Add a basic test case for git send-email, and fix some real bugs discovered. Signed-off-by: Ryan Anderson Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 t/t9001-send-email.sh (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh new file mode 100755 index 0000000000..276cbac3ba --- /dev/null +++ b/t/t9001-send-email.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +test_description='git-send-email' +. ./test-lib.sh + +PROG='git send-email' +test_expect_success \ + 'prepare reference tree' \ + 'echo "1A quick brown fox jumps over the" >file && + echo "lazy dog" >>file && + git add file + GIT_AUTHOR_NAME="A" git commit -a -m "Initial."' + +test_expect_success \ + 'Setup helper tool' \ + 'echo "#!/bin/sh" > fake.sendmail + echo "shift" >> fake.sendmail + echo "echo \"\$*\" > commandline" >> fake.sendmail + echo "cat > msgtxt" >> fake.sendmail + chmod +x ./fake.sendmail + git add fake.sendmail + GIT_AUTHOR_NAME="A" git commit -a -m "Second."' + +test_expect_success \ + 'Extract patches and send' \ + 'git format-patch -n HEAD^1 + git send-email -from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" ./0001*txt' + +test_expect_success \ + 'Verify commandline' \ + 'cline=$(cat commandline) + [ "$cline" == "nobody@example.com author@example.com" ]' + +test_done -- cgit v1.2.3 From 2186d566a6c2dfb2f168ae608bbb2e0e77122d7e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 29 May 2006 23:53:13 -0700 Subject: send-email: do not pass bogus address to local sendmail binary This makes t9001 test happy. Also fixes the warning on uninitialized $references variable again. Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 276cbac3ba..a61da1efbd 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -13,10 +13,14 @@ test_expect_success \ test_expect_success \ 'Setup helper tool' \ - 'echo "#!/bin/sh" > fake.sendmail - echo "shift" >> fake.sendmail - echo "echo \"\$*\" > commandline" >> fake.sendmail - echo "cat > msgtxt" >> fake.sendmail + '(echo "#!/bin/sh" + echo shift + echo for a + echo do + echo " echo \"!\$a!\"" + echo "done >commandline" + echo "cat > msgtxt" + ) >fake.sendmail chmod +x ./fake.sendmail git add fake.sendmail GIT_AUTHOR_NAME="A" git commit -a -m "Second."' @@ -26,9 +30,12 @@ test_expect_success \ 'git format-patch -n HEAD^1 git send-email -from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" ./0001*txt' +cat >expected <<\EOF +!nobody@example.com! +!author@example.com! +EOF test_expect_success \ 'Verify commandline' \ - 'cline=$(cat commandline) - [ "$cline" == "nobody@example.com author@example.com" ]' + 'diff commandline expected' test_done -- cgit v1.2.3 From 280242d1cc1fe2847f649d2f16b273e168fcbc48 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 2 Jul 2006 16:03:59 -0700 Subject: send-email: do not barf when Term::ReadLine does not like your terminal As long as we do not need to readline from the terminal, we should not barf when starting up the program. Without this patch, t9001 test on Cygwin occasionally died with the following error message: Unable to get Terminal Size. The TIOCGWINSZ ioctl didn't work. The COLUMNS and LINES environment variables didn't work. The resize program didn't work. at /usr/lib/perl5/vendor_perl/5.8/cygwin/Term/ReadKey.pm line 362. Compilation failed in require at /usr/lib/perl5/vendor_perl/5.8/Term/ReadLine/Perl.pm line 58. Acked-by: Ryan Anderson Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index a61da1efbd..e9ea33c18d 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -25,10 +25,13 @@ test_expect_success \ git add fake.sendmail GIT_AUTHOR_NAME="A" git commit -a -m "Second."' -test_expect_success \ - 'Extract patches and send' \ - 'git format-patch -n HEAD^1 - git send-email -from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" ./0001*txt' +test_expect_success 'Extract patches' ' + patches=`git format-patch -n HEAD^1` +' + +test_expect_success 'Send patches' ' + git send-email -from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors +' cat >expected <<\EOF !nobody@example.com! -- cgit v1.2.3 From 85d81a757e495fe74d8a403f813d3748e832c112 Mon Sep 17 00:00:00 2001 From: Glenn Rempe Date: Mon, 24 Sep 2007 13:33:38 -0700 Subject: Fixed minor typo in t/t9001-send-email.sh test command line. The git-send-email command line in the test was missing a single hyphen. Signed-off-by: Glenn Rempe Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index e9ea33c18d..83f9470202 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -30,7 +30,7 @@ test_expect_success 'Extract patches' ' ' test_expect_success 'Send patches' ' - git send-email -from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors + git send-email --from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors ' cat >expected <<\EOF -- cgit v1.2.3 From b7f30e0a972ab90a0f7720a7d6411822eb796ea3 Mon Sep 17 00:00:00 2001 From: "David D. Kilzer" Date: Sun, 18 Nov 2007 20:14:55 -0800 Subject: 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 Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 83f9470202..659f9c758f 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -41,4 +41,41 @@ test_expect_success \ 'Verify commandline' \ 'diff commandline expected' +cat >expected-show-all-headers <<\EOF +0001-Second.patch +(mbox) Adding cc: A from line 'From: A ' +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM: +RCPT TO:,,, +From: Example +To: to@example.com +Cc: cc@example.com, A +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING +In-Reply-To: +References: + +Result: OK +EOF + +test_expect_success 'Show all headers' ' + git send-email \ + --dry-run \ + --from="Example " \ + --to=to@example.com \ + --cc=cc@example.com \ + --bcc=bcc@example.com \ + --in-reply-to="" \ + --smtp-server relay.example.com \ + $patches | + sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ + -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ + -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ + >actual-show-all-headers && + diff -u expected-show-all-headers actual-show-all-headers +' + test_done -- cgit v1.2.3 From 747bbff9b9583642cd8702b7b559757a6960df00 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 18 Jan 2008 09:19:48 -0500 Subject: send-email: validate patches before sending anything We try to catch errors early so that we don't end up sending half of a broken patch series. Right now the only validation is checking that line-lengths are under the SMTP-mandated limit of 998. The validation parsing is very crude (it just checks each line length without understanding the mailbox format) but should work fine for this simple check. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 659f9c758f..1c4181022f 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -78,4 +78,24 @@ test_expect_success 'Show all headers' ' diff -u expected-show-all-headers actual-show-all-headers ' +z8=zzzzzzzz +z64=$z8$z8$z8$z8$z8$z8$z8$z8 +z512=$z64$z64$z64$z64$z64$z64$z64$z64 +test_expect_success 'reject long lines' ' + rm -f commandline && + cp $patches longline.patch && + echo $z512$z512 >>longline.patch && + ! git send-email \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches longline.patch \ + 2>errors && + grep longline.patch errors +' + +test_expect_success 'no patch was sent' ' + ! test -e commandline +' + test_done -- cgit v1.2.3 From c764a0c2b6d8c94d90c95fa8170970c85a40665c Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 18 Jan 2008 09:20:10 -0500 Subject: send-email: add no-validate option Since we are now sanity-checking the contents of patches and refusing to send ones with long lines, this knob provides a way for the user to override the new behavior (if, e.g., he knows his SMTP path will handle it). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 1c4181022f..4f6822f2c5 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -98,4 +98,14 @@ test_expect_success 'no patch was sent' ' ! test -e commandline ' +test_expect_success 'allow long lines with --no-validate' ' + git send-email \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + --no-validate \ + $patches longline.patch \ + 2>errors +' + test_done -- cgit v1.2.3 From c0d4528119c237a9939175adcf0113ee43a20438 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 21 Jan 2008 22:23:53 -0500 Subject: t9001: add missing && operators The exit value of some commands was not being used for the test output. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 4f6822f2c5..08f7c3d8d7 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -8,7 +8,7 @@ test_expect_success \ 'prepare reference tree' \ 'echo "1A quick brown fox jumps over the" >file && echo "lazy dog" >>file && - git add file + git add file && GIT_AUTHOR_NAME="A" git commit -a -m "Initial."' test_expect_success \ @@ -20,9 +20,9 @@ test_expect_success \ echo " echo \"!\$a!\"" echo "done >commandline" echo "cat > msgtxt" - ) >fake.sendmail - chmod +x ./fake.sendmail - git add fake.sendmail + ) >fake.sendmail && + chmod +x ./fake.sendmail && + git add fake.sendmail && GIT_AUTHOR_NAME="A" git commit -a -m "Second."' test_expect_success 'Extract patches' ' -- cgit v1.2.3 From 0fb7fc751d29cd1099556f71fc7c08158a6a78bc Mon Sep 17 00:00:00 2001 From: Jay Soffian Date: Thu, 21 Feb 2008 19:16:04 -0500 Subject: send-email: fix In-Reply-To regression Fix a regression introduced by 1ca3d6e (send-email: squelch warning due to comparing undefined $_ to "") where if the user was prompted for an initial In-Reply-To and didn't provide one, messages would be sent out with an invalid In-Reply-To of "<>" Also add test cases for the regression and the fix. A small modification was needed to allow send-email to take its replies from stdin if the environment variable GIT_SEND_EMAIL_NOTTY is set. Signed-off-by: Jay Soffian Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 08f7c3d8d7..2efaed441d 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -108,4 +108,25 @@ test_expect_success 'allow long lines with --no-validate' ' 2>errors ' +test_expect_success 'Invalid In-Reply-To' ' + git send-email \ + --from="Example " \ + --to=nobody@example.com \ + --in-reply-to=" " \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches + 2>errors + ! grep "^In-Reply-To: < *>" msgtxt +' + +test_expect_success 'Valid In-Reply-To when prompting' ' + (echo "From Example " + echo "To Example " + echo "" + ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches 2>errors && + ! grep "^In-Reply-To: < *>" msgtxt +' + test_done -- cgit v1.2.3 From 6d34a2bad11f241e56423511d4a0d62a1f378668 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sun, 24 Feb 2008 16:03:52 -0500 Subject: t9001: enhance fake sendmail test harness Previously, the fake.sendmail test harness would write its output to a hardcoded file, allowing only a single message to be tested. Instead, let's have it save the messages for all of its invocations so that we can see which messages were sent, and in which order. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 2efaed441d..4975048007 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -15,16 +15,22 @@ test_expect_success \ 'Setup helper tool' \ '(echo "#!/bin/sh" echo shift + echo output=1 + echo "while test -f commandline\$output; do output=\$((\$output+1)); done" echo for a echo do echo " echo \"!\$a!\"" - echo "done >commandline" - echo "cat > msgtxt" + echo "done >commandline\$output" + echo "cat > msgtxt\$output" ) >fake.sendmail && chmod +x ./fake.sendmail && git add fake.sendmail && GIT_AUTHOR_NAME="A" git commit -a -m "Second."' +clean_fake_sendmail() { + rm -f commandline* msgtxt* +} + test_expect_success 'Extract patches' ' patches=`git format-patch -n HEAD^1` ' @@ -39,7 +45,7 @@ cat >expected <<\EOF EOF test_expect_success \ 'Verify commandline' \ - 'diff commandline expected' + 'diff commandline1 expected' cat >expected-show-all-headers <<\EOF 0001-Second.patch @@ -82,7 +88,7 @@ z8=zzzzzzzz z64=$z8$z8$z8$z8$z8$z8$z8$z8 z512=$z64$z64$z64$z64$z64$z64$z64$z64 test_expect_success 'reject long lines' ' - rm -f commandline && + clean_fake_sendmail && cp $patches longline.patch && echo $z512$z512 >>longline.patch && ! git send-email \ @@ -95,7 +101,7 @@ test_expect_success 'reject long lines' ' ' test_expect_success 'no patch was sent' ' - ! test -e commandline + ! test -e commandline1 ' test_expect_success 'allow long lines with --no-validate' ' @@ -109,6 +115,7 @@ test_expect_success 'allow long lines with --no-validate' ' ' test_expect_success 'Invalid In-Reply-To' ' + clean_fake_sendmail && git send-email \ --from="Example " \ --to=nobody@example.com \ @@ -116,17 +123,18 @@ test_expect_success 'Invalid In-Reply-To' ' --smtp-server="$(pwd)/fake.sendmail" \ $patches 2>errors - ! grep "^In-Reply-To: < *>" msgtxt + ! grep "^In-Reply-To: < *>" msgtxt1 ' test_expect_success 'Valid In-Reply-To when prompting' ' + clean_fake_sendmail && (echo "From Example " echo "To Example " echo "" ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \ --smtp-server="$(pwd)/fake.sendmail" \ $patches 2>errors && - ! grep "^In-Reply-To: < *>" msgtxt + ! grep "^In-Reply-To: < *>" msgtxt1 ' test_done -- cgit v1.2.3 From 8a8bf4690e20a545561249a9b393c1ef3239c03d Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sun, 24 Feb 2008 16:04:14 -0500 Subject: send-email: test compose functionality This is just a basic sanity check that --compose works at all. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 4975048007..cbbfa9cb49 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -137,4 +137,33 @@ test_expect_success 'Valid In-Reply-To when prompting' ' ! grep "^In-Reply-To: < *>" msgtxt1 ' +test_expect_success 'setup fake editor' ' + (echo "#!/bin/sh" && + echo "echo fake edit >>\$1" + ) >fake-editor && + chmod +x fake-editor +' + +test_expect_success '--compose works' ' + clean_fake_sendmail && + echo y | \ + GIT_EDITOR=$(pwd)/fake-editor \ + GIT_SEND_EMAIL_NOTTY=1 \ + git send-email \ + --compose --subject foo \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches \ + 2>errors +' + +test_expect_success 'first message is compose text' ' + grep "^fake edit" msgtxt1 +' + +test_expect_success 'second message is patch' ' + grep "Subject:.*Second" msgtxt2 +' + test_done -- cgit v1.2.3 From 82ebb0b6ec7470cab96a013d3d719c109003ef83 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 12 Mar 2008 17:36:36 -0400 Subject: add test_cmp function for test scripts Many scripts compare actual and expected output using "diff -u". This is nicer than "cmp" because the output shows how the two differ. However, not all versions of diff understand -u, leading to unnecessary test failure. This adds a test_cmp function to the test scripts and switches all "diff -u" invocations to use it. The function uses the contents of "$GIT_TEST_CMP" to compare its arguments; the default is "diff -u". On systems with a less-capable diff, you can do: GIT_TEST_CMP=cmp make test Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index cbbfa9cb49..c0973b4e6e 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -81,7 +81,7 @@ test_expect_success 'Show all headers' ' -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ >actual-show-all-headers && - diff -u expected-show-all-headers actual-show-all-headers + test_cmp expected-show-all-headers actual-show-all-headers ' z8=zzzzzzzz -- cgit v1.2.3 From 33c592ddd55faa96d0f425710da5742339796b89 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 29 Apr 2008 12:56:47 +0200 Subject: Add tests for sendemail.cc configuration variable Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index c0973b4e6e..af655cf526 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -166,4 +166,70 @@ test_expect_success 'second message is patch' ' grep "Subject:.*Second" msgtxt2 ' +cat >expected-show-all-headers <<\EOF +0001-Second.patch +(mbox) Adding cc: A from line 'From: A ' +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM: +RCPT TO:,, +From: Example +To: to@example.com +Cc: cc@example.com, A +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING + +Result: OK +EOF + +test_expect_success 'sendemail.cc set' ' + git config sendemail.cc cc@example.com && + git send-email \ + --dry-run \ + --from="Example " \ + --to=to@example.com \ + --smtp-server relay.example.com \ + $patches | + sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ + -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ + -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ + >actual-show-all-headers && + test_cmp expected-show-all-headers actual-show-all-headers +' + +cat >expected-show-all-headers <<\EOF +0001-Second.patch +(mbox) Adding cc: A from line 'From: A ' +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM: +RCPT TO:, +From: Example +To: to@example.com +Cc: A +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING + +Result: OK +EOF + +test_expect_success 'sendemail.cc unset' ' + git config --unset sendemail.cc && + git send-email \ + --dry-run \ + --from="Example " \ + --to=to@example.com \ + --smtp-server relay.example.com \ + $patches | + sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ + -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ + -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ + >actual-show-all-headers && + test_cmp expected-show-all-headers actual-show-all-headers +' + test_done -- cgit v1.2.3 From 065096c2b558af80e670299621ff3ddc6839954c Mon Sep 17 00:00:00 2001 From: Bryan Donlan Date: Sun, 4 May 2008 01:37:53 -0400 Subject: git-send-email.perl: Handle shell metacharacters in $EDITOR properly This fixes the git-send-perl semantics for launching an editor when $GIT_EDITOR (or friends) contains shell metacharacters to match launch_editor() in builtin-tag.c. If we use the current approach (sh -c '$0 $@' "$EDITOR" files ...), we see it fails when $EDITOR has shell metacharacters: $ sh -x -c '$0 $@' "$VISUAL" "foo" + "$FAKE_EDITOR" foo "$FAKE_EDITOR": 1: "$FAKE_EDITOR": not found Whereas builtin-tag.c will invoke sh -c "$EDITOR \"$@\"". Thus, this patch changes git-send-email.perl to use the same method as the C utilities, and additionally updates t/t9001-send-email.sh to test for this bug. Signed-off-by: Bryan Donlan Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index c0973b4e6e..030f66cb7c 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -139,15 +139,19 @@ test_expect_success 'Valid In-Reply-To when prompting' ' test_expect_success 'setup fake editor' ' (echo "#!/bin/sh" && - echo "echo fake edit >>\$1" + echo "echo fake edit >>\"\$1\"" ) >fake-editor && chmod +x fake-editor ' +FAKE_EDITOR="$(pwd)/fake-editor" +export FAKE_EDITOR +GIT_EDITOR='"$FAKE_EDITOR"' +export GIT_EDITOR + test_expect_success '--compose works' ' clean_fake_sendmail && echo y | \ - GIT_EDITOR=$(pwd)/fake-editor \ GIT_SEND_EMAIL_NOTTY=1 \ git send-email \ --compose --subject foo \ -- cgit v1.2.3 From 7f0475c308625fb9e4cbbad8dc665983571cc5cf Mon Sep 17 00:00:00 2001 From: Bryan Donlan Date: Sun, 4 May 2008 01:37:55 -0400 Subject: Use test_set_editor in t9001-send-email.sh Signed-off-by: Bryan Donlan Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 030f66cb7c..0a65785573 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -144,10 +144,7 @@ test_expect_success 'setup fake editor' ' chmod +x fake-editor ' -FAKE_EDITOR="$(pwd)/fake-editor" -export FAKE_EDITOR -GIT_EDITOR='"$FAKE_EDITOR"' -export GIT_EDITOR +test_set_editor "$(pwd)/fake-editor" test_expect_success '--compose works' ' clean_fake_sendmail && -- cgit v1.2.3 From 0706bd19ef9b41e7519df2c73796ef93484272fd Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 28 Mar 2008 17:28:33 -0400 Subject: send-email: specify content-type of --compose body If the compose message contains non-ascii characters, then we assume it is in utf-8 and include the appropriate MIME headers. If the user has already included a MIME-Version header, then we assume they know what they are doing and don't add any headers. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index c0973b4e6e..e222c49320 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -166,4 +166,48 @@ test_expect_success 'second message is patch' ' grep "Subject:.*Second" msgtxt2 ' +test_expect_success '--compose adds MIME for utf8 body' ' + clean_fake_sendmail && + (echo "#!/bin/sh" && + echo "echo utf8 body: àéìöú >>\$1" + ) >fake-editor-utf8 && + chmod +x fake-editor-utf8 && + echo y | \ + GIT_EDITOR=$(pwd)/fake-editor-utf8 \ + GIT_SEND_EMAIL_NOTTY=1 \ + git send-email \ + --compose --subject foo \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches && + grep "^utf8 body" msgtxt1 && + grep "^Content-Type: text/plain; charset=utf-8" msgtxt1 +' + +test_expect_success '--compose respects user mime type' ' + clean_fake_sendmail && + (echo "#!/bin/sh" && + echo "(echo MIME-Version: 1.0" + echo " echo Content-Type: text/plain\\; charset=iso-8859-1" + echo " echo Content-Transfer-Encoding: 8bit" + echo " echo Subject: foo" + echo " echo " + echo " echo utf8 body: àéìöú) >\$1" + ) >fake-editor-utf8-mime && + chmod +x fake-editor-utf8-mime && + echo y | \ + GIT_EDITOR=$(pwd)/fake-editor-utf8-mime \ + GIT_SEND_EMAIL_NOTTY=1 \ + git send-email \ + --compose --subject foo \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches && + grep "^utf8 body" msgtxt1 && + grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 && + ! grep "^Content-Type: text/plain; charset=utf-8" msgtxt1 +' + test_done -- cgit v1.2.3 From d54eaaa268eb79a51ac11bfa8bbfb456c0b1a1fa Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 28 Mar 2008 17:29:01 -0400 Subject: send-email: rfc2047-quote subject lines with non-ascii characters We always use 'utf-8' as the encoding, since we currently have no way of getting the information from the user. This also refactors the quoting of recipient names, since both processes can share the rfc2047 quoting code. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index e222c49320..a4bcd282b6 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -210,4 +210,19 @@ test_expect_success '--compose respects user mime type' ' ! grep "^Content-Type: text/plain; charset=utf-8" msgtxt1 ' +test_expect_success '--compose adds MIME for utf8 subject' ' + clean_fake_sendmail && + echo y | \ + GIT_EDITOR=$(pwd)/fake-editor \ + GIT_SEND_EMAIL_NOTTY=1 \ + git send-email \ + --compose --subject utf8-sübjëct \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches && + grep "^fake edit" msgtxt1 && + grep "^Subject: =?utf-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 +' + test_done -- cgit v1.2.3 From d492b31cafe9aa5ce001b1d48815f4c0bb40d01a Mon Sep 17 00:00:00 2001 From: Stephan Beyer Date: Sat, 12 Jul 2008 17:47:52 +0200 Subject: t/: Use "test_must_fail git" instead of "! git" This patch changes every occurrence of "! git" -- with the meaning that a git call has to gracefully fail -- into "test_must_fail git". This is useful to - make sure the test does not fail because of a signal, e.g. SIGSEGV, and - advertise the use of "test_must_fail" for new tests. Signed-off-by: Stephan Beyer Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 3e4eb63f1c..de5b9802c9 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -91,7 +91,7 @@ test_expect_success 'reject long lines' ' clean_fake_sendmail && cp $patches longline.patch && echo $z512$z512 >>longline.patch && - ! git send-email \ + test_must_fail git send-email \ --from="Example " \ --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ -- cgit v1.2.3 From bb3e4f03be815067814624b1e0b2f6de054519cd Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 17 Jul 2008 23:18:43 -0700 Subject: t9001 (send-email): Do not use hardcoded /bin/sh in test Scriptlets used form inside this test began with hardcoded "#!/bin/sh". By setting SHELL_PATH the user is already telling us that what the vendor has in /bin/sh isn't POSIX enough, and we really should try to honor that request. Originally noticed by SungHyun Nam who later tested this patch and verified that it fixes the issue on Solaris 9. Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index de5b9802c9..1c857cf4ab 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -13,7 +13,7 @@ test_expect_success \ test_expect_success \ 'Setup helper tool' \ - '(echo "#!/bin/sh" + '(echo "#!$SHELL_PATH" echo shift echo output=1 echo "while test -f commandline\$output; do output=\$((\$output+1)); done" @@ -138,7 +138,7 @@ test_expect_success 'Valid In-Reply-To when prompting' ' ' test_expect_success 'setup fake editor' ' - (echo "#!/bin/sh" && + (echo "#!$SHELL_PATH" && echo "echo fake edit >>\"\$1\"" ) >fake-editor && chmod +x fake-editor @@ -235,7 +235,7 @@ test_expect_success 'sendemail.cc unset' ' test_expect_success '--compose adds MIME for utf8 body' ' clean_fake_sendmail && - (echo "#!/bin/sh" && + (echo "#!$SHELL_PATH" && echo "echo utf8 body: àéìöú >>\"\$1\"" ) >fake-editor-utf8 && chmod +x fake-editor-utf8 && @@ -254,7 +254,7 @@ test_expect_success '--compose adds MIME for utf8 body' ' test_expect_success '--compose respects user mime type' ' clean_fake_sendmail && - (echo "#!/bin/sh" && + (echo "#!$SHELL_PATH" && echo "(echo MIME-Version: 1.0" echo " echo Content-Type: text/plain\\; charset=iso-8859-1" echo " echo Content-Transfer-Encoding: 8bit" -- cgit v1.2.3 From 47a528ad24185133867ebb5bb7692db2cb8bef39 Mon Sep 17 00:00:00 2001 From: Nanako Shiraishi Date: Wed, 3 Sep 2008 17:59:33 +0900 Subject: tests: use "git xyzzy" form (t7200 - t9001) Converts tests between t7201-t9001. Signed-off-by: Nanako Shiraishi Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 1c857cf4ab..d098a01ba3 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='git-send-email' +test_description='git send-email' . ./test-lib.sh PROG='git send-email' -- cgit v1.2.3 From 3fee1fe87144360a1913eab86af9ad136c810076 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Fri, 10 Oct 2008 19:21:34 -0500 Subject: t9001: use older Getopt::Long boolean prefix '--no' rather than '--no-' Since dbf5e1e9, the '--no-validate' option is a Getopt::Long boolean option. The '--no-' prefix (as in --no-validate) for boolean options is not supported in Getopt::Long version 2.32 which was released with Perl 5.8.0. This version only supports '--no' as in '--novalidate'. More recent versions of Getopt::Long, such as version 2.34, support either prefix. So use the older form in the tests. Signed-off-by: Brandon Casey Signed-off-by: Shawn O. Pearce --- t/t9001-send-email.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index d098a01ba3..561ae7d0a6 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -109,7 +109,7 @@ test_expect_success 'allow long lines with --no-validate' ' --from="Example " \ --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ - --no-validate \ + --novalidate \ $patches longline.patch \ 2>errors ' -- cgit v1.2.3 From 5df9fcf695a0ba85abfeed68efb3b1c5890068d6 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Tue, 11 Nov 2008 00:54:00 +0100 Subject: git send-email: interpret unknown files as revision lists Filter out all the arguments git-send-email doesn't like to a git format-patch command, that dumps its content to a safe directory. Barf when a file/revision conflict occurs, allow it to be overriden --[no-]format-patch. Signed-off-by: Pierre Habouzit Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 561ae7d0a6..617e97d963 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -292,4 +292,12 @@ test_expect_success '--compose adds MIME for utf8 subject' ' grep "^Subject: =?utf-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 ' +test_expect_success 'detects ambiguous reference/file conflict' ' + echo master > master && + git add master && + git commit -m"add master" && + test_must_fail git send-email --dry-run master 2>errors && + grep disambiguate errors +' + test_done -- cgit v1.2.3 From 69f4ce553708ee5ce474faaa9c45312f38aad563 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 30 Nov 2008 22:38:20 -0800 Subject: send-email: do not reverse the command line arguments The loop picks elements from @ARGV one by one, sifts them into arguments meant for format-patch and the script itself, and pushes them to @files and @rev_list_opts arrays. Pick elements from @ARGV starting at the beginning using shift, instead of at the end using pop, as push appends them to the end of the array. Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 617e97d963..cb3d183770 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -300,4 +300,17 @@ test_expect_success 'detects ambiguous reference/file conflict' ' grep disambiguate errors ' +test_expect_success 'feed two files' ' + rm -fr outdir && + git format-patch -2 -o outdir && + GIT_SEND_EMAIL_NOTTY=1 git send-email \ + --dry-run \ + --from="Example " \ + --to=nobody@example.com \ + outdir/000?-*.patch 2>errors >out && + grep "^Subject: " out >subjects && + test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." && + test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master" +' + test_done -- cgit v1.2.3 From 5012699d9840fe34fe0838ea0d529c2f32f76b82 Mon Sep 17 00:00:00 2001 From: Jay Soffian Date: Sat, 14 Feb 2009 23:32:14 -0500 Subject: send-email: handle multiple Cc addresses when reading mbox message When git format-patch is given multiple --cc arguments, it generates a Cc header that looks like: Cc: first@example.com, second@example.com, third@example.com Before this commit, send-email was unable to handle such a message as it did not handle folded header lines, nor multiple recipients in a Cc line. This patch: - Unfolds header lines by pre-processing the header before extracting any of its fields. - Handles Cc lines with multiple recipients. - Adds use of Mail::Address if available for splitting Cc line and the "Who should the emails be sent to?" prompt", with fall back to existing split_addrs() function. - Tests the new functionality and adds two tests for detecting whether "From:" appears correctly in message body when patch author differs from patch sender. Signed-off-by: Jay Soffian Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index cb3d183770..63ab88bfc8 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -32,7 +32,7 @@ clean_fake_sendmail() { } test_expect_success 'Extract patches' ' - patches=`git format-patch -n HEAD^1` + patches=`git format-patch --cc="One " --cc=two@example.com -n HEAD^1` ' test_expect_success 'Send patches' ' @@ -42,6 +42,8 @@ test_expect_success 'Send patches' ' cat >expected <<\EOF !nobody@example.com! !author@example.com! +!one@example.com! +!two@example.com! EOF test_expect_success \ 'Verify commandline' \ @@ -50,13 +52,15 @@ test_expect_success \ cat >expected-show-all-headers <<\EOF 0001-Second.patch (mbox) Adding cc: A from line 'From: A ' +(mbox) Adding cc: One from line 'Cc: One , two@example.com' +(mbox) Adding cc: two@example.com from line 'Cc: One , two@example.com' Dry-OK. Log says: Server: relay.example.com MAIL FROM: -RCPT TO:,,, +RCPT TO:,,,,, From: Example To: to@example.com -Cc: cc@example.com, A +Cc: cc@example.com, A , One , two@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -104,6 +108,28 @@ test_expect_success 'no patch was sent' ' ! test -e commandline1 ' +test_expect_success 'Author From: in message body' ' + clean_fake_sendmail && + git send-email \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches && + sed "1,/^$/d" < msgtxt1 > msgbody1 + grep "From: A " msgbody1 +' + +test_expect_success 'Author From: not in message body' ' + clean_fake_sendmail && + git send-email \ + --from="A " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches && + sed "1,/^$/d" < msgtxt1 > msgbody1 + ! grep "From: A " msgbody1 +' + test_expect_success 'allow long lines with --no-validate' ' git send-email \ --from="Example " \ @@ -170,13 +196,15 @@ test_expect_success 'second message is patch' ' cat >expected-show-all-headers <<\EOF 0001-Second.patch (mbox) Adding cc: A from line 'From: A ' +(mbox) Adding cc: One from line 'Cc: One , two@example.com' +(mbox) Adding cc: two@example.com from line 'Cc: One , two@example.com' Dry-OK. Log says: Server: relay.example.com MAIL FROM: -RCPT TO:,, +RCPT TO:,,,, From: Example To: to@example.com -Cc: cc@example.com, A +Cc: cc@example.com, A , One , two@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -203,13 +231,15 @@ test_expect_success 'sendemail.cc set' ' cat >expected-show-all-headers <<\EOF 0001-Second.patch (mbox) Adding cc: A from line 'From: A ' +(mbox) Adding cc: One from line 'Cc: One , two@example.com' +(mbox) Adding cc: two@example.com from line 'Cc: One , two@example.com' Dry-OK. Log says: Server: relay.example.com MAIL FROM: -RCPT TO:, +RCPT TO:,,, From: Example To: to@example.com -Cc: A +Cc: A , One , two@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING -- cgit v1.2.3 From 3531e2703d8e441bfb4a6765459317b3db3f224c Mon Sep 17 00:00:00 2001 From: Jay Soffian Date: Sat, 14 Feb 2009 23:32:15 -0500 Subject: send-email: --suppress-cc improvements Since 6564828 (git-send-email: Generalize auto-cc recipient mechanism., 2007-12-25) we can suppress automatic Cc generation separately for each of the possible address sources. However, --suppress-cc=sob suppressed both SOB lines and body (but not header) Cc lines, contrary to the name. Change --suppress-cc=sob to mean only SOB lines, and add separate choices 'bodycc' (body Cc lines) and 'body' (both 'sob' and 'bodycc'). The option --no-signed-off-by-cc now acts like --suppress-cc=sob, which is not backwards compatible but matches the name of the option. Also update the documentation and add a few tests. Original patch by me. Revised by Thomas Rast, who contributed the documentation and test updates. Signed-off-by: Jay Soffian Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 150 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 131 insertions(+), 19 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 63ab88bfc8..4df4f965cb 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -32,11 +32,11 @@ clean_fake_sendmail() { } test_expect_success 'Extract patches' ' - patches=`git format-patch --cc="One " --cc=two@example.com -n HEAD^1` + patches=`git format-patch -s --cc="One " --cc=two@example.com -n HEAD^1` ' test_expect_success 'Send patches' ' - git send-email --from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors + git send-email --suppress-cc=sob --from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors ' cat >expected <<\EOF @@ -74,6 +74,7 @@ EOF test_expect_success 'Show all headers' ' git send-email \ --dry-run \ + --suppress-cc=sob \ --from="Example " \ --to=to@example.com \ --cc=cc@example.com \ @@ -193,7 +194,7 @@ test_expect_success 'second message is patch' ' grep "Subject:.*Second" msgtxt2 ' -cat >expected-show-all-headers <<\EOF +cat >expected-suppress-sob <<\EOF 0001-Second.patch (mbox) Adding cc: A from line 'From: A ' (mbox) Adding cc: One from line 'Cc: One , two@example.com' @@ -213,10 +214,10 @@ X-Mailer: X-MAILER-STRING Result: OK EOF -test_expect_success 'sendemail.cc set' ' - git config sendemail.cc cc@example.com && +test_suppression () { git send-email \ --dry-run \ + --suppress-cc=$1 \ --from="Example " \ --to=to@example.com \ --smtp-server relay.example.com \ @@ -224,11 +225,16 @@ test_expect_success 'sendemail.cc set' ' sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ - >actual-show-all-headers && - test_cmp expected-show-all-headers actual-show-all-headers + >actual-suppress-$1 && + test_cmp expected-suppress-$1 actual-suppress-$1 +} + +test_expect_success 'sendemail.cc set' ' + git config sendemail.cc cc@example.com && + test_suppression sob ' -cat >expected-show-all-headers <<\EOF +cat >expected-suppress-sob <<\EOF 0001-Second.patch (mbox) Adding cc: A from line 'From: A ' (mbox) Adding cc: One from line 'Cc: One , two@example.com' @@ -250,17 +256,123 @@ EOF test_expect_success 'sendemail.cc unset' ' git config --unset sendemail.cc && - git send-email \ - --dry-run \ - --from="Example " \ - --to=to@example.com \ - --smtp-server relay.example.com \ - $patches | - sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ - -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ - -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ - >actual-show-all-headers && - test_cmp expected-show-all-headers actual-show-all-headers + test_suppression sob +' + +cat >expected-suppress-all <<\EOF +0001-Second.patch +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM: +RCPT TO: +From: Example +To: to@example.com +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING + +Result: OK +EOF + +test_expect_success '--suppress-cc=all' ' + test_suppression all +' + +cat >expected-suppress-body <<\EOF +0001-Second.patch +(mbox) Adding cc: A from line 'From: A ' +(mbox) Adding cc: One from line 'Cc: One , two@example.com' +(mbox) Adding cc: two@example.com from line 'Cc: One , two@example.com' +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM: +RCPT TO:,,, +From: Example +To: to@example.com +Cc: A , One , two@example.com +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING + +Result: OK +EOF + +test_expect_success '--suppress-cc=body' ' + test_suppression body +' + +cat >expected-suppress-sob <<\EOF +0001-Second.patch +(mbox) Adding cc: A from line 'From: A ' +(mbox) Adding cc: One from line 'Cc: One , two@example.com' +(mbox) Adding cc: two@example.com from line 'Cc: One , two@example.com' +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM: +RCPT TO:,,, +From: Example +To: to@example.com +Cc: A , One , two@example.com +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING + +Result: OK +EOF + +test_expect_success '--suppress-cc=sob' ' + test_suppression sob +' + +cat >expected-suppress-bodycc <<\EOF +0001-Second.patch +(mbox) Adding cc: A from line 'From: A ' +(mbox) Adding cc: One from line 'Cc: One , two@example.com' +(mbox) Adding cc: two@example.com from line 'Cc: One , two@example.com' +(body) Adding cc: C O Mitter from line 'Signed-off-by: C O Mitter ' +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM: +RCPT TO:,,,, +From: Example +To: to@example.com +Cc: A , One , two@example.com, C O Mitter +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING + +Result: OK +EOF + +test_expect_success '--suppress-cc=bodycc' ' + test_suppression bodycc +' + +cat >expected-suppress-cc <<\EOF +0001-Second.patch +(mbox) Adding cc: A from line 'From: A ' +(body) Adding cc: C O Mitter from line 'Signed-off-by: C O Mitter ' +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM: +RCPT TO:,, +From: Example +To: to@example.com +Cc: A , C O Mitter +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING + +Result: OK +EOF + +test_expect_success '--suppress-cc=cc' ' + test_suppression cc ' test_expect_success '--compose adds MIME for utf8 body' ' -- cgit v1.2.3 From c1f2aa45b7bdb82c4378443ae23ad9625e782fe2 Mon Sep 17 00:00:00 2001 From: Jay Soffian Date: Mon, 2 Mar 2009 23:52:18 -0500 Subject: send-email: add --confirm option and configuration setting send-email violates the principle of least surprise by automatically cc'ing additional recipients without confirming this with the user. This patch teaches send-email a --confirm option. It takes the following values: --confirm=always always confirm before sending --confirm=never never confirm before sending --confirm=cc confirm before sending when send-email has automatically added addresses from the patch to the Cc list --confirm=compose confirm before sending the first message when using --compose. (Needed to maintain backwards compatibility with existing behavior.) --confirm=auto 'cc' + 'compose' If sendemail.confirm is unconfigured, the option defaults to 'compose' if any suppress-Cc related options have been used, otherwise it defaults to 'auto'. Unfortunately, it is impossible to introduce this patch such that it helps new users without potentially annoying some existing users. We attempt to mitigate the latter by: * Allowing the user to set 'git config sendemail.confirm never' * Allowing the user to say 'all' after the first prompt to not be prompted on remaining emails during the same invocation. * Telling the user about the 'sendemail.confirm' setting if it is unconfigured whenever we prompt due to Cc before sending. * Only prompting if no --suppress related options have been passed, as using such an option is likely to indicate an experienced send-email user. There is a slight fib in message informing the user of the sendemail.confirm setting and this is intentional. Setting 'auto' differs from leaving sendemail.confirm unset in two ways: 1) 'auto' obviously squelches the informational message; 2) 'auto' prompts when the Cc list has been expanded even in the presence of a --suppress related option, where leaving sendemail.confirm unset does not. This is intentional to keep the message simple, and to avoid adding another sendemail.confirm value ('auto-except-suppress'?). Signed-off-by: Jay Soffian Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 108 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 92 insertions(+), 16 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 4df4f965cb..08d5b91c91 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -35,6 +35,47 @@ test_expect_success 'Extract patches' ' patches=`git format-patch -s --cc="One " --cc=two@example.com -n HEAD^1` ' +# Test no confirm early to ensure remaining tests will not hang +test_no_confirm () { + rm -f no_confirm_okay + echo n | \ + GIT_SEND_EMAIL_NOTTY=1 \ + git send-email \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $@ \ + $patches > stdout && + test_must_fail grep "Send this email" stdout && + > no_confirm_okay +} + +# Exit immediately to prevent hang if a no-confirm test fails +check_no_confirm () { + test -f no_confirm_okay || { + say 'No confirm test failed; skipping remaining tests to prevent hanging' + test_done + } +} + +test_expect_success 'No confirm with --suppress-cc' ' + test_no_confirm --suppress-cc=sob +' +check_no_confirm + +test_expect_success 'No confirm with --confirm=never' ' + test_no_confirm --confirm=never +' +check_no_confirm + +# leave sendemail.confirm set to never after this so that none of the +# remaining tests prompt unintentionally. +test_expect_success 'No confirm with sendemail.confirm=never' ' + git config sendemail.confirm never && + test_no_confirm --compose --subject=foo +' +check_no_confirm + test_expect_success 'Send patches' ' git send-email --suppress-cc=sob --from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors ' @@ -175,15 +216,13 @@ test_set_editor "$(pwd)/fake-editor" test_expect_success '--compose works' ' clean_fake_sendmail && - echo y | \ - GIT_SEND_EMAIL_NOTTY=1 \ - git send-email \ - --compose --subject foo \ - --from="Example " \ - --to=nobody@example.com \ - --smtp-server="$(pwd)/fake.sendmail" \ - $patches \ - 2>errors + git send-email \ + --compose --subject foo \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches \ + 2>errors ' test_expect_success 'first message is compose text' ' @@ -375,15 +414,56 @@ test_expect_success '--suppress-cc=cc' ' test_suppression cc ' +test_confirm () { + echo y | \ + GIT_SEND_EMAIL_NOTTY=1 \ + git send-email \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $@ \ + $patches | grep "Send this email" +} + +test_expect_success '--confirm=always' ' + test_confirm --confirm=always --suppress-cc=all +' + +test_expect_success '--confirm=auto' ' + test_confirm --confirm=auto +' + +test_expect_success '--confirm=cc' ' + test_confirm --confirm=cc +' + +test_expect_success '--confirm=compose' ' + test_confirm --confirm=compose --compose +' + +test_expect_success 'confirm by default (due to cc)' ' + CONFIRM=$(git config --get sendemail.confirm) && + git config --unset sendemail.confirm && + test_confirm && + git config sendemail.confirm $CONFIRM +' + +test_expect_success 'confirm by default (due to --compose)' ' + CONFIRM=$(git config --get sendemail.confirm) && + git config --unset sendemail.confirm && + test_confirm --suppress-cc=all --compose + ret="$?" + git config sendemail.confirm ${CONFIRM:-never} + test $ret = "0" +' + test_expect_success '--compose adds MIME for utf8 body' ' clean_fake_sendmail && (echo "#!$SHELL_PATH" && echo "echo utf8 body: àéìöú >>\"\$1\"" ) >fake-editor-utf8 && chmod +x fake-editor-utf8 && - echo y | \ GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ - GIT_SEND_EMAIL_NOTTY=1 \ git send-email \ --compose --subject foo \ --from="Example " \ @@ -405,9 +485,7 @@ test_expect_success '--compose respects user mime type' ' echo " echo utf8 body: àéìöú) >\"\$1\"" ) >fake-editor-utf8-mime && chmod +x fake-editor-utf8-mime && - echo y | \ GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \ - GIT_SEND_EMAIL_NOTTY=1 \ git send-email \ --compose --subject foo \ --from="Example " \ @@ -421,9 +499,7 @@ test_expect_success '--compose respects user mime type' ' test_expect_success '--compose adds MIME for utf8 subject' ' clean_fake_sendmail && - echo y | \ GIT_EDITOR="\"$(pwd)/fake-editor\"" \ - GIT_SEND_EMAIL_NOTTY=1 \ git send-email \ --compose --subject utf8-sübjëct \ --from="Example " \ @@ -445,7 +521,7 @@ test_expect_success 'detects ambiguous reference/file conflict' ' test_expect_success 'feed two files' ' rm -fr outdir && git format-patch -2 -o outdir && - GIT_SEND_EMAIL_NOTTY=1 git send-email \ + git send-email \ --dry-run \ --from="Example " \ --to=nobody@example.com \ -- cgit v1.2.3 From aaab4b9fb97c1f638d02be7b8c432a4d57f37c56 Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Wed, 11 Mar 2009 23:40:13 +0100 Subject: send-email: test --no-thread --in-reply-to combination 3e0c4ff (send-email: respect in-reply-to regardless of threading, 2009-03-01) fixed the handling of the In-Reply-To header when both --no-thread and --in-reply-to are in effect. Add a test for it. Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index d098a01ba3..a404204b17 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -292,4 +292,15 @@ test_expect_success '--compose adds MIME for utf8 subject' ' grep "^Subject: =?utf-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 ' +test_expect_success 'in-reply-to but no threading' ' + git send-email \ + --dry-run \ + --from="Example " \ + --to=nobody@example.com \ + --in-reply-to="" \ + --no-thread \ + $patches | + grep "In-Reply-To: " +' + test_done -- cgit v1.2.3 From 188c3827c10f5a04588ef7af8b63a7b5dbcc38ed Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 16 Mar 2009 21:18:42 +0100 Subject: Tests: use test_cmp instead of diff where possible Several old tests were written before test_cmp was introduced, convert these to test_cmp. If were are at it, fix the order of the arguments where necessary to make expected come first, so the command shows how the test result deviates from the correct output. Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 08d5b91c91..9523305304 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -88,7 +88,7 @@ cat >expected <<\EOF EOF test_expect_success \ 'Verify commandline' \ - 'diff commandline1 expected' + 'test_cmp expected commandline1' cat >expected-show-all-headers <<\EOF 0001-Second.patch -- cgit v1.2.3 From c18f75a1e96ff0f028edf94effd10cf56d892f22 Mon Sep 17 00:00:00 2001 From: Jay Soffian Date: Sat, 28 Mar 2009 21:39:11 -0400 Subject: send-email: add tests for refactored prompting Signed-off-by: Jay Soffian Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 52 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index e426c96fb7..b4de98c1f2 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -421,8 +421,8 @@ test_confirm () { --from="Example " \ --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ - $@ \ - $patches | grep "Send this email" + $@ $patches > stdout && + grep "Send this email" stdout } test_expect_success '--confirm=always' ' @@ -444,8 +444,10 @@ test_expect_success '--confirm=compose' ' test_expect_success 'confirm by default (due to cc)' ' CONFIRM=$(git config --get sendemail.confirm) && git config --unset sendemail.confirm && - test_confirm && - git config sendemail.confirm $CONFIRM + test_confirm + ret="$?" + git config sendemail.confirm ${CONFIRM:-never} + test $ret = "0" ' test_expect_success 'confirm by default (due to --compose)' ' @@ -457,6 +459,48 @@ test_expect_success 'confirm by default (due to --compose)' ' test $ret = "0" ' +test_expect_success 'confirm detects EOF (inform assumes y)' ' + CONFIRM=$(git config --get sendemail.confirm) && + git config --unset sendemail.confirm && + GIT_SEND_EMAIL_NOTTY=1 \ + git send-email \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches < /dev/null + ret="$?" + git config sendemail.confirm ${CONFIRM:-never} + test $ret = "0" +' + +test_expect_success 'confirm detects EOF (auto causes failure)' ' + CONFIRM=$(git config --get sendemail.confirm) && + git config sendemail.confirm auto && + GIT_SEND_EMAIL_NOTTY=1 \ + test_must_fail git send-email \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches < /dev/null + ret="$?" + git config sendemail.confirm ${CONFIRM:-never} + test $ret = "0" +' + +test_expect_success 'confirm doesnt loop forever' ' + CONFIRM=$(git config --get sendemail.confirm) && + git config sendemail.confirm auto && + yes "bogus" | GIT_SEND_EMAIL_NOTTY=1 \ + test_must_fail git send-email \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches + ret="$?" + git config sendemail.confirm ${CONFIRM:-never} + test $ret = "0" +' + test_expect_success '--compose adds MIME for utf8 body' ' clean_fake_sendmail && (echo "#!$SHELL_PATH" && -- cgit v1.2.3 From dc1460aa8de64f62b4612b6d2546ed7b88050de2 Mon Sep 17 00:00:00 2001 From: Jay Soffian Date: Tue, 31 Mar 2009 12:22:12 -0400 Subject: send-email: ask_default should apply to all emails, not just the first Commit 6e18251 made the "Send this email?" prompt assume yes if confirm = "inform" when it was unable to get a valid response. However, the "yes" assumption only worked correctly for the first email. This commit fixes the issue and confirms the fix by modifying the existing test for the prompt to send multiple emails. Reported by Matthieu Moy Signed-off-by: Jay Soffian Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index b4de98c1f2..195ff8b27b 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -462,12 +462,14 @@ test_expect_success 'confirm by default (due to --compose)' ' test_expect_success 'confirm detects EOF (inform assumes y)' ' CONFIRM=$(git config --get sendemail.confirm) && git config --unset sendemail.confirm && + rm -fr outdir && + git format-patch -2 -o outdir && GIT_SEND_EMAIL_NOTTY=1 \ git send-email \ --from="Example " \ --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ - $patches < /dev/null + outdir/*.patch < /dev/null ret="$?" git config sendemail.confirm ${CONFIRM:-never} test $ret = "0" -- cgit v1.2.3 From 3b3637c3f1d752e6e6d559f30cc53bbec18537ef Mon Sep 17 00:00:00 2001 From: Jay Soffian Date: Tue, 31 Mar 2009 12:22:13 -0400 Subject: send-email: correct two tests which were going interactive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit c18f75a (send-email: add tests for refactored prompting, 2009-03-28) added two tests which went interactive under the dash shell. This patch corrects the issue, reported by Björn Steinbrink. Signed-off-by: Jay Soffian Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 195ff8b27b..84238f7197 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -478,7 +478,8 @@ test_expect_success 'confirm detects EOF (inform assumes y)' ' test_expect_success 'confirm detects EOF (auto causes failure)' ' CONFIRM=$(git config --get sendemail.confirm) && git config sendemail.confirm auto && - GIT_SEND_EMAIL_NOTTY=1 \ + GIT_SEND_EMAIL_NOTTY=1 && + export GIT_SEND_EMAIL_NOTTY && test_must_fail git send-email \ --from="Example " \ --to=nobody@example.com \ @@ -492,8 +493,9 @@ test_expect_success 'confirm detects EOF (auto causes failure)' ' test_expect_success 'confirm doesnt loop forever' ' CONFIRM=$(git config --get sendemail.confirm) && git config sendemail.confirm auto && - yes "bogus" | GIT_SEND_EMAIL_NOTTY=1 \ - test_must_fail git send-email \ + GIT_SEND_EMAIL_NOTTY=1 && + export GIT_SEND_EMAIL_NOTTY && + yes "bogus" | test_must_fail git send-email \ --from="Example " \ --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ -- cgit v1.2.3 From a61c0ffa4474ad6dcec18a5454630371106710f4 Mon Sep 17 00:00:00 2001 From: Jay Soffian Date: Tue, 31 Mar 2009 12:22:14 -0400 Subject: send-email: ensure quoted addresses are rfc2047 encoded sanitize_address assumes that quoted addresses (e.g., "first last" Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 84238f7197..192b97b2d6 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -505,6 +505,19 @@ test_expect_success 'confirm doesnt loop forever' ' test $ret = "0" ' +test_expect_success 'utf8 Cc is rfc2047 encoded' ' + clean_fake_sendmail && + rm -fr outdir && + git format-patch -1 -o outdir --cc="àéìöú " && + git send-email \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + outdir/*.patch && + grep "^Cc:" msgtxt1 | + grep "=?utf-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= " +' + test_expect_success '--compose adds MIME for utf8 body' ' clean_fake_sendmail && (echo "#!$SHELL_PATH" && -- cgit v1.2.3 From 0da43a685aa061f55ed19ea30e1d6220020059a6 Mon Sep 17 00:00:00 2001 From: Jay Soffian Date: Sat, 4 Apr 2009 23:23:21 -0400 Subject: send-email: fix nasty bug in ask() function Commit 6e18251 (send-email: refactor and ensure prompting doesn't loop forever) introduced an ask function, which unfortunately had a nasty bug. This caused it not to accept anything but the default reply to the "Who should the emails appear to be from?" prompt, and nothing but ctrl-d to the "Who should the emails be sent to?" and "Message-ID to be used as In-Reply-To for the first email?" prompts. This commit corrects the issues and adds a test to confirm the fix. Signed-off-by: Jay Soffian Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 192b97b2d6..3c90c4fc1c 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -130,6 +130,19 @@ test_expect_success 'Show all headers' ' test_cmp expected-show-all-headers actual-show-all-headers ' +test_expect_success 'Prompting works' ' + clean_fake_sendmail && + (echo "Example " + echo "to@example.com" + echo "" + ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches \ + 2>errors && + grep "^From: Example $" msgtxt1 && + grep "^To: to@example.com$" msgtxt1 +' + z8=zzzzzzzz z64=$z8$z8$z8$z8$z8$z8$z8$z8 z512=$z64$z64$z64$z64$z64$z64$z64$z64 -- cgit v1.2.3 From 1b19ccd236e3369ac77d74ded207406ffbf9feca Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 3 Apr 2009 15:33:59 -0400 Subject: tests: skip perl tests if NO_PERL is defined These scripts all test git programs that are written in perl, and thus obviously won't work if NO_PERL is defined. We pass NO_PERL to the scripts from the building Makefile via the GIT-BUILD-OPTIONS file. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 3c90c4fc1c..d9420e0a3b 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -3,6 +3,11 @@ test_description='git send-email' . ./test-lib.sh +if ! test_have_prereq PERL; then + say 'skipping git send-email tests, perl not available' + test_done +fi + PROG='git send-email' test_expect_success \ 'prepare reference tree' \ -- cgit v1.2.3 From 84eeb687de7a6c7c42af3fb51b176e0f412a979e Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Fri, 24 Apr 2009 18:18:52 -0500 Subject: t9001: use older Getopt::Long boolean prefix '--no' rather than '--no-' The '--no-thread' option is a Getopt::Long boolean option. The '--no-' prefix (as in --no-thread) for boolean options is not supported in Getopt::Long version 2.32 which was released with Perl 5.8.0. This version only supports '--no' as in '--nothread'. More recent versions of Getopt::Long, such as version 2.34, support either prefix. So use the older form in the tests. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index d9420e0a3b..ce26ea4ac5 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -616,7 +616,7 @@ test_expect_success 'in-reply-to but no threading' ' --from="Example " \ --to=nobody@example.com \ --in-reply-to="" \ - --no-thread \ + --nothread \ $patches | grep "In-Reply-To: " ' -- cgit v1.2.3 From d1fff6fce0e065d1dbb1450146a6f6f79b349229 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Sat, 6 Jun 2009 20:12:31 -0500 Subject: send-email: use UTF-8 rather than utf-8 for consistency The rest of the git source has been converted to use upper-case character encoding names to assist older platforms. The charset attribute of MIME is defined to be case-insensitive, but older platforms may still have an easier time dealing with upper-case rather than lower-case. So do so for send-email too. Update t9001 to handle the changes. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index ce26ea4ac5..2ce24cd5a6 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -533,7 +533,7 @@ test_expect_success 'utf8 Cc is rfc2047 encoded' ' --smtp-server="$(pwd)/fake.sendmail" \ outdir/*.patch && grep "^Cc:" msgtxt1 | - grep "=?utf-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= " + grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= " ' test_expect_success '--compose adds MIME for utf8 body' ' @@ -550,7 +550,7 @@ test_expect_success '--compose adds MIME for utf8 body' ' --smtp-server="$(pwd)/fake.sendmail" \ $patches && grep "^utf8 body" msgtxt1 && - grep "^Content-Type: text/plain; charset=utf-8" msgtxt1 + grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 ' test_expect_success '--compose respects user mime type' ' @@ -573,7 +573,7 @@ test_expect_success '--compose respects user mime type' ' $patches && grep "^utf8 body" msgtxt1 && grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 && - ! grep "^Content-Type: text/plain; charset=utf-8" msgtxt1 + ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 ' test_expect_success '--compose adds MIME for utf8 subject' ' @@ -586,7 +586,7 @@ test_expect_success '--compose adds MIME for utf8 subject' ' --smtp-server="$(pwd)/fake.sendmail" \ $patches && grep "^fake edit" msgtxt1 && - grep "^Subject: =?utf-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 + grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 ' test_expect_success 'detects ambiguous reference/file conflict' ' -- cgit v1.2.3 From 32ae83194b0f287a9b6644cdad175c56417c31f3 Mon Sep 17 00:00:00 2001 From: Markus Heidelberg Date: Fri, 12 Jun 2009 12:51:37 +0200 Subject: add a test for git-send-email for non-threaded mails Signed-off-by: Markus Heidelberg Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index ce26ea4ac5..5bfa36eccf 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -621,4 +621,14 @@ test_expect_success 'in-reply-to but no threading' ' grep "In-Reply-To: " ' +test_expect_failure 'no in-reply-to and no threading' ' + git send-email \ + --dry-run \ + --from="Example " \ + --to=nobody@example.com \ + --nothread \ + $patches $patches >stdout && + ! grep "In-Reply-To: " stdout +' + test_done -- cgit v1.2.3 From 5e9758e2968238906c730c9c77ecc95c21e7495e Mon Sep 17 00:00:00 2001 From: Markus Heidelberg Date: Fri, 12 Jun 2009 12:51:38 +0200 Subject: send-email: fix non-threaded mails After commit 3e0c4ff (send-email: respect in-reply-to regardless of threading, 2009-03-01) the variable $thread was only used for prompting for an "In-Reply-To", but not for controlling whether the "In-Reply-To" and "References" fields should be written into the email. Thus these fields were always used beginning with the second mail and it was not possible to produce non-threaded mails anymore. However, a later commit 15da108 ("send-email: 'References:' should only reference what is sent", 2009-04-13) introduced a regression with the side effect to make non-threaded mails possible again, but only when --no-chain-reply-to was used. Signed-off-by: Markus Heidelberg Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 5bfa36eccf..8518acaca6 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -621,7 +621,7 @@ test_expect_success 'in-reply-to but no threading' ' grep "In-Reply-To: " ' -test_expect_failure 'no in-reply-to and no threading' ' +test_expect_success 'no in-reply-to and no threading' ' git send-email \ --dry-run \ --from="Example " \ -- cgit v1.2.3 From d67114a5f3cbbedd4f01e6ff87fd5d4db9563ead Mon Sep 17 00:00:00 2001 From: Markus Heidelberg Date: Fri, 12 Jun 2009 12:51:40 +0200 Subject: add a test for git-send-email for threaded mails without chain-reply-to Signed-off-by: Markus Heidelberg Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 2ce24cd5a6..4f67de3ac7 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -621,4 +621,15 @@ test_expect_success 'in-reply-to but no threading' ' grep "In-Reply-To: " ' +test_expect_failure 'threading but no chain-reply-to' ' + git send-email \ + --dry-run \ + --from="Example " \ + --to=nobody@example.com \ + --thread \ + --nochain-reply-to \ + $patches $patches >stdout && + grep "In-Reply-To: " stdout +' + test_done -- cgit v1.2.3 From f74fe34b96816bad1f568202ec51ef18ae7513b3 Mon Sep 17 00:00:00 2001 From: Markus Heidelberg Date: Fri, 12 Jun 2009 12:51:41 +0200 Subject: send-email: fix threaded mails without chain-reply-to An earlier commit 15da108 ("send-email: 'References:' should only reference what is sent", 2009-04-13) broke logic to set up threading information for the next message by rewriting "!" to "not" without understanding the precedence rules of the language. Namely, ! defined $reply_to || length($reply_to) == 0 was changed to not defined $reply_to || length($reply_to) == 0 which is not (defined $reply_to || length($reply_to) == 0) and different from what was intended, which is (not defined $reply_to) || (length($reply_to) == 0) Signed-off-by: Markus Heidelberg Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 4f67de3ac7..8ab1a78bf5 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -621,7 +621,7 @@ test_expect_success 'in-reply-to but no threading' ' grep "In-Reply-To: " ' -test_expect_failure 'threading but no chain-reply-to' ' +test_expect_success 'threading but no chain-reply-to' ' git send-email \ --dry-run \ --from="Example " \ -- cgit v1.2.3 From cb8a9bd518002dd4fb693df6230b4976bafc15e0 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 18 Jun 2009 14:31:32 +0200 Subject: Test cccmd in t9001-send-email.sh and fix some bugs For another patch series I'm working on I needed some tests for the cc-cmd feature of git-send-email. This patch adds 3 tests for the feature and for the possibility to specify --suppress-cc multiple times, and fixes two bugs. The first bug is that the --suppress-cc option for `cccmd' was misspelled as `ccmd' in the code. The second bug, which is actually found only with my other series, is that the argument to the cccmd is never quoted, so the cccmd would fail with patch file names containing a space. A third bug I fix (in the docs) is that the bodycc argument was actually spelled ccbody in the documentation and bash completion. Signed-off-by: Paolo Bonzini Cc: Markus Heidelberg Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 80 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 75 insertions(+), 5 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 9ce04fd472..fb7d9f3e4a 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -148,6 +148,22 @@ test_expect_success 'Prompting works' ' grep "^To: to@example.com$" msgtxt1 ' +test_expect_success 'cccmd works' ' + clean_fake_sendmail && + cp $patches cccmd.patch && + echo cccmd--cccmd@example.com >>cccmd.patch && + echo sed -n s/^cccmd--//p \"\$1\" > cccmd-sed && + chmod +x cccmd-sed && + git send-email \ + --from="Example " \ + --to=nobody@example.com \ + --cc-cmd=./cccmd-sed \ + --smtp-server="$(pwd)/fake.sendmail" \ + cccmd.patch \ + && + grep ^Cc:.*cccmd@example.com msgtxt1 +' + z8=zzzzzzzz z64=$z8$z8$z8$z8$z8$z8$z8$z8 z512=$z64$z64$z64$z64$z64$z64$z64$z64 @@ -274,7 +290,7 @@ EOF test_suppression () { git send-email \ --dry-run \ - --suppress-cc=$1 \ + --suppress-cc=$1 ${2+"--suppress-cc=$2"} \ --from="Example " \ --to=to@example.com \ --smtp-server relay.example.com \ @@ -282,8 +298,8 @@ test_suppression () { sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ - >actual-suppress-$1 && - test_cmp expected-suppress-$1 actual-suppress-$1 + >actual-suppress-$1${2+"-$2"} && + test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"} } test_expect_success 'sendemail.cc set' ' @@ -316,6 +332,34 @@ test_expect_success 'sendemail.cc unset' ' test_suppression sob ' +cat >expected-suppress-cccmd <<\EOF +0001-Second.patch +(mbox) Adding cc: A from line 'From: A ' +(mbox) Adding cc: One from line 'Cc: One , two@example.com' +(mbox) Adding cc: two@example.com from line 'Cc: One , two@example.com' +(body) Adding cc: C O Mitter from line 'Signed-off-by: C O Mitter ' +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM: +RCPT TO:,,,, +From: Example +To: to@example.com +Cc: A , One , two@example.com, C O Mitter +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING + +Result: OK +EOF + +test_expect_success 'sendemail.cccmd' ' + echo echo cc-cmd@example.com > cccmd && + chmod +x cccmd && + git config sendemail.cccmd ./cccmd && + test_suppression cccmd +' + cat >expected-suppress-all <<\EOF 0001-Second.patch Dry-OK. Log says: @@ -341,13 +385,14 @@ cat >expected-suppress-body <<\EOF (mbox) Adding cc: A from line 'From: A ' (mbox) Adding cc: One from line 'Cc: One , two@example.com' (mbox) Adding cc: two@example.com from line 'Cc: One , two@example.com' +(cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd' Dry-OK. Log says: Server: relay.example.com MAIL FROM: -RCPT TO:,,, +RCPT TO:,,,, From: Example To: to@example.com -Cc: A , One , two@example.com +Cc: A , One , two@example.com, cc-cmd@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -360,6 +405,30 @@ test_expect_success '--suppress-cc=body' ' test_suppression body ' +cat >expected-suppress-body-cccmd <<\EOF +0001-Second.patch +(mbox) Adding cc: A from line 'From: A ' +(mbox) Adding cc: One from line 'Cc: One , two@example.com' +(mbox) Adding cc: two@example.com from line 'Cc: One , two@example.com' +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM: +RCPT TO:,,, +From: Example +To: to@example.com +Cc: A , One , two@example.com +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING + +Result: OK +EOF + +test_expect_success '--suppress-cc=body --suppress-cc=cccmd' ' + test_suppression body cccmd +' + cat >expected-suppress-sob <<\EOF 0001-Second.patch (mbox) Adding cc: A from line 'From: A ' @@ -381,6 +450,7 @@ Result: OK EOF test_expect_success '--suppress-cc=sob' ' + git config --unset sendemail.cccmd test_suppression sob ' -- cgit v1.2.3 From 977e289e0d73ad66883425efbd37eadb7d91fd61 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Mon, 22 Jun 2009 12:32:52 -0500 Subject: t/t9001-send-email.sh: ensure generated script is executed with $SHELL_PATH If the shell is not specified using the '#!' notation, then the OS will use '/bin/sh' to execute the script which may not produce the desired results. In particular, /bin/sh on Solaris interprets '^' specially which has an effect on the sed command that this patch touches. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index fb7d9f3e4a..fb606a9f05 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -152,7 +152,10 @@ test_expect_success 'cccmd works' ' clean_fake_sendmail && cp $patches cccmd.patch && echo cccmd--cccmd@example.com >>cccmd.patch && - echo sed -n s/^cccmd--//p \"\$1\" > cccmd-sed && + { + echo "#!$SHELL_PATH" + echo sed -n -e s/^cccmd--//p \"\$1\" + } > cccmd-sed && chmod +x cccmd-sed && git send-email \ --from="Example " \ -- cgit v1.2.3 From 02461e0e2833753151ed71899f075c94e5fc495b Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Thu, 8 Oct 2009 10:03:26 -0700 Subject: git-send-email.perl: fold multiple entry "Cc:" and multiple single line "RCPT TO:"s Some MTAs reject Cc: lines longer than 78 chars. Avoid this by using the same join as "To:" ",\n\t" so each subsequent Cc entry is on a new line. RCPT TO: should have a single entry per line. see: http://www.ietf.org/rfc/rfc2821.txt Signed-off-by: Joe Perches Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 94 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 74 insertions(+), 20 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index fb606a9f05..84a7f03d46 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -103,10 +103,18 @@ cat >expected-show-all-headers <<\EOF Dry-OK. Log says: Server: relay.example.com MAIL FROM: -RCPT TO:,,,,, +RCPT TO: +RCPT TO: +RCPT TO: +RCPT TO: +RCPT TO: +RCPT TO: From: Example To: to@example.com -Cc: cc@example.com, A , One , two@example.com +Cc: cc@example.com, + A , + One , + two@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -164,7 +172,7 @@ test_expect_success 'cccmd works' ' --smtp-server="$(pwd)/fake.sendmail" \ cccmd.patch \ && - grep ^Cc:.*cccmd@example.com msgtxt1 + grep "^ cccmd@example.com" msgtxt1 ' z8=zzzzzzzz @@ -278,10 +286,17 @@ cat >expected-suppress-sob <<\EOF Dry-OK. Log says: Server: relay.example.com MAIL FROM: -RCPT TO:,,,, +RCPT TO: +RCPT TO: +RCPT TO: +RCPT TO: +RCPT TO: From: Example To: to@example.com -Cc: cc@example.com, A , One , two@example.com +Cc: cc@example.com, + A , + One , + two@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -318,10 +333,15 @@ cat >expected-suppress-sob <<\EOF Dry-OK. Log says: Server: relay.example.com MAIL FROM: -RCPT TO:,,, +RCPT TO: +RCPT TO: +RCPT TO: +RCPT TO: From: Example To: to@example.com -Cc: A , One , two@example.com +Cc: A , + One , + two@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -344,10 +364,17 @@ cat >expected-suppress-cccmd <<\EOF Dry-OK. Log says: Server: relay.example.com MAIL FROM: -RCPT TO:,,,, +RCPT TO: +RCPT TO: +RCPT TO: +RCPT TO: +RCPT TO: From: Example To: to@example.com -Cc: A , One , two@example.com, C O Mitter +Cc: A , + One , + two@example.com, + C O Mitter Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -392,10 +419,17 @@ cat >expected-suppress-body <<\EOF Dry-OK. Log says: Server: relay.example.com MAIL FROM: -RCPT TO:,,,, +RCPT TO: +RCPT TO: +RCPT TO: +RCPT TO: +RCPT TO: From: Example To: to@example.com -Cc: A , One , two@example.com, cc-cmd@example.com +Cc: A , + One , + two@example.com, + cc-cmd@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -416,10 +450,15 @@ cat >expected-suppress-body-cccmd <<\EOF Dry-OK. Log says: Server: relay.example.com MAIL FROM: -RCPT TO:,,, +RCPT TO: +RCPT TO: +RCPT TO: +RCPT TO: From: Example To: to@example.com -Cc: A , One , two@example.com +Cc: A , + One , + two@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -440,10 +479,15 @@ cat >expected-suppress-sob <<\EOF Dry-OK. Log says: Server: relay.example.com MAIL FROM: -RCPT TO:,,, +RCPT TO: +RCPT TO: +RCPT TO: +RCPT TO: From: Example To: to@example.com -Cc: A , One , two@example.com +Cc: A , + One , + two@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -466,10 +510,17 @@ cat >expected-suppress-bodycc <<\EOF Dry-OK. Log says: Server: relay.example.com MAIL FROM: -RCPT TO:,,,, +RCPT TO: +RCPT TO: +RCPT TO: +RCPT TO: +RCPT TO: From: Example To: to@example.com -Cc: A , One , two@example.com, C O Mitter +Cc: A , + One , + two@example.com, + C O Mitter Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -489,10 +540,13 @@ cat >expected-suppress-cc <<\EOF Dry-OK. Log says: Server: relay.example.com MAIL FROM: -RCPT TO:,, +RCPT TO: +RCPT TO: +RCPT TO: From: Example To: to@example.com -Cc: A , C O Mitter +Cc: A , + C O Mitter Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -605,7 +659,7 @@ test_expect_success 'utf8 Cc is rfc2047 encoded' ' --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ outdir/*.patch && - grep "^Cc:" msgtxt1 | + grep "^ " msgtxt1 | grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= " ' -- cgit v1.2.3 From 4f333bc1d32a84c9ddad737ccdbd6e99ed05d396 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 22 Nov 2009 09:54:10 -0800 Subject: t9001: test --envelope-sender option of send-email Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index fb606a9f05..0164629ed0 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -95,6 +95,23 @@ test_expect_success \ 'Verify commandline' \ 'test_cmp expected commandline1' +test_expect_success 'Send patches with --envelope-sender' ' + clean_fake_sendmail && + git send-email --envelope-sender="Patch Contributer " --suppress-cc=sob --from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors +' + +cat >expected <<\EOF +!patch@example.com! +!-i! +!nobody@example.com! +!author@example.com! +!one@example.com! +!two@example.com! +EOF +test_expect_success \ + 'Verify commandline' \ + 'test_cmp expected commandline1' + cat >expected-show-all-headers <<\EOF 0001-Second.patch (mbox) Adding cc: A from line 'From: A ' -- cgit v1.2.3 From c89e32414516e906520e9bdd809560971eb52ef5 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 26 Nov 2009 21:04:29 +0200 Subject: send-email: automatic envelope sender This adds the option to specify the envelope sender as "auto" which would pick the 'from' address. This is good because now we can specify the address only in one place in $HOME/.gitconfig and change it easily. [jc: added tests] Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 0164629ed0..c23ea0f3c5 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -112,6 +112,23 @@ test_expect_success \ 'Verify commandline' \ 'test_cmp expected commandline1' +test_expect_success 'Send patches with --envelope-sender=auto' ' + clean_fake_sendmail && + git send-email --envelope-sender=auto --suppress-cc=sob --from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors +' + +cat >expected <<\EOF +!nobody@example.com! +!-i! +!nobody@example.com! +!author@example.com! +!one@example.com! +!two@example.com! +EOF +test_expect_success \ + 'Verify commandline' \ + 'test_cmp expected commandline1' + cat >expected-show-all-headers <<\EOF 0001-Second.patch (mbox) Adding cc: A from line 'From: A ' -- cgit v1.2.3 From 528fb08732aa742edf56bc61cc8943c7f6d02977 Mon Sep 17 00:00:00 2001 From: Nanako Shiraishi Date: Sun, 29 Nov 2009 12:24:48 +0900 Subject: prepare send-email for smoother change of --chain-reply-to default Give a warning message when send-email uses chain-reply-to to thread the messages because of the current default, not because the user explicitly asked to, either from the command line or from the configuration. This way, by the time 1.7.0 switches the default, everybody will be ready. Signed-off-by: Nanako Shiraishi Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 84a7f03d46..798291240a 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -769,4 +769,53 @@ test_expect_success 'threading but no chain-reply-to' ' grep "In-Reply-To: " stdout ' +test_expect_success 'warning with an implicit --chain-reply-to' ' + git send-email \ + --dry-run \ + --from="Example " \ + --to=nobody@example.com \ + outdir/000?-*.patch 2>errors >out && + grep "no-chain-reply-to" errors +' + +test_expect_success 'no warning with an explicit --chain-reply-to' ' + git send-email \ + --dry-run \ + --from="Example " \ + --to=nobody@example.com \ + --chain-reply-to \ + outdir/000?-*.patch 2>errors >out && + ! grep "no-chain-reply-to" errors +' + +test_expect_success 'no warning with an explicit --no-chain-reply-to' ' + git send-email \ + --dry-run \ + --from="Example " \ + --to=nobody@example.com \ + --no-chain-reply-to \ + outdir/000?-*.patch 2>errors >out && + ! grep "no-chain-reply-to" errors +' + +test_expect_success 'no warning with sendemail.chainreplyto = false' ' + git config sendemail.chainreplyto false && + git send-email \ + --dry-run \ + --from="Example " \ + --to=nobody@example.com \ + outdir/000?-*.patch 2>errors >out && + ! grep "no-chain-reply-to" errors +' + +test_expect_success 'no warning with sendemail.chainreplyto = true' ' + git config sendemail.chainreplyto true && + git send-email \ + --dry-run \ + --from="Example " \ + --to=nobody@example.com \ + outdir/000?-*.patch 2>errors >out && + ! grep "no-chain-reply-to" errors +' + test_done -- cgit v1.2.3 From 907a0b1e04ea31cb368e9422df93d8ebb0187914 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Thu, 3 Dec 2009 11:52:46 -0600 Subject: t9001: use older Getopt::Long boolean prefix '--no' rather than '--no-' The '--no-chain-reply-to' option is a Getopt::Long boolean option. The '--no-' prefix (as in --no-chain-reply-to) for boolean options is not supported in Getopt::Long version 2.32 which was released with Perl 5.8.0. This version only supports '--no' as in '--nochain-reply-to'. More recent versions of Getopt::Long, such as version 2.34, support either prefix. So use the older form in the tests. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index fb51ab3dbe..752adaac85 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -827,7 +827,7 @@ test_expect_success 'no warning with an explicit --no-chain-reply-to' ' --dry-run \ --from="Example " \ --to=nobody@example.com \ - --no-chain-reply-to \ + --nochain-reply-to \ outdir/000?-*.patch 2>errors >out && ! grep "no-chain-reply-to" errors ' -- cgit v1.2.3 From 9524cf29930b4f91d68ad1384d7f984393a54c15 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Tue, 26 Jan 2010 15:08:31 -0800 Subject: fix portability issues with $ in double quotes Using a dollar sign in double quotes isn't portable. Escape them with a backslash or replace the double quotes with single quotes. Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 752adaac85..c09f375288 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -186,8 +186,8 @@ test_expect_success 'Prompting works' ' --smtp-server="$(pwd)/fake.sendmail" \ $patches \ 2>errors && - grep "^From: Example $" msgtxt1 && - grep "^To: to@example.com$" msgtxt1 + grep "^From: Example \$" msgtxt1 && + grep "^To: to@example.com\$" msgtxt1 ' test_expect_success 'cccmd works' ' @@ -236,7 +236,7 @@ test_expect_success 'Author From: in message body' ' --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ $patches && - sed "1,/^$/d" < msgtxt1 > msgbody1 + sed "1,/^\$/d" < msgtxt1 > msgbody1 grep "From: A " msgbody1 ' @@ -247,7 +247,7 @@ test_expect_success 'Author From: not in message body' ' --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ $patches && - sed "1,/^$/d" < msgtxt1 > msgbody1 + sed "1,/^\$/d" < msgtxt1 > msgbody1 ! grep "From: A " msgbody1 ' -- cgit v1.2.3 From f434c083a097bdc43991e4b0282b9aa1a994a60e Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Sun, 7 Mar 2010 14:46:48 -0800 Subject: send-email: add --no-cc, --no-to, and --no-bcc There's no way to override the sendemail.to, sendemail.cc, and sendemail.bcc config settings. Add options allowing the user to tell git to ignore the config settings and take whatever is on the command line. Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index c09f375288..640b3d2bb4 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -852,4 +852,70 @@ test_expect_success 'no warning with sendemail.chainreplyto = true' ' ! grep "no-chain-reply-to" errors ' +test_expect_success 'sendemail.to works' ' + git config --replace-all sendemail.to "Somebody " && + git send-email \ + --dry-run \ + --from="Example " \ + $patches $patches >stdout && + grep "To: Somebody " stdout +' + +test_expect_success '--no-to overrides sendemail.to' ' + git send-email \ + --dry-run \ + --from="Example " \ + --no-to \ + --to=nobody@example.com \ + $patches $patches >stdout && + grep "To: nobody@example.com" stdout && + ! grep "To: Somebody " stdout +' + +test_expect_success 'sendemail.cc works' ' + git config --replace-all sendemail.cc "Somebody " && + git send-email \ + --dry-run \ + --from="Example " \ + --to=nobody@example.com \ + $patches $patches >stdout && + grep "Cc: Somebody " stdout +' + +test_expect_success '--no-cc overrides sendemail.cc' ' + git send-email \ + --dry-run \ + --from="Example " \ + --no-cc \ + --cc=bodies@example.com \ + --to=nobody@example.com \ + $patches $patches >stdout && + grep "Cc: bodies@example.com" stdout && + ! grep "Cc: Somebody " stdout +' + +test_expect_success 'sendemail.bcc works' ' + git config --replace-all sendemail.bcc "Other " && + git send-email \ + --dry-run \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server relay.example.com \ + $patches $patches >stdout && + grep "RCPT TO:" stdout +' + +test_expect_success '--no-bcc overrides sendemail.bcc' ' + git send-email \ + --dry-run \ + --from="Example " \ + --no-bcc \ + --bcc=bodies@example.com \ + --to=nobody@example.com \ + --smtp-server relay.example.com \ + $patches $patches >stdout && + grep "RCPT TO:" stdout && + ! grep "RCPT TO:" stdout +' + test_done -- cgit v1.2.3 From 3cae7e5b2b9c73aca6a7729bc34c1ce6638fa43a Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Thu, 17 Jun 2010 22:10:39 +0200 Subject: send-email: ask about and declare 8bit mails git-send-email passes on an 8bit mail as-is even if it does not declare a content-type. Because the user can edit email between format-patch and send-email, such invalid mails are unfortunately not very hard to come by. Make git-send-email stop and ask about the encoding to use if it encounters any such mail. Also provide a configuration setting to permanently configure an encoding. Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 640b3d2bb4..0b8a591507 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -918,4 +918,81 @@ test_expect_success '--no-bcc overrides sendemail.bcc' ' ! grep "RCPT TO:" stdout ' +cat >email-using-8bit < +From: author@example.com +Date: Sat, 12 Jun 2010 15:53:58 +0200 +Subject: subject goes here + +Dieser deutsche Text enthält einen Umlaut! +EOF + +cat >content-type-decl <stdout && + grep "do not declare a Content-Transfer-Encoding" stdout && + grep email-using-8bit stdout && + grep "Which 8bit encoding" stdout && + grep "Content\\|MIME" msgtxt1 >actual && + test_cmp actual content-type-decl +' + +test_expect_success 'sendemail.8bitEncoding works' ' + clean_fake_sendmail && + git config sendemail.assume8bitEncoding UTF-8 && + echo bogus | + git send-email --from=author@example.com --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + email-using-8bit >stdout && + grep "Content\\|MIME" msgtxt1 >actual && + test_cmp actual content-type-decl +' + +test_expect_success '--8bit-encoding overrides sendemail.8bitEncoding' ' + clean_fake_sendmail && + git config sendemail.assume8bitEncoding "bogus too" && + echo bogus | + git send-email --from=author@example.com --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + --8bit-encoding=UTF-8 \ + email-using-8bit >stdout && + grep "Content\\|MIME" msgtxt1 >actual && + test_cmp actual content-type-decl +' + +cat >email-using-8bit < +From: author@example.com +Date: Sat, 12 Jun 2010 15:53:58 +0200 +Subject: Dieser Betreff enthält auch einen Umlaut! + +Nothing to see here. +EOF + +cat >expected <stdout && + grep "Subject" msgtxt1 >actual && + test_cmp expected actual +' + test_done -- cgit v1.2.3 From fadb5156e485e9d25c89d4b4f96c2d4fe6db6187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 24 Jun 2010 17:44:48 +0000 Subject: tests: Skip tests in a way that makes sense under TAP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SKIP messages are now part of the TAP plan. A TAP harness now knows why a particular test was skipped and can report that information. The non-TAP harness built into Git's test-lib did nothing special with these messages, and is unaffected by these changes. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 640b3d2bb4..ddc3d8db9f 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -4,7 +4,7 @@ test_description='git send-email' . ./test-lib.sh if ! test_have_prereq PERL; then - say 'skipping git send-email tests, perl not available' + skip_all='skipping git send-email tests, perl not available' test_done fi @@ -58,7 +58,7 @@ test_no_confirm () { # Exit immediately to prevent hang if a no-confirm test fails check_no_confirm () { test -f no_confirm_okay || { - say 'No confirm test failed; skipping remaining tests to prevent hanging' + skip_all='confirm test failed; skipping remaining tests to prevent hanging' test_done } } -- cgit v1.2.3 From 3183286238f7b0b4f491963ffc05bb47b35e487d Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Mon, 28 Jun 2010 17:46:22 -0500 Subject: t/t9001: use egrep when regular expressions are involved Supplying backslashed, extended regular expressions to grep is not portable. Use egrep instead. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 0b8a591507..382ab6c98a 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -943,7 +943,7 @@ test_expect_success 'asks about and fixes 8bit encodings' ' grep "do not declare a Content-Transfer-Encoding" stdout && grep email-using-8bit stdout && grep "Which 8bit encoding" stdout && - grep "Content\\|MIME" msgtxt1 >actual && + egrep "Content|MIME" msgtxt1 >actual && test_cmp actual content-type-decl ' @@ -954,7 +954,7 @@ test_expect_success 'sendemail.8bitEncoding works' ' git send-email --from=author@example.com --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ email-using-8bit >stdout && - grep "Content\\|MIME" msgtxt1 >actual && + egrep "Content|MIME" msgtxt1 >actual && test_cmp actual content-type-decl ' @@ -966,7 +966,7 @@ test_expect_success '--8bit-encoding overrides sendemail.8bitEncoding' ' --smtp-server="$(pwd)/fake.sendmail" \ --8bit-encoding=UTF-8 \ email-using-8bit >stdout && - grep "Content\\|MIME" msgtxt1 >actual && + egrep "Content|MIME" msgtxt1 >actual && test_cmp actual content-type-decl ' -- cgit v1.2.3 From 3731231d4c81d1234d231e2a82f3720f10bdbe76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Fri, 13 Aug 2010 20:40:08 +0000 Subject: t/t9001-send-email.sh: Remove needless PROG=* assignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the PROG=* assignment from t9001-send-email.sh. It's been there since v1.4.0-rc1~30 when the test was originally added, but only tests that source annotate-tests.sh need it, it was seemingly introduced to this test via copy/paste coding. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 1 - 1 file changed, 1 deletion(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 23597cc407..6525d1dacd 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -8,7 +8,6 @@ if ! test_have_prereq PERL; then test_done fi -PROG='git send-email' test_expect_success \ 'prepare reference tree' \ 'echo "1A quick brown fox jumps over the" >file && -- cgit v1.2.3 From 57cd35e6adc68a33163136ef416ffa43b4821ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Fri, 13 Aug 2010 20:40:09 +0000 Subject: t/t9001-send-email.sh: change from skip_all=* to prereq skip MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change this test to skip test with test prerequisites, and to do setup work in tests. This improves the skipped statistics on platforms where the test isn't run. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 165 +++++++++++++++++++++++++------------------------- 1 file changed, 83 insertions(+), 82 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 6525d1dacd..bd17d31e6f 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -3,19 +3,17 @@ test_description='git send-email' . ./test-lib.sh -if ! test_have_prereq PERL; then - skip_all='skipping git send-email tests, perl not available' - test_done -fi +# May be altered later in the test +PREREQ="PERL" -test_expect_success \ +test_expect_success $PREREQ \ 'prepare reference tree' \ 'echo "1A quick brown fox jumps over the" >file && echo "lazy dog" >>file && git add file && GIT_AUTHOR_NAME="A" git commit -a -m "Initial."' -test_expect_success \ +test_expect_success $PREREQ \ 'Setup helper tool' \ '(echo "#!$SHELL_PATH" echo shift @@ -35,7 +33,7 @@ clean_fake_sendmail() { rm -f commandline* msgtxt* } -test_expect_success 'Extract patches' ' +test_expect_success $PREREQ 'Extract patches' ' patches=`git format-patch -s --cc="One " --cc=two@example.com -n HEAD^1` ' @@ -56,31 +54,34 @@ test_no_confirm () { # Exit immediately to prevent hang if a no-confirm test fails check_no_confirm () { - test -f no_confirm_okay || { - skip_all='confirm test failed; skipping remaining tests to prevent hanging' - test_done - } + if ! test -f no_confirm_okay + then + say 'confirm test failed; skipping remaining tests to prevent hanging' + PREREQ="$PREREQ,CHECK_NO_CONFIRM" + fi + return 0 } -test_expect_success 'No confirm with --suppress-cc' ' - test_no_confirm --suppress-cc=sob +test_expect_success $PREREQ 'No confirm with --suppress-cc' ' + test_no_confirm --suppress-cc=sob && + check_no_confirm ' -check_no_confirm -test_expect_success 'No confirm with --confirm=never' ' - test_no_confirm --confirm=never + +test_expect_success $PREREQ 'No confirm with --confirm=never' ' + test_no_confirm --confirm=never && + check_no_confirm ' -check_no_confirm # leave sendemail.confirm set to never after this so that none of the # remaining tests prompt unintentionally. -test_expect_success 'No confirm with sendemail.confirm=never' ' +test_expect_success $PREREQ 'No confirm with sendemail.confirm=never' ' git config sendemail.confirm never && - test_no_confirm --compose --subject=foo + test_no_confirm --compose --subject=foo && + check_no_confirm ' -check_no_confirm -test_expect_success 'Send patches' ' +test_expect_success $PREREQ 'Send patches' ' git send-email --suppress-cc=sob --from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors ' @@ -90,11 +91,11 @@ cat >expected <<\EOF !one@example.com! !two@example.com! EOF -test_expect_success \ +test_expect_success $PREREQ \ 'Verify commandline' \ 'test_cmp expected commandline1' -test_expect_success 'Send patches with --envelope-sender' ' +test_expect_success $PREREQ 'Send patches with --envelope-sender' ' clean_fake_sendmail && git send-email --envelope-sender="Patch Contributer " --suppress-cc=sob --from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors ' @@ -107,11 +108,11 @@ cat >expected <<\EOF !one@example.com! !two@example.com! EOF -test_expect_success \ +test_expect_success $PREREQ \ 'Verify commandline' \ 'test_cmp expected commandline1' -test_expect_success 'Send patches with --envelope-sender=auto' ' +test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' ' clean_fake_sendmail && git send-email --envelope-sender=auto --suppress-cc=sob --from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors ' @@ -124,7 +125,7 @@ cat >expected <<\EOF !one@example.com! !two@example.com! EOF -test_expect_success \ +test_expect_success $PREREQ \ 'Verify commandline' \ 'test_cmp expected commandline1' @@ -158,7 +159,7 @@ References: Result: OK EOF -test_expect_success 'Show all headers' ' +test_expect_success $PREREQ 'Show all headers' ' git send-email \ --dry-run \ --suppress-cc=sob \ @@ -176,7 +177,7 @@ test_expect_success 'Show all headers' ' test_cmp expected-show-all-headers actual-show-all-headers ' -test_expect_success 'Prompting works' ' +test_expect_success $PREREQ 'Prompting works' ' clean_fake_sendmail && (echo "Example " echo "to@example.com" @@ -189,7 +190,7 @@ test_expect_success 'Prompting works' ' grep "^To: to@example.com\$" msgtxt1 ' -test_expect_success 'cccmd works' ' +test_expect_success $PREREQ 'cccmd works' ' clean_fake_sendmail && cp $patches cccmd.patch && echo cccmd--cccmd@example.com >>cccmd.patch && @@ -211,7 +212,7 @@ test_expect_success 'cccmd works' ' z8=zzzzzzzz z64=$z8$z8$z8$z8$z8$z8$z8$z8 z512=$z64$z64$z64$z64$z64$z64$z64$z64 -test_expect_success 'reject long lines' ' +test_expect_success $PREREQ 'reject long lines' ' clean_fake_sendmail && cp $patches longline.patch && echo $z512$z512 >>longline.patch && @@ -224,11 +225,11 @@ test_expect_success 'reject long lines' ' grep longline.patch errors ' -test_expect_success 'no patch was sent' ' +test_expect_success $PREREQ 'no patch was sent' ' ! test -e commandline1 ' -test_expect_success 'Author From: in message body' ' +test_expect_success $PREREQ 'Author From: in message body' ' clean_fake_sendmail && git send-email \ --from="Example " \ @@ -239,7 +240,7 @@ test_expect_success 'Author From: in message body' ' grep "From: A " msgbody1 ' -test_expect_success 'Author From: not in message body' ' +test_expect_success $PREREQ 'Author From: not in message body' ' clean_fake_sendmail && git send-email \ --from="A " \ @@ -250,7 +251,7 @@ test_expect_success 'Author From: not in message body' ' ! grep "From: A " msgbody1 ' -test_expect_success 'allow long lines with --no-validate' ' +test_expect_success $PREREQ 'allow long lines with --no-validate' ' git send-email \ --from="Example " \ --to=nobody@example.com \ @@ -260,7 +261,7 @@ test_expect_success 'allow long lines with --no-validate' ' 2>errors ' -test_expect_success 'Invalid In-Reply-To' ' +test_expect_success $PREREQ 'Invalid In-Reply-To' ' clean_fake_sendmail && git send-email \ --from="Example " \ @@ -272,7 +273,7 @@ test_expect_success 'Invalid In-Reply-To' ' ! grep "^In-Reply-To: < *>" msgtxt1 ' -test_expect_success 'Valid In-Reply-To when prompting' ' +test_expect_success $PREREQ 'Valid In-Reply-To when prompting' ' clean_fake_sendmail && (echo "From Example " echo "To Example " @@ -283,7 +284,7 @@ test_expect_success 'Valid In-Reply-To when prompting' ' ! grep "^In-Reply-To: < *>" msgtxt1 ' -test_expect_success 'setup fake editor' ' +test_expect_success $PREREQ 'setup fake editor' ' (echo "#!$SHELL_PATH" && echo "echo fake edit >>\"\$1\"" ) >fake-editor && @@ -292,7 +293,7 @@ test_expect_success 'setup fake editor' ' test_set_editor "$(pwd)/fake-editor" -test_expect_success '--compose works' ' +test_expect_success $PREREQ '--compose works' ' clean_fake_sendmail && git send-email \ --compose --subject foo \ @@ -303,11 +304,11 @@ test_expect_success '--compose works' ' 2>errors ' -test_expect_success 'first message is compose text' ' +test_expect_success $PREREQ 'first message is compose text' ' grep "^fake edit" msgtxt1 ' -test_expect_success 'second message is patch' ' +test_expect_success $PREREQ 'second message is patch' ' grep "Subject:.*Second" msgtxt2 ' @@ -353,7 +354,7 @@ test_suppression () { test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"} } -test_expect_success 'sendemail.cc set' ' +test_expect_success $PREREQ 'sendemail.cc set' ' git config sendemail.cc cc@example.com && test_suppression sob ' @@ -383,7 +384,7 @@ X-Mailer: X-MAILER-STRING Result: OK EOF -test_expect_success 'sendemail.cc unset' ' +test_expect_success $PREREQ 'sendemail.cc unset' ' git config --unset sendemail.cc && test_suppression sob ' @@ -416,7 +417,7 @@ X-Mailer: X-MAILER-STRING Result: OK EOF -test_expect_success 'sendemail.cccmd' ' +test_expect_success $PREREQ 'sendemail.cccmd' ' echo echo cc-cmd@example.com > cccmd && chmod +x cccmd && git config sendemail.cccmd ./cccmd && @@ -439,7 +440,7 @@ X-Mailer: X-MAILER-STRING Result: OK EOF -test_expect_success '--suppress-cc=all' ' +test_expect_success $PREREQ '--suppress-cc=all' ' test_suppression all ' @@ -471,7 +472,7 @@ X-Mailer: X-MAILER-STRING Result: OK EOF -test_expect_success '--suppress-cc=body' ' +test_expect_success $PREREQ '--suppress-cc=body' ' test_suppression body ' @@ -500,7 +501,7 @@ X-Mailer: X-MAILER-STRING Result: OK EOF -test_expect_success '--suppress-cc=body --suppress-cc=cccmd' ' +test_expect_success $PREREQ '--suppress-cc=body --suppress-cc=cccmd' ' test_suppression body cccmd ' @@ -529,7 +530,7 @@ X-Mailer: X-MAILER-STRING Result: OK EOF -test_expect_success '--suppress-cc=sob' ' +test_expect_success $PREREQ '--suppress-cc=sob' ' git config --unset sendemail.cccmd test_suppression sob ' @@ -562,7 +563,7 @@ X-Mailer: X-MAILER-STRING Result: OK EOF -test_expect_success '--suppress-cc=bodycc' ' +test_expect_success $PREREQ '--suppress-cc=bodycc' ' test_suppression bodycc ' @@ -588,7 +589,7 @@ X-Mailer: X-MAILER-STRING Result: OK EOF -test_expect_success '--suppress-cc=cc' ' +test_expect_success $PREREQ '--suppress-cc=cc' ' test_suppression cc ' @@ -603,23 +604,23 @@ test_confirm () { grep "Send this email" stdout } -test_expect_success '--confirm=always' ' +test_expect_success $PREREQ '--confirm=always' ' test_confirm --confirm=always --suppress-cc=all ' -test_expect_success '--confirm=auto' ' +test_expect_success $PREREQ '--confirm=auto' ' test_confirm --confirm=auto ' -test_expect_success '--confirm=cc' ' +test_expect_success $PREREQ '--confirm=cc' ' test_confirm --confirm=cc ' -test_expect_success '--confirm=compose' ' +test_expect_success $PREREQ '--confirm=compose' ' test_confirm --confirm=compose --compose ' -test_expect_success 'confirm by default (due to cc)' ' +test_expect_success $PREREQ 'confirm by default (due to cc)' ' CONFIRM=$(git config --get sendemail.confirm) && git config --unset sendemail.confirm && test_confirm @@ -628,7 +629,7 @@ test_expect_success 'confirm by default (due to cc)' ' test $ret = "0" ' -test_expect_success 'confirm by default (due to --compose)' ' +test_expect_success $PREREQ 'confirm by default (due to --compose)' ' CONFIRM=$(git config --get sendemail.confirm) && git config --unset sendemail.confirm && test_confirm --suppress-cc=all --compose @@ -637,7 +638,7 @@ test_expect_success 'confirm by default (due to --compose)' ' test $ret = "0" ' -test_expect_success 'confirm detects EOF (inform assumes y)' ' +test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' ' CONFIRM=$(git config --get sendemail.confirm) && git config --unset sendemail.confirm && rm -fr outdir && @@ -653,7 +654,7 @@ test_expect_success 'confirm detects EOF (inform assumes y)' ' test $ret = "0" ' -test_expect_success 'confirm detects EOF (auto causes failure)' ' +test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' ' CONFIRM=$(git config --get sendemail.confirm) && git config sendemail.confirm auto && GIT_SEND_EMAIL_NOTTY=1 && @@ -668,7 +669,7 @@ test_expect_success 'confirm detects EOF (auto causes failure)' ' test $ret = "0" ' -test_expect_success 'confirm doesnt loop forever' ' +test_expect_success $PREREQ 'confirm doesnt loop forever' ' CONFIRM=$(git config --get sendemail.confirm) && git config sendemail.confirm auto && GIT_SEND_EMAIL_NOTTY=1 && @@ -683,7 +684,7 @@ test_expect_success 'confirm doesnt loop forever' ' test $ret = "0" ' -test_expect_success 'utf8 Cc is rfc2047 encoded' ' +test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' ' clean_fake_sendmail && rm -fr outdir && git format-patch -1 -o outdir --cc="àéìöú " && @@ -696,7 +697,7 @@ test_expect_success 'utf8 Cc is rfc2047 encoded' ' grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= " ' -test_expect_success '--compose adds MIME for utf8 body' ' +test_expect_success $PREREQ '--compose adds MIME for utf8 body' ' clean_fake_sendmail && (echo "#!$SHELL_PATH" && echo "echo utf8 body: àéìöú >>\"\$1\"" @@ -713,7 +714,7 @@ test_expect_success '--compose adds MIME for utf8 body' ' grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 ' -test_expect_success '--compose respects user mime type' ' +test_expect_success $PREREQ '--compose respects user mime type' ' clean_fake_sendmail && (echo "#!$SHELL_PATH" && echo "(echo MIME-Version: 1.0" @@ -736,7 +737,7 @@ test_expect_success '--compose respects user mime type' ' ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 ' -test_expect_success '--compose adds MIME for utf8 subject' ' +test_expect_success $PREREQ '--compose adds MIME for utf8 subject' ' clean_fake_sendmail && GIT_EDITOR="\"$(pwd)/fake-editor\"" \ git send-email \ @@ -749,7 +750,7 @@ test_expect_success '--compose adds MIME for utf8 subject' ' grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 ' -test_expect_success 'detects ambiguous reference/file conflict' ' +test_expect_success $PREREQ 'detects ambiguous reference/file conflict' ' echo master > master && git add master && git commit -m"add master" && @@ -757,7 +758,7 @@ test_expect_success 'detects ambiguous reference/file conflict' ' grep disambiguate errors ' -test_expect_success 'feed two files' ' +test_expect_success $PREREQ 'feed two files' ' rm -fr outdir && git format-patch -2 -o outdir && git send-email \ @@ -770,7 +771,7 @@ test_expect_success 'feed two files' ' test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master" ' -test_expect_success 'in-reply-to but no threading' ' +test_expect_success $PREREQ 'in-reply-to but no threading' ' git send-email \ --dry-run \ --from="Example " \ @@ -781,7 +782,7 @@ test_expect_success 'in-reply-to but no threading' ' grep "In-Reply-To: " ' -test_expect_success 'no in-reply-to and no threading' ' +test_expect_success $PREREQ 'no in-reply-to and no threading' ' git send-email \ --dry-run \ --from="Example " \ @@ -791,7 +792,7 @@ test_expect_success 'no in-reply-to and no threading' ' ! grep "In-Reply-To: " stdout ' -test_expect_success 'threading but no chain-reply-to' ' +test_expect_success $PREREQ 'threading but no chain-reply-to' ' git send-email \ --dry-run \ --from="Example " \ @@ -802,7 +803,7 @@ test_expect_success 'threading but no chain-reply-to' ' grep "In-Reply-To: " stdout ' -test_expect_success 'warning with an implicit --chain-reply-to' ' +test_expect_success $PREREQ 'warning with an implicit --chain-reply-to' ' git send-email \ --dry-run \ --from="Example " \ @@ -811,7 +812,7 @@ test_expect_success 'warning with an implicit --chain-reply-to' ' grep "no-chain-reply-to" errors ' -test_expect_success 'no warning with an explicit --chain-reply-to' ' +test_expect_success $PREREQ 'no warning with an explicit --chain-reply-to' ' git send-email \ --dry-run \ --from="Example " \ @@ -821,7 +822,7 @@ test_expect_success 'no warning with an explicit --chain-reply-to' ' ! grep "no-chain-reply-to" errors ' -test_expect_success 'no warning with an explicit --no-chain-reply-to' ' +test_expect_success $PREREQ 'no warning with an explicit --no-chain-reply-to' ' git send-email \ --dry-run \ --from="Example " \ @@ -831,7 +832,7 @@ test_expect_success 'no warning with an explicit --no-chain-reply-to' ' ! grep "no-chain-reply-to" errors ' -test_expect_success 'no warning with sendemail.chainreplyto = false' ' +test_expect_success $PREREQ 'no warning with sendemail.chainreplyto = false' ' git config sendemail.chainreplyto false && git send-email \ --dry-run \ @@ -841,7 +842,7 @@ test_expect_success 'no warning with sendemail.chainreplyto = false' ' ! grep "no-chain-reply-to" errors ' -test_expect_success 'no warning with sendemail.chainreplyto = true' ' +test_expect_success $PREREQ 'no warning with sendemail.chainreplyto = true' ' git config sendemail.chainreplyto true && git send-email \ --dry-run \ @@ -851,7 +852,7 @@ test_expect_success 'no warning with sendemail.chainreplyto = true' ' ! grep "no-chain-reply-to" errors ' -test_expect_success 'sendemail.to works' ' +test_expect_success $PREREQ 'sendemail.to works' ' git config --replace-all sendemail.to "Somebody " && git send-email \ --dry-run \ @@ -860,7 +861,7 @@ test_expect_success 'sendemail.to works' ' grep "To: Somebody " stdout ' -test_expect_success '--no-to overrides sendemail.to' ' +test_expect_success $PREREQ '--no-to overrides sendemail.to' ' git send-email \ --dry-run \ --from="Example " \ @@ -871,7 +872,7 @@ test_expect_success '--no-to overrides sendemail.to' ' ! grep "To: Somebody " stdout ' -test_expect_success 'sendemail.cc works' ' +test_expect_success $PREREQ 'sendemail.cc works' ' git config --replace-all sendemail.cc "Somebody " && git send-email \ --dry-run \ @@ -881,7 +882,7 @@ test_expect_success 'sendemail.cc works' ' grep "Cc: Somebody " stdout ' -test_expect_success '--no-cc overrides sendemail.cc' ' +test_expect_success $PREREQ '--no-cc overrides sendemail.cc' ' git send-email \ --dry-run \ --from="Example " \ @@ -893,7 +894,7 @@ test_expect_success '--no-cc overrides sendemail.cc' ' ! grep "Cc: Somebody " stdout ' -test_expect_success 'sendemail.bcc works' ' +test_expect_success $PREREQ 'sendemail.bcc works' ' git config --replace-all sendemail.bcc "Other " && git send-email \ --dry-run \ @@ -904,7 +905,7 @@ test_expect_success 'sendemail.bcc works' ' grep "RCPT TO:" stdout ' -test_expect_success '--no-bcc overrides sendemail.bcc' ' +test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' ' git send-email \ --dry-run \ --from="Example " \ @@ -933,7 +934,7 @@ Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EOF -test_expect_success 'asks about and fixes 8bit encodings' ' +test_expect_success $PREREQ 'asks about and fixes 8bit encodings' ' clean_fake_sendmail && echo | git send-email --from=author@example.com --to=nobody@example.com \ @@ -946,7 +947,7 @@ test_expect_success 'asks about and fixes 8bit encodings' ' test_cmp actual content-type-decl ' -test_expect_success 'sendemail.8bitEncoding works' ' +test_expect_success $PREREQ 'sendemail.8bitEncoding works' ' clean_fake_sendmail && git config sendemail.assume8bitEncoding UTF-8 && echo bogus | @@ -957,7 +958,7 @@ test_expect_success 'sendemail.8bitEncoding works' ' test_cmp actual content-type-decl ' -test_expect_success '--8bit-encoding overrides sendemail.8bitEncoding' ' +test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' ' clean_fake_sendmail && git config sendemail.assume8bitEncoding "bogus too" && echo bogus | @@ -983,7 +984,7 @@ cat >expected < Date: Fri, 13 Aug 2010 20:40:10 +0000 Subject: t/t9001-send-email.sh: convert setup code to tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change the setup code in t/t9001-send-email.sh to use test_expect_success. This way it isn't needlessly run in environments where the test prerequisites aren't met. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index bd17d31e6f..71b3df9b55 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -85,12 +85,15 @@ test_expect_success $PREREQ 'Send patches' ' git send-email --suppress-cc=sob --from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors ' +test_expect_success $PREREQ 'setup expect' ' cat >expected <<\EOF !nobody@example.com! !author@example.com! !one@example.com! !two@example.com! EOF +' + test_expect_success $PREREQ \ 'Verify commandline' \ 'test_cmp expected commandline1' @@ -100,6 +103,7 @@ test_expect_success $PREREQ 'Send patches with --envelope-sender' ' git send-email --envelope-sender="Patch Contributer " --suppress-cc=sob --from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors ' +test_expect_success $PREREQ 'setup expect' ' cat >expected <<\EOF !patch@example.com! !-i! @@ -108,6 +112,8 @@ cat >expected <<\EOF !one@example.com! !two@example.com! EOF +' + test_expect_success $PREREQ \ 'Verify commandline' \ 'test_cmp expected commandline1' @@ -117,6 +123,7 @@ test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' ' git send-email --envelope-sender=auto --suppress-cc=sob --from="Example " --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors ' +test_expect_success $PREREQ 'setup expect' ' cat >expected <<\EOF !nobody@example.com! !-i! @@ -125,10 +132,13 @@ cat >expected <<\EOF !one@example.com! !two@example.com! EOF +' + test_expect_success $PREREQ \ 'Verify commandline' \ 'test_cmp expected commandline1' +test_expect_success $PREREQ 'setup expect' " cat >expected-show-all-headers <<\EOF 0001-Second.patch (mbox) Adding cc: A from line 'From: A ' @@ -158,6 +168,7 @@ References: Result: OK EOF +" test_expect_success $PREREQ 'Show all headers' ' git send-email \ @@ -209,10 +220,10 @@ test_expect_success $PREREQ 'cccmd works' ' grep "^ cccmd@example.com" msgtxt1 ' -z8=zzzzzzzz -z64=$z8$z8$z8$z8$z8$z8$z8$z8 -z512=$z64$z64$z64$z64$z64$z64$z64$z64 test_expect_success $PREREQ 'reject long lines' ' + z8=zzzzzzzz && + z64=$z8$z8$z8$z8$z8$z8$z8$z8 && + z512=$z64$z64$z64$z64$z64$z64$z64$z64 && clean_fake_sendmail && cp $patches longline.patch && echo $z512$z512 >>longline.patch && @@ -312,6 +323,7 @@ test_expect_success $PREREQ 'second message is patch' ' grep "Subject:.*Second" msgtxt2 ' +test_expect_success $PREREQ 'setup expect' " cat >expected-suppress-sob <<\EOF 0001-Second.patch (mbox) Adding cc: A from line 'From: A ' @@ -338,6 +350,7 @@ X-Mailer: X-MAILER-STRING Result: OK EOF +" test_suppression () { git send-email \ @@ -359,6 +372,7 @@ test_expect_success $PREREQ 'sendemail.cc set' ' test_suppression sob ' +test_expect_success $PREREQ 'setup expect' " cat >expected-suppress-sob <<\EOF 0001-Second.patch (mbox) Adding cc: A from line 'From: A ' @@ -383,12 +397,14 @@ X-Mailer: X-MAILER-STRING Result: OK EOF +" test_expect_success $PREREQ 'sendemail.cc unset' ' git config --unset sendemail.cc && test_suppression sob ' +test_expect_success $PREREQ 'setup expect' " cat >expected-suppress-cccmd <<\EOF 0001-Second.patch (mbox) Adding cc: A from line 'From: A ' @@ -416,6 +432,7 @@ X-Mailer: X-MAILER-STRING Result: OK EOF +" test_expect_success $PREREQ 'sendemail.cccmd' ' echo echo cc-cmd@example.com > cccmd && @@ -424,6 +441,7 @@ test_expect_success $PREREQ 'sendemail.cccmd' ' test_suppression cccmd ' +test_expect_success $PREREQ 'setup expect' ' cat >expected-suppress-all <<\EOF 0001-Second.patch Dry-OK. Log says: @@ -439,11 +457,13 @@ X-Mailer: X-MAILER-STRING Result: OK EOF +' test_expect_success $PREREQ '--suppress-cc=all' ' test_suppression all ' +test_expect_success $PREREQ 'setup expect' " cat >expected-suppress-body <<\EOF 0001-Second.patch (mbox) Adding cc: A from line 'From: A ' @@ -471,11 +491,13 @@ X-Mailer: X-MAILER-STRING Result: OK EOF +" test_expect_success $PREREQ '--suppress-cc=body' ' test_suppression body ' +test_expect_success $PREREQ 'setup expect' " cat >expected-suppress-body-cccmd <<\EOF 0001-Second.patch (mbox) Adding cc: A from line 'From: A ' @@ -500,11 +522,13 @@ X-Mailer: X-MAILER-STRING Result: OK EOF +" test_expect_success $PREREQ '--suppress-cc=body --suppress-cc=cccmd' ' test_suppression body cccmd ' +test_expect_success $PREREQ 'setup expect' " cat >expected-suppress-sob <<\EOF 0001-Second.patch (mbox) Adding cc: A from line 'From: A ' @@ -529,12 +553,14 @@ X-Mailer: X-MAILER-STRING Result: OK EOF +" test_expect_success $PREREQ '--suppress-cc=sob' ' git config --unset sendemail.cccmd test_suppression sob ' +test_expect_success $PREREQ 'setup expect' " cat >expected-suppress-bodycc <<\EOF 0001-Second.patch (mbox) Adding cc: A from line 'From: A ' @@ -562,11 +588,13 @@ X-Mailer: X-MAILER-STRING Result: OK EOF +" test_expect_success $PREREQ '--suppress-cc=bodycc' ' test_suppression bodycc ' +test_expect_success $PREREQ 'setup expect' " cat >expected-suppress-cc <<\EOF 0001-Second.patch (mbox) Adding cc: A from line 'From: A ' @@ -588,6 +616,7 @@ X-Mailer: X-MAILER-STRING Result: OK EOF +" test_expect_success $PREREQ '--suppress-cc=cc' ' test_suppression cc @@ -918,6 +947,7 @@ test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' ' ! grep "RCPT TO:" stdout ' +test_expect_success $PREREQ 'setup expect' ' cat >email-using-8bit < @@ -927,12 +957,15 @@ Subject: subject goes here Dieser deutsche Text enthält einen Umlaut! EOF +' +test_expect_success $PREREQ 'setup expect' ' cat >content-type-decl <email-using-8bit < @@ -979,10 +1013,13 @@ Subject: Dieser Betreff enthält auch einen Umlaut! Nothing to see here. EOF +' +test_expect_success $PREREQ 'setup expect' ' cat >expected < Date: Mon, 8 Jun 2009 23:34:12 +0200 Subject: send-email: Refuse to send cover-letter template subject Every so often, someone sends out an unedited cover-letter template. Add a simple check to send-email that refuses to send if the subject contains "*** SUBJECT HERE ***", with an option --force to override. Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 23597cc407..f3aedb9176 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -995,4 +995,40 @@ test_expect_success '--8bit-encoding also treats subject' ' test_cmp expected actual ' +# Note that the patches in this test are deliberately out of order; we +# want to make sure it works even if the cover-letter is not in the +# first mail. +test_expect_success 'refusing to send cover letter template' ' + clean_fake_sendmail && + rm -fr outdir && + git format-patch --cover-letter -2 -o outdir && + test_must_fail git send-email \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + outdir/0002-*.patch \ + outdir/0000-*.patch \ + outdir/0001-*.patch \ + 2>errors >out && + grep "SUBJECT HERE" errors && + test -z "$(ls msgtxt*)" +' + +test_expect_success '--force sends cover letter template anyway' ' + clean_fake_sendmail && + rm -fr outdir && + git format-patch --cover-letter -2 -o outdir && + git send-email \ + --force \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + outdir/0002-*.patch \ + outdir/0000-*.patch \ + outdir/0001-*.patch \ + 2>errors >out && + ! grep "SUBJECT HERE" errors && + test -n "$(ls msgtxt*)" +' + test_done -- cgit v1.2.3 From 6e74e075d25aea67cf973e456a6804c0c3741235 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 24 Sep 2010 10:03:00 -0700 Subject: git-send-email.perl: Add --to-cmd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the ability to use a command line --to-cmd=cmd to create the list of "To:" addresses. Used a shared routine for --cc-cmd and --to-cmd. Did not use IPC::Open2, leaving that for Ævar if ever he decides to fix the other bugs he might find. Signed-off-by: Joe Perches Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 71b3df9b55..36cf421dd0 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -201,6 +201,24 @@ test_expect_success $PREREQ 'Prompting works' ' grep "^To: to@example.com\$" msgtxt1 ' +test_expect_success $PREREQ 'tocmd works' ' + clean_fake_sendmail && + cp $patches tocmd.patch && + echo tocmd--tocmd@example.com >>tocmd.patch && + { + echo "#!$SHELL_PATH" + echo sed -n -e s/^tocmd--//p \"\$1\" + } > tocmd-sed && + chmod +x tocmd-sed && + git send-email \ + --from="Example " \ + --to-cmd=./tocmd-sed \ + --smtp-server="$(pwd)/fake.sendmail" \ + tocmd.patch \ + && + grep "^To: tocmd@example.com" msgtxt1 +' + test_expect_success $PREREQ 'cccmd works' ' clean_fake_sendmail && cp $patches cccmd.patch && -- cgit v1.2.3 From 21802cd32805b19fa32e8e3594ee3914733d53d3 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Wed, 29 Sep 2010 00:26:44 -0700 Subject: send-email: Use To: headers in patch files It's a minor annoyance when you take the painstaking time to setup To: headers for each patch in a large series, and then go out to send the series with git-send-email and watch git ignore the To: headers in the patch files. Therefore, always add To: headers from a patch file to the To: headers for that message. Keep the prompt for the blanket To: header so as to not break scripts (and user expectations). This means even if a patch has a To: header, git will prompt for the To: address. Otherwise, we'll need to introduce interface breakage to either request the header for each patch missing a To: header or default the header to whatever To: address is found first (be it in a patch or from user input). Both of these options don't seem very obvious/useful. Reported-by: Viresh Kumar Signed-off-by: Stephen Boyd Tested-by: Viresh Kumar Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 71b3df9b55..294e31f7f0 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -947,6 +947,30 @@ test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' ' ! grep "RCPT TO:" stdout ' +test_expect_success $PREREQ 'patches To headers are used by default' ' + patch=`git format-patch -1 --to="bodies@example.com"` && + test_when_finished "rm $patch" && + git send-email \ + --dry-run \ + --from="Example " \ + --smtp-server relay.example.com \ + $patch >stdout && + grep "RCPT TO:" stdout +' + +test_expect_success $PREREQ 'patches To headers are appended to' ' + patch=`git format-patch -1 --to="bodies@example.com"` && + test_when_finished "rm $patch" && + git send-email \ + --dry-run \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server relay.example.com \ + $patch >stdout && + grep "RCPT TO:" stdout && + grep "RCPT TO:" stdout +' + test_expect_success $PREREQ 'setup expect' ' cat >email-using-8bit < Date: Thu, 30 Sep 2010 13:43:09 +0000 Subject: send-email: use Perl idioms in while loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change `while(<$fh>) { my $c = $_' to `while(my $c = <$fh>) {', and use `chomp $c' instead of `$c =~ s/\n$//g;', the two are equivalent in this case. I've also changed the --cccmd test so that we test for the stripping of whitespace at the beginning of the lines returned from the --cccmd. I think we probably shouldn't do this, but it was there already so I haven't changed the behavior. Signed-off-by: Ævar Arnfjörð Bjarmason Reviewed-by: Jeff King > Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 6f67da4e71..99a16d5750 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -204,7 +204,7 @@ test_expect_success $PREREQ 'Prompting works' ' test_expect_success $PREREQ 'cccmd works' ' clean_fake_sendmail && cp $patches cccmd.patch && - echo cccmd--cccmd@example.com >>cccmd.patch && + echo "cccmd-- cccmd@example.com" >>cccmd.patch && { echo "#!$SHELL_PATH" echo sed -n -e s/^cccmd--//p \"\$1\" -- cgit v1.2.3 From 3c3bb51c3b205a6838b022896c9323d4b25bf392 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Mon, 4 Oct 2010 00:05:24 -0700 Subject: send-email: Don't leak To: headers between patches If the first patch in a series has a To: header in the file and the second patch in the series doesn't the address from the first patch will be part of the To: addresses in the second patch. Fix this by treating the to list like the cc list. Have an initial to list come from the command line, user input and config options. Then build up a to list from each patch and concatenate the two together before sending the patch. Finally, reset the list after sending each patch so the To: headers from a patch don't get used for the next one. Reported-by: Viresh Kumar Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 294e31f7f0..13d8d1a8b4 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -971,6 +971,21 @@ test_expect_success $PREREQ 'patches To headers are appended to' ' grep "RCPT TO:" stdout ' +test_expect_success $PREREQ 'To headers from files reset each patch' ' + patch1=`git format-patch -1 --to="bodies@example.com"` && + patch2=`git format-patch -1 --to="other@example.com" HEAD~` && + test_when_finished "rm $patch1 && rm $patch2" && + git send-email \ + --dry-run \ + --from="Example " \ + --to="nobody@example.com" \ + --smtp-server relay.example.com \ + $patch1 $patch2 >stdout && + test $(grep -c "RCPT TO:" stdout) = 1 && + test $(grep -c "RCPT TO:" stdout) = 2 && + test $(grep -c "RCPT TO:" stdout) = 1 +' + test_expect_success $PREREQ 'setup expect' ' cat >email-using-8bit < Date: Tue, 19 Oct 2010 11:50:39 +0200 Subject: t/t9001-send-email.sh: fix stderr redirection in 'Invalid In-Reply-To' Signed-off-by: Antonio Ospite Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 71b3df9b55..07c50c764c 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -279,7 +279,7 @@ test_expect_success $PREREQ 'Invalid In-Reply-To' ' --to=nobody@example.com \ --in-reply-to=" " \ --smtp-server="$(pwd)/fake.sendmail" \ - $patches + $patches \ 2>errors ! grep "^In-Reply-To: < *>" msgtxt1 ' -- cgit v1.2.3 From 54aae5e1a08cb8c788d6f7345ca29898a5941140 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 19 Oct 2010 11:46:31 -0700 Subject: t9001: send-email interation with --in-reply-to and --chain-reply-to 1. When --in-reply-to gives $reply_to, the first one becomes a reply to that message, with or without --chain-reply-to. 2. When --chain-reply-to is in effect, all the messages are strung together to form a single chain. The first message may be in reply to the $reply_to given by --in-reply-to command line option (see previous), or the root of the discussion thread. The second one is a response to the first one, and the third one is a response to the second one, etc. 3. When --chain-reply-to is not in effect: a. When --in-reply-to is used, too, the second and the subsequent ones become replies to $reply_to. Together with the first rule, all messages become replies to $reply_to given by --in-reply-to. b. When --in-reply-to is not used, presumably the second and subsequent ones become replies to the first one, which would be the root. The documentation is reasonably clear about the 1., 2. and 3a. above, I think, even though I do not think 3b. is clearly specified. The two tests added by this patch at least documents what happens between these two options. Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index d1ba25205b..26c2e93c43 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -313,6 +313,47 @@ test_expect_success $PREREQ 'Valid In-Reply-To when prompting' ' ! grep "^In-Reply-To: < *>" msgtxt1 ' +test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' ' + clean_fake_sendmail && + echo "" >expect && + git send-email \ + --from="Example " \ + --to=nobody@example.com \ + --no-chain-reply-to \ + --in-reply-to="$(cat expect)" \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches $patches $patches \ + 2>errors && + # All the messages are replies to --in-reply-to + sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual && + test_cmp expect actual && + sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual && + test_cmp expect actual && + sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual && + test_cmp expect actual +' + +test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' ' + clean_fake_sendmail && + echo "" >expect && + git send-email \ + --from="Example " \ + --to=nobody@example.com \ + --chain-reply-to \ + --in-reply-to="$(cat expect)" \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches $patches $patches \ + 2>errors && + sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual && + test_cmp expect actual && + sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect && + sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual && + test_cmp expect actual && + sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect && + sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual && + test_cmp expect actual +' + test_expect_success $PREREQ 'setup fake editor' ' (echo "#!$SHELL_PATH" && echo "echo fake edit >>\"\$1\"" -- cgit v1.2.3 From db54c8e710397fbd58892daead6181b424d6d70a Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Fri, 12 Nov 2010 15:55:08 +0100 Subject: git-send-email.perl: make initial In-Reply-To apply only to first email When an initial --in-reply-to is supplied, make it apply only to the first message; --[no-]chain-reply-to setting are honored by second and subsequent messages; this is also how the git-format-patch option with the same name behaves. Moreover, when $initial_reply_to is asked to the user interactively it is asked as the "Message-ID to be used as In-Reply-To for the _first_ email", this makes the user think that the second and subsequent patches are not using it but are considered as replies to the first message or chained according to the --[no-]chain-reply setting. Look at the v2 series in the illustration to see what the new behavior ensures: (before the patch) | (after the patch) [PATCH 0/2] Here is what I did... | [PATCH 0/2] Here is what I did... [PATCH 1/2] Clean up and tests | [PATCH 1/2] Clean up and tests [PATCH 2/2] Implementation | [PATCH 2/2] Implementation [PATCH v2 0/3] Here is a reroll | [PATCH v2 0/3] Here is a reroll [PATCH v2 1/3] Clean up | [PATCH v2 1/3] Clean up [PATCH v2 2/3] New tests | [PATCH v2 2/3] New tests [PATCH v2 3/3] Implementation | [PATCH v2 3/3] Implementation This is the typical behaviour we want when we send a series with cover letter in reply to some discussion, the new patch series should appear as a separate subtree in the discussion. Also update the documentation on --in-reply-to to describe the new behavior. Signed-off-by: Antonio Ospite Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 26c2e93c43..5e48318013 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -324,9 +324,11 @@ test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' ' --smtp-server="$(pwd)/fake.sendmail" \ $patches $patches $patches \ 2>errors && - # All the messages are replies to --in-reply-to + # The first message is a reply to --in-reply-to sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual && test_cmp expect actual && + # Second and subsequent messages are replies to the first one + sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect && sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual && test_cmp expect actual && sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual && -- cgit v1.2.3 From d2559f734bba7fe5257720356a92f3b7a5b0d37c Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Wed, 22 Dec 2010 15:58:53 -0800 Subject: t9001: use older Getopt::Long boolean prefix '--no' rather than '--no-' The '--no-chain-reply-to' option is a Getopt::Long boolean option. The '--no-' prefix (as in --no-chain-reply-to) for boolean options is not supported in Getopt::Long version 2.32 which was released with Perl 5.8.0. This version only supports '--no' as in '--nochain-reply-to'. More recent versions of Getopt::Long, such as version 2.34, support either prefix. So use the older form in the tests. See also: 907a0b1e04ea31cb368e9422df93d8ebb0187914 84eeb687de7a6c7c42af3fb51b176e0f412a979e 3fee1fe87144360a1913eab86af9ad136c810076 Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 5e48318013..1dc4a9228e 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -319,7 +319,7 @@ test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' ' git send-email \ --from="Example " \ --to=nobody@example.com \ - --no-chain-reply-to \ + --nochain-reply-to \ --in-reply-to="$(cat expect)" \ --smtp-server="$(pwd)/fake.sendmail" \ $patches $patches $patches \ -- cgit v1.2.3 From 57da20426417cd0834e7fc442096d1c18924228a Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Wed, 29 Dec 2010 21:02:31 +0000 Subject: t9001: Fix test prerequisites Add in missing Perl prerequisites for new tests of send-email. Signed-off-by: Robin H. Johnson Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index a298eb0437..f1047d2ef3 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -1035,7 +1035,7 @@ test_expect_success $PREREQ '--8bit-encoding also treats subject' ' # Note that the patches in this test are deliberately out of order; we # want to make sure it works even if the cover-letter is not in the # first mail. -test_expect_success 'refusing to send cover letter template' ' +test_expect_success $PREREQ 'refusing to send cover letter template' ' clean_fake_sendmail && rm -fr outdir && git format-patch --cover-letter -2 -o outdir && @@ -1051,7 +1051,7 @@ test_expect_success 'refusing to send cover letter template' ' test -z "$(ls msgtxt*)" ' -test_expect_success '--force sends cover letter template anyway' ' +test_expect_success $PREREQ '--force sends cover letter template anyway' ' clean_fake_sendmail && rm -fr outdir && git format-patch --cover-letter -2 -o outdir && -- cgit v1.2.3 From cc7e81674b9fef94e64fe3e8c134f1a27ce2fa25 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Tue, 4 Jan 2011 21:56:58 +0100 Subject: t/t9001-send-email.sh: fix '&&' chain in some tests t/README recommends chaining test assertions. Signed-off-by: Antonio Ospite Signed-off-by: Junio C Hamano --- t/t9001-send-email.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 't/t9001-send-email.sh') diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 5e48318013..2fb22d0fbc 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -265,7 +265,7 @@ test_expect_success $PREREQ 'Author From: in message body' ' --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ $patches && - sed "1,/^\$/d" < msgtxt1 > msgbody1 + sed "1,/^\$/d" < msgtxt1 > msgbody1 && grep "From: A " msgbody1 ' @@ -276,7 +276,7 @@ test_expect_success $PREREQ 'Author From: not in message body' ' --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ $patches && - sed "1,/^\$/d" < msgtxt1 > msgbody1 + sed "1,/^\$/d" < msgtxt1 > msgbody1 && ! grep "From: A " msgbody1 ' @@ -298,7 +298,7 @@ test_expect_success $PREREQ 'Invalid In-Reply-To' ' --in-reply-to=" " \ --smtp-server="$(pwd)/fake.sendmail" \ $patches \ - 2>errors + 2>errors && ! grep "^In-Reply-To: < *>" msgtxt1 ' @@ -617,7 +617,7 @@ EOF " test_expect_success $PREREQ '--suppress-cc=sob' ' - git config --unset sendemail.cccmd + test_might_fail git config --unset sendemail.cccmd && test_suppression sob ' -- cgit v1.2.3