Skip to contentSkip to conversation

git send-email suppress-cc=self fixes

PATCH Superseded Michael S. Tsirkin 2 participants 12 messages Jun 15, 2016

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover git send-email suppress-cc=self fixes

This includes bugfixes related to handling of --suppress-cc=self flag. Tests are also included.

Signature · 1 line
MST
#1 lore raw

PATCH 1/6 t/send-email.sh: add test for suppress self

---
 t/t9001-send-email.sh | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
t/t9001-send-email.sh +41 -0
index ebd5c5d..36ecf73 100755
@@ -171,6 +171,47 @@ Result: OK
 EOF
 "
 
+test_suppress_self () {
+		test_commit $3 &&
+		test_when_finished "git reset --hard HEAD^" &&
+		{
+			echo "#!$SHELL_PATH"
+			echo sed -n -e s/^cccmd--//p \"\$1\"
+		} > cccmd-sed &&
+		chmod +x cccmd-sed &&
+		git commit --amend --author="$1 <$2>" -F - << EOF && \
+		clean_fake_sendmail && \
+		echo suppress-self-$3.patch > /dev/tty && \
+		git format-patch --stdout -1 >suppress-self-$3.patch && \
+		git send-email --from="$1 <$2>" \
+		[email protected] \
+		--cc-cmd=./cccmd-sed \
+		--suppress-cc=self \
+		--smtp-server="$(pwd)/fake.sendmail" \
+		suppress-self-$3.patch && \
+		mv msgtxt1 msgtxt1-$3 && \
+		sed -e '/^$/q' msgtxt1-$3 > msghdr1-$3 && \
+		rm -f expected-no-cc-$3 && \
+		touch expected-no-cc-$3 && \
+		grep '^Cc:' msghdr1-$3 > actual-no-cc-$3 && \
+		test_cmp expected-no-cc-$3 actual-no-cc-$3
+test suppress-cc.self $3 with name $1 email $2
+
+$3
+
+cccmd--"$1" <$2>
+
+Cc: "$1" <$2>
+Cc: $1 <$2>
+Signed-off-by: "$1" <$2>
+Signed-off-by: $1 <$2>
+EOF
+}
+
+test_expect_success $PREREQ 'self name is suppressed' "
+	test_suppress_self 'A U Thor' '[email protected]' 'self_name_suppressed'
+"
+
 test_expect_success $PREREQ 'Show all headers' '
 	git send-email \
 		--dry-run \
Signature · 1 line
MST
#7 lore raw

PATCH 2/6 send-email: fix suppress-cc=self on cccmd

In reply to Michael S. Tsirkin

When cccmd is used, old-style suppress-from filter is applied by the newer suppress-cc=self isn't. Fix this up.

---
 git-send-email.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git-send-email.perl +1 -1
index bd13cc8..a138615 100755
@@ -1462,7 +1462,7 @@ sub recipients_cmd {
 		$address =~ s/^\s*//g;
 		$address =~ s/\s*$//g;
 		$address = sanitize_address($address);
-		next if ($address eq $sanitized_sender and $suppress_from);
+		next if ($address eq $sender and $suppress_cc{'self'});
 		push @addresses, $address;
 		printf("($prefix) Adding %s: %s from: '%s'\n",
 		       $what, $address, $cmd) unless $quiet;
Signature · 1 line
MST
#8 lore raw

PATCH 3/6 t/send-email: test suppress-cc=self on cccmd

In reply to Michael S. Tsirkin

Check that suppress-cc=self works when applied
to output of cccmd.

---
 t/t9001-send-email.sh | 50 +++++++++++++++++++++++++++++++++-----------------
 1 file changed, 33 insertions(+), 17 deletions(-)
t/t9001-send-email.sh +33 -17
index 36ecf73..8aa55f8 100755
@@ -179,37 +179,53 @@ test_suppress_self () {
 			echo sed -n -e s/^cccmd--//p \"\$1\"
 		} > cccmd-sed &&
 		chmod +x cccmd-sed &&
-		git commit --amend --author="$1 <$2>" -F - << EOF && \
-		clean_fake_sendmail && \
-		echo suppress-self-$3.patch > /dev/tty && \
-		git format-patch --stdout -1 >suppress-self-$3.patch && \
-		git send-email --from="$1 <$2>" \
+		git commit --amend --author="$1 <$2>" -F - && 
+		clean_fake_sendmail && 
+		git format-patch --stdout -1 >suppress-self-$3.patch && 
+		git send-email --from="$1 <$2>"  \
 		[email protected] \
 		--cc-cmd=./cccmd-sed \
 		--suppress-cc=self \
 		--smtp-server="$(pwd)/fake.sendmail" \
-		suppress-self-$3.patch && \
-		mv msgtxt1 msgtxt1-$3 && \
-		sed -e '/^$/q' msgtxt1-$3 > msghdr1-$3 && \
-		rm -f expected-no-cc-$3 && \
-		touch expected-no-cc-$3 && \
-		grep '^Cc:' msghdr1-$3 > actual-no-cc-$3 && \
-		test_cmp expected-no-cc-$3 actual-no-cc-$3
-test suppress-cc.self $3 with name $1 email $2
+		suppress-self-$3.patch && 
+		mv msgtxt1 msgtxt1-$3 && 
+		sed -e '/^$/q' msgtxt1-$3 > msghdr1-$3 && 
+		rm -f expected-no-cc-$3 && 
+		touch expected-no-cc-$3 && 
+		(grep '^Cc:' msghdr1-$3 > actual-no-cc-$3;
+		 test_cmp expected-no-cc-$3 actual-no-cc-$3)
+}
+
+test_suppress_self_unquoted () {
+test_suppress_self "$1" "$2" "unquoted-$3" << EOF
+		test suppress-cc.self unquoted-$3 with name $1 email $2
+unquoted-$3
+
+cccmd--$1 <$2>
+
+Cc: $1 <$2>
+Signed-off-by: $1 <$2>
+EOF
+}
+
+test_suppress_self_quoted () {
+test_suppress_self "$1" "$2" "quoted-$3" << EOF
+test suppress-cc.self quoted-$3 with name $1 email $2
 
-$3
+quoted-$3
 
 cccmd--"$1" <$2>
 
-Cc: "$1" <$2>
 Cc: $1 <$2>
-Signed-off-by: "$1" <$2>
+Cc: "$1" <$2>
 Signed-off-by: $1 <$2>
+Signed-off-by: "$1" <$2>
 EOF
 }
 
+
 test_expect_success $PREREQ 'self name is suppressed' "
-	test_suppress_self 'A U Thor' '[email protected]' 'self_name_suppressed'
+	test_suppress_self_unquoted 'A U Thor' '[email protected]' 'self_name_suppressed'
 "
 
 test_expect_success $PREREQ 'Show all headers' '
Signature · 1 line
MST
#9 lore raw

PATCH 4/6 send-email: make --suppress-cc=self sanitize input

In reply to Michael S. Tsirkin

--suppress-cc=self fails to filter sender address in many cases where it needs to be sanitized in some way, for example quoted:
"A U. Thor" <[email protected]>
To fix, make send-email sanitize both sender and the address it is compared against.

---
 git-send-email.perl | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
git-send-email.perl +11 -7
index a138615..92df393 100755
@@ -760,6 +760,8 @@ if (!defined $sender) {
 	$sender = $repoauthor || $repocommitter || '';
 }
 
+$sender = sanitize_address($sender);
+
 my $prompting = 0;
 if (!@initial_to && !defined $to_cmd) {
 	my $to = ask("Who should the emails be sent to (if any)? ",
@@ -1113,10 +1115,9 @@ sub send_message {
 	if ($cc ne '') {
 		$ccline = "\nCc: $cc";
 	}
-	my $sanitized_sender = sanitize_address($sender);
 	make_message_id() unless defined($message_id);
 
-	my $header = "From: $sanitized_sender
+	my $header = "From: $sender
 To: $to${ccline}
 Subject: $subject
 Date: $date
@@ -1133,7 +1134,7 @@ X-Mailer: git-send-email $gitversion
 	}
 
 	my @sendmail_parameters = ('-i', @recipients);
-	my $raw_from = $sanitized_sender;
+	my $raw_from = $sender;
 	if (defined $envelope_sender && $envelope_sender ne "auto") {
 		$raw_from = $envelope_sender;
 	}
@@ -1308,8 +1309,9 @@ foreach my $t (@files) {
 			}
 			elsif (/^From:\s+(.*)$/i) {
 				($author, $author_encoding) = unquote_rfc2047($1);
+				my $sauthor = sanitize_address($author);
 				next if $suppress_cc{'author'};
-				next if $suppress_cc{'self'} and $author eq $sender;
+				next if $suppress_cc{'self'} and $sauthor eq $sender;
 				printf("(mbox) Adding cc: %s from line '%s'\n",
 					$1, $_) unless $quiet;
 				push @cc, $1;
@@ -1323,7 +1325,9 @@ foreach my $t (@files) {
 			}
 			elsif (/^Cc:\s+(.*)$/i) {
 				foreach my $addr (parse_address_line($1)) {
-					if (unquote_rfc2047($addr) eq $sender) {
+					my $qaddr = unquote_rfc2047($addr);
+					my $saddr = sanitize_address($qaddr);
+					if ($saddr eq $sender) {
 						next if ($suppress_cc{'self'});
 					} else {
 						next if ($suppress_cc{'cc'});
@@ -1370,7 +1374,8 @@ foreach my $t (@files) {
 			chomp;
 			my ($what, $c) = ($1, $2);
 			chomp $c;
-			if ($c eq $sender) {
+			my $sc = sanitize_address($c);
+			if ($sc eq $sender) {
 				next if ($suppress_cc{'self'});
 			} else {
 				next if $suppress_cc{'sob'} and $what =~ /Signed-off-by/i;
@@ -1454,7 +1459,6 @@ foreach my $t (@files) {
 sub recipients_cmd {
 	my ($prefix, $what, $cmd, $file) = @_;
 
-	my $sanitized_sender = sanitize_address($sender);
 	my @addresses = ();
 	open my $fh, "-|", "$cmd \Q$file\E"
 	    or die "($prefix) Could not execute '$cmd'";
Signature · 1 line
MST
#10 lore raw

PATCH 5/6 t/send-email: add test with quoted sender

In reply to Michael S. Tsirkin

add test where sender address needs to be quoted. Make sure --suppress-cc=self works well in this case.

---
 t/t9001-send-email.sh | 4 ++++
 1 file changed, 4 insertions(+)
t/t9001-send-email.sh +4 -0
index 8aa55f8..0ab4056 100755
@@ -228,6 +228,10 @@ test_expect_success $PREREQ 'self name is suppressed' "
 	test_suppress_self_unquoted 'A U Thor' '[email protected]' 'self_name_suppressed'
 "
 
+test_expect_success $PREREQ 'quoted self name is suppressed' "
+	test_suppress_self_quoted 'A U. Thor' '[email protected]' 'self_name_suppressed'
+"
+
 test_expect_success $PREREQ 'Show all headers' '
 	git send-email \
 		--dry-run \
Signature · 1 line
MST
#11 lore raw

PATCH 6/6 t/send-email: test suppress-cc=self with non-ascii

In reply to Michael S. Tsirkin

test suppress-cc=self when sender is non-acsii

---
 t/t9001-send-email.sh | 4 ++++
 1 file changed, 4 insertions(+)
t/t9001-send-email.sh +4 -0
index 0ab4056..66ebb1e 100755
@@ -232,6 +232,10 @@ test_expect_success $PREREQ 'quoted self name is suppressed' "
 	test_suppress_self_quoted 'A U. Thor' '[email protected]' 'self_name_suppressed'
 "
 
+test_expect_success $PREREQ 'non-ascii self name is suppressed' "
+	test_suppress_self_quoted 'Füñný Nâmé' '[email protected]' 'non_ascii_self_suppressed'
+"
+
 test_expect_success $PREREQ 'Show all headers' '
 	git send-email \
 		--dry-run \
Signature · 1 line
MST
#2 lore raw

Re: [PATCH 1/6] t/send-email.sh: add test for suppress self

In reply to Michael S. Tsirkin
Quoted 2 lines · Michael S. Tsirkin

---

Thanks.

Quoted 9 lines
 t/t9001-send-email.sh | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
t/t9001-send-email.sh +0 -0
index ebd5c5d..36ecf73 100755
@@ -171,6 +171,47 @@ Result: OK
 EOF

t/t9001-send-email.sh Result: OK · line 181

Quoted 10 lines
t/t9001-send-email.sh +8 -0
 "
 
+test_suppress_self () {
+		test_commit $3 &&
+		test_when_finished "git reset --hard HEAD^" &&
+		{
+			echo "#!$SHELL_PATH"
+			echo sed -n -e s/^cccmd--//p \"\$1\"
+		} > cccmd-sed &&
+		chmod +x cccmd-sed &&

We can use write_script for this kind of thing, I think.

t/t9001-send-email.sh Result: OK · line 182

Quoted 1 line
t/t9001-send-email.sh +1 -0
+		git commit --amend --author="$1 <$2>" -F - << EOF && \

Hmm,... everything below this function is fed as the standard input to "git commit" as its updated log message (i.e. "--amend -F -")?

Puzzled...

The EOF I can find is at the very bottom of this function, so there is no "next command" that && at the end of the above line is cascading the control to.

Doubly puzzled...

In any case, please do not add " \" at the end of line when the line ends one command and "&&" at the end of line clearly tells the shell that you haven't stopped talking yet.

t/t9001-send-email.sh Result: OK · line 184

Quoted 2 lines
t/t9001-send-email.sh +2 -0
+		clean_fake_sendmail && \
+		echo suppress-self-$3.patch > /dev/tty && \

Do we always have /dev/tty? If this is a leftover debugging, please remove it. If redirecting it to >&2 does not upset what the test does, that is good, too (you can run the test with -v option to view the output).

t/t9001-send-email.sh Result: OK · line 193

Quoted 9 lines
t/t9001-send-email.sh +9 -0
+		git format-patch --stdout -1 >suppress-self-$3.patch && \
+		git send-email --from="$1 <$2>" \
+		[email protected] \
+		--cc-cmd=./cccmd-sed \
+		--suppress-cc=self \
+		--smtp-server="$(pwd)/fake.sendmail" \
+		suppress-self-$3.patch && \
+		mv msgtxt1 msgtxt1-$3 && \
+		sed -e '/^$/q' msgtxt1-$3 > msghdr1-$3 && \

Style. No SP between redirection operator and redirection target, e.g. >$filename, <$filename, etc. Some in this patch is done correctly (e.g. format-patch above), some others are not.

t/t9001-send-email.sh Result: OK · line 195

Quoted 2 lines
t/t9001-send-email.sh +2 -0
+		rm -f expected-no-cc-$3 && \
+		touch expected-no-cc-$3 && \

Please reserve "touch" for "make sure it has recent timestamp", not for "make sure it exists and is empty". The above two should be more like:

		>"expected-no-cc-$3" &&

Also, even though it is not required by POSIX, please dquote the redirection target filename if you have variable expansion. Some versions of bash (incorrectly) give warning if you don't.

Quoted 22 lines
t/t9001-send-email.sh +19 -0
+		grep '^Cc:' msghdr1-$3 > actual-no-cc-$3 && \
+		test_cmp expected-no-cc-$3 actual-no-cc-$3
+test suppress-cc.self $3 with name $1 email $2
+
+$3
+
+cccmd--"$1" <$2>
+
+Cc: "$1" <$2>
+Cc: $1 <$2>
+Signed-off-by: "$1" <$2>
+Signed-off-by: $1 <$2>
+EOF
+}
+
+test_expect_success $PREREQ 'self name is suppressed' "
+	test_suppress_self 'A U Thor' '[email protected]' 'self_name_suppressed'
+"
+
 test_expect_success $PREREQ 'Show all headers' '
 	git send-email \
 		--dry-run \
#3 lore raw

Re: [PATCH 1/6] t/send-email.sh: add test for suppress self

Quoted 6 lines · Junio C Hamano
Quoted 2 lines · Michael S. Tsirkin

---

Thanks.

Thanks, I'll address your comments and repost. You asked some questions below, so I tried to answer.

Quoted 11 lines
Quoted 11 lines
 t/t9001-send-email.sh | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
t/t9001-send-email.sh +0 -0
index ebd5c5d..36ecf73 100755
@@ -171,6 +171,47 @@ Result: OK
 EOF
 "
 
Quoted 10 lines

t/t9001-send-email.sh Result: OK · line 181

Quoted 8 lines
t/t9001-send-email.sh +8 -0
+test_suppress_self () {
+		test_commit $3 &&
+		test_when_finished "git reset --hard HEAD^" &&
+		{
+			echo "#!$SHELL_PATH"
+			echo sed -n -e s/^cccmd--//p \"\$1\"
+		} > cccmd-sed &&
+		chmod +x cccmd-sed &&

We can use write_script for this kind of thing, I think.

Important?
It's open-coded elsewhere in this test.

Quoted 10 lines

t/t9001-send-email.sh Result: OK · line 182

Quoted 1 line
t/t9001-send-email.sh +1 -0
+		git commit --amend --author="$1 <$2>" -F - << EOF && \

Hmm,... everything below this function is fed as the standard input to "git commit" as its updated log message (i.e. "--amend -F -")?

Puzzled...
The EOF I can find is at the very bottom of this function, so there is no "next command" that && at the end of the above line is cascading the control to.

Quoted 5 lines

Doubly puzzled...

In any case, please do not add " \" at the end of line when the line ends one command and "&&" at the end of line clearly tells the shell that you haven't stopped talking yet.

Note that \ make following lines count as continuation of this one. So they are *not* part of standard input.

Look here:

FOO << EOF && BAR && VAR
BLABLA
EOF

this feeds BLABLA as input to FOO, then
runs BAR and then VAR.

Now we don't want to put BAR and VAR on same line because that line is too long.
So we write the equivalent: \ followed by newline is same as space for shell, so we can write it as:

FOO << EOF && \
BAR && \
VAR
BLABLA
EOF

Clear now?

If we don't want to use \, this can also
be done like this:

FOO << EOF &&
BLABLA
EOF
BAR &&
VAR

I think this is what you suggest.

Quoted 6 lines

t/t9001-send-email.sh Result: OK · line 184

Quoted 3 lines
t/t9001-send-email.sh +2 -0
+		clean_fake_sendmail && \
+		echo suppress-self-$3.patch > /dev/tty && \

Do we always have /dev/tty? If this is a leftover debugging, please remove it.

Leftover.

Quoted 4 lines

If redirecting it to >&2 does not upset what the test
does, that is good, too (you can run the test with -v option to view the output).

Quoted 13 lines

t/t9001-send-email.sh Result: OK · line 193

Quoted 9 lines
t/t9001-send-email.sh +9 -0
+		git format-patch --stdout -1 >suppress-self-$3.patch && \
+		git send-email --from="$1 <$2>" \
+		[email protected] \
+		--cc-cmd=./cccmd-sed \
+		--suppress-cc=self \
+		--smtp-server="$(pwd)/fake.sendmail" \
+		suppress-self-$3.patch && \
+		mv msgtxt1 msgtxt1-$3 && \
+		sed -e '/^$/q' msgtxt1-$3 > msghdr1-$3 && \

Style. No SP between redirection operator and redirection target, e.g. >$filename, <$filename, etc. Some in this patch is done correctly (e.g. format-patch above), some others are not.

will fix.

Quoted 8 lines

t/t9001-send-email.sh Result: OK · line 195

Quoted 2 lines
t/t9001-send-email.sh +2 -0
+		rm -f expected-no-cc-$3 && \
+		touch expected-no-cc-$3 && \

Please reserve "touch" for "make sure it has recent timestamp", not for "make sure it exists and is empty". The above two should be more like:

		>"expected-no-cc-$3" &&

OK

Quoted 3 lines

Also, even though it is not required by POSIX, please dquote the redirection target filename if you have variable expansion. Some versions of bash (incorrectly) give warning if you don't.

OK

Quoted 22 lines
Quoted 22 lines
t/t9001-send-email.sh +19 -0
+		grep '^Cc:' msghdr1-$3 > actual-no-cc-$3 && \
+		test_cmp expected-no-cc-$3 actual-no-cc-$3
+test suppress-cc.self $3 with name $1 email $2
+
+$3
+
+cccmd--"$1" <$2>
+
+Cc: "$1" <$2>
+Cc: $1 <$2>
+Signed-off-by: "$1" <$2>
+Signed-off-by: $1 <$2>
+EOF
+}
+
+test_expect_success $PREREQ 'self name is suppressed' "
+	test_suppress_self 'A U Thor' '[email protected]' 'self_name_suppressed'
+"
+
 test_expect_success $PREREQ 'Show all headers' '
 	git send-email \
 		--dry-run \
#4 lore raw

Re: [PATCH 1/6] t/send-email.sh: add test for suppress self

Quoted 11 lines · Michael S. Tsirkin
Quoted 10 lines

t/t9001-send-email.sh Result: OK · line 181

Quoted 8 lines
t/t9001-send-email.sh +8 -0
+test_suppress_self () {
+		test_commit $3 &&
+		test_when_finished "git reset --hard HEAD^" &&
+		{
+			echo "#!$SHELL_PATH"
+			echo sed -n -e s/^cccmd--//p \"\$1\"
+		} > cccmd-sed &&
+		chmod +x cccmd-sed &&

We can use write_script for this kind of thing, I think.

Quoted 2 lines

Important?
It's open-coded elsewhere in this test.

Not that important, other than that it is nice not to spread what the old tests did before write_script was introduced to new ones, as that is one more thing to update when somebody feels like it.

Quoted 9 lines

If we don't want to use \, this can also be done like this:

FOO << EOF &&
BLABLA
EOF
BAR &&
VAR

I think this is what you suggest.

Yup, that is exactly what I meant (but no leading indentation before BAR and VAR).

That way, it is a lot more clear where the input is (the BLABLA is fed to FOO and BAR and VAR do not have anything to do with it).

Quoted 2 lines
Quoted 2 lines

t/t9001-send-email.sh Result: OK · line 197

Quoted 2 lines
t/t9001-send-email.sh +2 -0
+		grep '^Cc:' msghdr1-$3 > actual-no-cc-$3 && \
+		test_cmp expected-no-cc-$3 actual-no-cc-$3

OK, so this is where the message begins, with the commit title "test supress-cc.self...".

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
t/t9001-send-email.sh +17 -0
+test suppress-cc.self $3 with name $1 email $2
+
+$3
+
+cccmd--"$1" <$2>
+
+Cc: "$1" <$2>
+Cc: $1 <$2>
+Signed-off-by: "$1" <$2>
+Signed-off-by: $1 <$2>
+EOF
+}
+
+test_expect_success $PREREQ 'self name is suppressed' "
+	test_suppress_self 'A U Thor' '[email protected]' 'self_name_suppressed'
+"
+
 test_expect_success $PREREQ 'Show all headers' '
 	git send-email \
 		--dry-run \
#5 lore raw

Re: [PATCH 1/6] t/send-email.sh: add test for suppress self

Quoted 13 lines · Junio C Hamano
Quoted 9 lines

If we don't want to use \, this can also be done like this:

FOO << EOF &&
BLABLA
EOF
BAR &&
VAR

I think this is what you suggest.

Yup, that is exactly what I meant (but no leading indentation before BAR and VAR).

Quoted 8 lines

That way, it is a lot more clear where the input is (the BLABLA is fed to FOO and BAR and VAR do not have anything to do with it).

Quoted 2 lines
Quoted 2 lines

t/t9001-send-email.sh Result: OK · line 197

Quoted 2 lines
t/t9001-send-email.sh +2 -0
+		grep '^Cc:' msghdr1-$3 > actual-no-cc-$3 && \
+		test_cmp expected-no-cc-$3 actual-no-cc-$3

OK, so this is where the message begins, with the commit title "test supress-cc.self...".

Another thing I forgot to say, if you are rerolling this patch anyway to follow that style, is that our newer tests typically write it like this:

test_supress_self () {
	test_commit $3 &&
        test_when_finished "git reset --hard HEAD^" &&
        write_script <<-EOF &&
        sed -n -e s/^cccmd--//p \"\$1\"
	EOF

	git commit --amend --author="$1 <$2>" -F - <<-EOF &&
	test suppress-cc.self $3 with name $1 email $2

	$3

	cccmd--"$1" <$2>

        Cc: "$1" <$2>
	Cc: $1 <$2>
	Signed-off-by: "$1" <$2>
	Signed-off-by: $1 <$2>
        EOF
        
        clean_fake_sendmail &&
        git format-patch --stdout -1 >"suppress-self-$3.patch" &&
        git send-email --from="$1 <$2>" \
        	[email protected] \
                ... other args ...
        ... verification steps for the send-email output ...
}
#6 lore raw

Re: [PATCH 1/6] t/send-email.sh: add test for suppress self

Quoted 24 lines · Junio C Hamano
Quoted 13 lines · Junio C Hamano
Quoted 9 lines

If we don't want to use \, this can also be done like this:

FOO << EOF &&
BLABLA
EOF
BAR &&
VAR

I think this is what you suggest.

Yup, that is exactly what I meant (but no leading indentation before BAR and VAR).

Quoted 8 lines

That way, it is a lot more clear where the input is (the BLABLA is fed to FOO and BAR and VAR do not have anything to do with it).

Quoted 2 lines
Quoted 2 lines

t/t9001-send-email.sh Result: OK · line 197

Quoted 2 lines
t/t9001-send-email.sh +2 -0
+		grep '^Cc:' msghdr1-$3 > actual-no-cc-$3 && \
+		test_cmp expected-no-cc-$3 actual-no-cc-$3

OK, so this is where the message begins, with the commit title "test supress-cc.self...".

Quoted 3 lines

Another thing I forgot to say, if you are rerolling this patch anyway to follow that style, is that our newer tests typically write it like this:

What exactly should I notice here?

Quoted 27 lines
test_supress_self () {
	test_commit $3 &&
        test_when_finished "git reset --hard HEAD^" &&
        write_script <<-EOF &&
        sed -n -e s/^cccmd--//p \"\$1\"
	EOF

	git commit --amend --author="$1 <$2>" -F - <<-EOF &&
	test suppress-cc.self $3 with name $1 email $2

	$3

	cccmd--"$1" <$2>

        Cc: "$1" <$2>
	Cc: $1 <$2>
	Signed-off-by: "$1" <$2>
	Signed-off-by: $1 <$2>
        EOF
        
        clean_fake_sendmail &&
        git format-patch --stdout -1 >"suppress-self-$3.patch" &&
        git send-email --from="$1 <$2>" \
        	[email protected] \
                ... other args ...
        ... verification steps for the send-email output ...
}