Skip to contentSkip to conversation

git-send-email not sending?

PATCH In review Seth Falcon 3 participants 8 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

I'm using git version 1.5.4.rc3.37.gfdcf3 and when I use git-send-email with the --compose option like this:

   git send-email --compose -- a_dir_of_patches/

The intro email gets sent, but not any of the actual patches. If I ommit the --compose option, then the patches do get sent. Pretty sure this worked for me until a recent update so I wonder if there's a buglet in the recent validation patches (or I'm in error and missing some needed config?).

+ seth

Signature · 1 line
Seth Falcon | [email protected] | blog: http://userprimary.net/user/
#1 lore raw

Test of send-email patch

This email is sent with git send-email --compose to verify that the patch following in the next mail fixes the problem reported by Seth.

/Gustaf

#2 lore raw

PATCH 1/1 send-email, fix breakage in combination with --compose

This fixes the subtile bug in git send-email that was introduced into git send-email with

commit aa54892f5ada8282643dc7387b33261c7135d784
send-email: detect invocation errors earlier

causing no patches to be sent out if the --compose flag was used.

---
 git-send-email.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
git-send-email.perl +1 -1
index 6c72952..a1a9d14 100755
@@ -462,7 +462,7 @@ EOT
 		exit(0);
 	}
 
-	@files = ($compose_filename . ".final");
+	@files = ($compose_filename . ".final", @files);
 }
 
 # Variables we set as part of the loop over files
Signature · 1 line
1.5.4.rc4.1.gbdcdb
Acked-by on v1 1/1
#3 lore raw

Re: [PATCH] send-email, fix breakage in combination with --compose

Quoted 5 lines · Gustaf Hendeby

This fixes the subtile bug in git send-email that was introduced into git send-email with

commit aa54892f5ada8282643dc7387b33261c7135d784
send-email: detect invocation errors earlier

Sorry, this was my fault. I have looked over the code again to make sure there are not any other places where the movement of @files should matter, but this seems to be the only one.

As penance, I'll send some tests in a moment.

git-send-email.perl EOT · line 465

Quoted 2 lines
git-send-email.perl +1 -1
-	@files = ($compose_filename . ".final");
+	@files = ($compose_filename . ".final", @files);

I think this might be more readable as

unshift @files, "$compose_filename.final";

but either way it fixes the bug, so

-Peff

#4 lore raw

PATCH 1/3 t9001: add missing && operators

The exit value of some commands was not being used for the test output.

---

Quoted 1 line · Jeff King

As penance, I'll send some tests in a moment.

This turned into a 3-patch series because of some cleanup needed. This first one is just tightening up the setup tests, which will be modified in the next patch.

 t/t9001-send-email.sh |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
t/t9001-send-email.sh +4 -4
index 4f6822f..08f7c3d 100755
@@ -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' '
Signature · 1 line
1.5.4.rc3.1130.gd9718-dirty
#5 lore raw

PATCH 2/3 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 which were sent, and in which order.

---
This shouldn't change the test behavior at all, but is needed for the test in 3/3.

 t/t9001-send-email.sh |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
t/t9001-send-email.sh +11 -5
index 08f7c3d..dd0c395 100755
@@ -15,16 +15,22 @@ test_expect_success \
     'Setup helper tool' \
     '(echo "#!/bin/sh"
       echo shift
+      echo output=1
+      echo "while test -e 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' '
Signature · 1 line
1.5.4.rc3.1130.gd9718-dirty
#6 lore raw

PATCH 3/3 send-email: test compose functionality

This is just a basic sanity check that --compose works at all. Unfortunately, we have to add a --no-confirm-send option to git-send-email to make this work, since it otherwise unconditionally tries to talk to the terminal.

---
Note that the change to git-send-email depends textually on Gustaf's fix (actually, on my suggested version). I am not happy with adding the --no-confirm-send option, but there just isn't any way to avoid the readline call with the existing code short of providing a dummy perl module in the test harness.

 git-send-email.perl   |   16 ++++++++++------
 t/t9001-send-email.sh |   27 +++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 6 deletions(-)
git-send-email.perl +10 -6
index df1c833..f265a82 100755
@@ -180,6 +180,7 @@ my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc, $cc_cmd);
 my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_authpass, $smtp_ssl);
 my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);
 my ($no_validate);
+my ($no_confirm_send);
 
 my %config_bool_settings = (
     "thread" => [\$thread, 1],
@@ -226,6 +227,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
 		    "envelope-sender=s" => \$envelope_sender,
 		    "thread!" => \$thread,
 		    "no-validate" => \$no_validate,
+		    "no-confirm-send" => \$no_confirm_send,
 	 );
 
 unless ($rc) {
@@ -453,13 +455,15 @@ EOT
 	close(C);
 	close(C2);
 
-	do {
-		$_ = $term->readline("Send this email? (y|n) ");
-	} while (!defined $_);
+	if (!$no_confirm_send) {
+		do {
+			$_ = $term->readline("Send this email? (y|n) ");
+		} while (!defined $_);
 
-	if (uc substr($_,0,1) ne 'Y') {
-		cleanup_compose_files();
-		exit(0);
+		if (uc substr($_,0,1) ne 'Y') {
+			cleanup_compose_files();
+			exit(0);
+		}
 	}
 
 	unshift @files, "$compose_filename.final";
t/t9001-send-email.sh +27 -0
index dd0c395..b1e9de5 100755
@@ -114,4 +114,31 @@ test_expect_success 'allow long lines with --no-validate' '
 		2>errors
 '
 
+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 &&
+	GIT_EDITOR=$(pwd)/fake-editor \
+	git send-email \
+		--compose --subject foo --no-confirm-send \
+		--from="Example <[email protected]>" \
+		[email protected] \
+		--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
Signature · 1 line
1.5.4.rc3.1130.gd9718-dirty
author Acked-by on v1 1/1
#7 lore raw

Re: [PATCH] send-email, fix breakage in combination with --compose

In reply to Gustaf Hendeby

Hi Gustaf,

Quoted 9 lines · Gustaf Hendeby

This fixes the subtile bug in git send-email that was introduced into git send-email with

commit aa54892f5ada8282643dc7387b33261c7135d784
send-email: detect invocation errors earlier

causing no patches to be sent out if the --compose flag was used.

I gave this a quick test and it works for me too. Thanks!

So FWIW,

Signature · 1 line
Seth Falcon | [email protected] | blog: http://userprimary.net/user/