threads / discuss / 11694

git-send-email not sending?

Subject: git-send-email not sending?

## tl;dr

8 messages between Jan 21, 2008 and Jan 22, 2008.

replies: 7people: 3as markdown or json

Seth Falcon· Jan 21, 2008, 18:30 UTC · lore
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
-- 
Seth Falcon | seth@userprimary.net | blog: http://userprimary.net/user/
Gustaf Hendeby· Jan 21, 2008, 19:57 UTC · re: Gustaf Hendeby · lore

[PATCH] 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.
Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>
---
 git-send-email.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 6c72952..a1a9d14 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -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
-- 
1.5.4.rc4.1.gbdcdb
Seth Falcon· Jan 22, 2008, 00:05 UTC · re: Gustaf Hendeby · lore

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

Hi Gustaf,
Gustaf Hendeby <hendeby@isy.liu.se> writes:
Show 9 quoted lines
> 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.
>
> Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>
I gave this a quick test and it works for me too.  Thanks!
So FWIW,
Acked-by: Seth Falcon <seth@userprimary.net>
-- 
Seth Falcon | seth@userprimary.net | blog: http://userprimary.net/user/
Jeff King· Jan 22, 2008, 03:19 UTC · re: Gustaf Hendeby · lore

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

On Mon, Jan 21, 2008 at 08:57:46PM +0100, Gustaf Hendeby wrote:
Show 5 quoted lines
> 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.
> -	@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
Acked-by: Jeff King <peff@peff.net>
-Peff
Jeff King· Jan 22, 2008, 03:23 UTC · re: Jeff King · lore

[PATCH 1/3] t9001: add missing && operators

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

Signed-off-by: Jeff King <peff@peff.net>
---
On Mon, Jan 21, 2008 at 10:19:32PM -0500, Jeff King wrote:
> 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(-)
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 4f6822f..08f7c3d 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' '
-- 
1.5.4.rc3.1130.gd9718-dirty
Jeff King· Jan 22, 2008, 03:25 UTC · re: Jeff King · lore

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

Signed-off-by: Jeff King <peff@peff.net>
---
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(-)
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 08f7c3d..dd0c395 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 -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' '
-- 
1.5.4.rc3.1130.gd9718-dirty
Jeff King· Jan 22, 2008, 03:29 UTC · re: Jeff King · lore

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

Signed-off-by: Jeff King <peff@peff.net>
---
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(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index df1c833..f265a82 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -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";
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index dd0c395..b1e9de5 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -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 <nobody@example.com>" \
+		--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
-- 
1.5.4.rc3.1130.gd9718-dirty

← back to recent threads