[PATCH v6 2/2] send-email: make it easy to discern the messages for each patch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When sending one or multiple patches at once, the displayed result statuses
for each patch and the "Send this email [y/n/a/...]?" confirmation prompts
become bunched together with the messages produced for the subsequent patch,
or with the produced SMTP trace, respectively.

This makes reading the outputs unnecessarily harder, as visible in a couple
of excerpts from a sample output below:

    ...
    MIME-Version: 1.0
    Content-Transfer-Encoding: 8bit

    Result: 250
    OK. Log says:
    Server: smtp.example.com
    MAIL FROM:<test@xxxxxxxxxxx>
    ...

    ...
    MIME-Version: 1.0
    Content-Transfer-Encoding: 8bit

    Send this email? ([y]es|[n]o|[e]dit|[q]uit|[a]ll): y
    OK. Log says:
    Server: smtp.example.com
    MAIL FROM:<test@xxxxxxxxxxx>
    ...

As visible in the excerpts above, bunching the "Result: <status-code>" lines
or the "Send this email [y/n/a/...]?" confirmation prompts together with the
other messages makes the outputs a bit unreadable, which actually becomes
worse as the number of patches sent at once increases.

To make the produced outputs more readable, ensure that vertical whitespace
(more precisely, single newlines) exist before the displayed result statuses
and after the confirmation prompts, as visible in the two updated excerpts
from a sample output below:

    ...
    MIME-Version: 1.0
    Content-Transfer-Encoding: 8bit

    Result: 250

    OK. Log says:
    Server: smtp.example.com
    MAIL FROM:<test@xxxxxxxxxxx>
    ...

    ...
    MIME-Version: 1.0
    Content-Transfer-Encoding: 8bit

    Send this email? ([y]es|[n]o|[e]dit|[q]uit|[a]ll): y

    OK. Log says:
    Server: smtp.example.com
    MAIL FROM:<test@xxxxxxxxxxx>
    ...

While there, remove a couple of spotted stray newlines in the source code
and convert one indentation from spaces to tabs, for consistency.

Update the associated test, t9001, by including additional newlines into
the expected outputs of separate tests affected by these changes.

Helped-by: Junio C Hamano <gitster@xxxxxxxxx>
Signed-off-by: Dragan Simic <dsimic@xxxxxxxxxxx>
---
 git-send-email.perl   |  8 +++++---
 t/t9001-send-email.sh | 10 ++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index f0be4b4560f7..1d6712a44e95 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1361,7 +1361,6 @@ sub smtp_host_string {
 
 # Returns 1 if authentication succeeded or was not necessary
 # (smtp_user was not specified), and 0 otherwise.
-
 sub smtp_auth_maybe {
 	if (!defined $smtp_authuser || $auth || (defined $smtp_auth && $smtp_auth eq "none")) {
 		return 1;
@@ -1510,6 +1509,7 @@ sub gen_header {
 sub send_message {
 	my ($recipients_ref, $to, $date, $gitversion, $cc, $ccline, $header) = gen_header();
 	my @recipients = @$recipients_ref;
+	my $confirm_shown = 0;
 
 	my @sendmail_parameters = ('-i', @recipients);
 	my $raw_from = $sender;
@@ -1555,6 +1555,7 @@ sub send_message {
 		} elsif (/^a/i) {
 			$confirm = 'never';
 		}
+		$confirm_shown = 1;
 	}
 
 	unshift (@sendmail_parameters, @smtp_server_options);
@@ -1576,7 +1577,6 @@ sub send_message {
 		print $sm "$header\n$message";
 		close $sm or die $!;
 	} else {
-
 		if (!defined $smtp_server) {
 			die __("The required SMTP server is not properly defined.")
 		}
@@ -1664,9 +1664,11 @@ sub send_message {
 		$smtp->code =~ /250|200/ or die sprintf(__("Failed to send %s\n"), $subject).$smtp->message;
 	}
 	if ($quiet) {
+		print "\n" if ($confirm_shown);
 		printf($dry_run ? __("Dry-Sent %s") : __("Sent %s"), $subject);
 		print "\n";
 	} else {
+		print "\n";
 		print($dry_run ? __("Dry-OK. Log says:") : __("OK. Log says:"));
 		print "\n";
 		if (!defined $sendmail_cmd && !file_name_is_absolute($smtp_server)) {
@@ -1923,7 +1925,7 @@ sub pre_process_file {
 sub process_file {
 	my ($t) = @_;
 
-        pre_process_file($t, $quiet);
+	pre_process_file($t, $quiet);
 
 	my $message_was_sent = send_message();
 	if ($message_was_sent == -1) {
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 5a771000c9ca..a5cb198a5c5f 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -208,6 +208,7 @@ cat >expected-show-all-headers <<\EOF
 (mbox) Adding cc: A <author@xxxxxxxxxxx> from line 'From: A <author@xxxxxxxxxxx>'
 (mbox) Adding cc: One <one@xxxxxxxxxxx> from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
 (mbox) Adding cc: two@xxxxxxxxxxx from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
+
 Dry-OK. Log says:
 Server: relay.example.com
 MAIL FROM:<from@xxxxxxxxxxx>
@@ -821,6 +822,7 @@ cat >expected-suppress-sob <<\EOF
 (mbox) Adding cc: A <author@xxxxxxxxxxx> from line 'From: A <author@xxxxxxxxxxx>'
 (mbox) Adding cc: One <one@xxxxxxxxxxx> from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
 (mbox) Adding cc: two@xxxxxxxxxxx from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
+
 Dry-OK. Log says:
 Server: relay.example.com
 MAIL FROM:<from@xxxxxxxxxxx>
@@ -869,6 +871,7 @@ cat >expected-suppress-sob <<\EOF
 (mbox) Adding cc: A <author@xxxxxxxxxxx> from line 'From: A <author@xxxxxxxxxxx>'
 (mbox) Adding cc: One <one@xxxxxxxxxxx> from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
 (mbox) Adding cc: two@xxxxxxxxxxx from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
+
 Dry-OK. Log says:
 Server: relay.example.com
 MAIL FROM:<from@xxxxxxxxxxx>
@@ -904,6 +907,7 @@ cat >expected-suppress-cccmd <<\EOF
 (mbox) Adding cc: One <one@xxxxxxxxxxx> from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
 (mbox) Adding cc: two@xxxxxxxxxxx from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
 (body) Adding cc: C O Mitter <committer@xxxxxxxxxxx> from line 'Signed-off-by: C O Mitter <committer@xxxxxxxxxxx>'
+
 Dry-OK. Log says:
 Server: relay.example.com
 MAIL FROM:<from@xxxxxxxxxxx>
@@ -940,6 +944,7 @@ test_expect_success $PREREQ 'sendemail.cccmd' '
 test_expect_success $PREREQ 'setup expect' '
 cat >expected-suppress-all <<\EOF
 0001-Second.patch
+
 Dry-OK. Log says:
 Server: relay.example.com
 MAIL FROM:<from@xxxxxxxxxxx>
@@ -968,6 +973,7 @@ cat >expected-suppress-body <<\EOF
 (mbox) Adding cc: One <one@xxxxxxxxxxx> from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
 (mbox) Adding cc: two@xxxxxxxxxxx from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
 (cc-cmd) Adding cc: cc-cmd@xxxxxxxxxxx from: './cccmd'
+
 Dry-OK. Log says:
 Server: relay.example.com
 MAIL FROM:<from@xxxxxxxxxxx>
@@ -1003,6 +1009,7 @@ cat >expected-suppress-body-cccmd <<\EOF
 (mbox) Adding cc: A <author@xxxxxxxxxxx> from line 'From: A <author@xxxxxxxxxxx>'
 (mbox) Adding cc: One <one@xxxxxxxxxxx> from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
 (mbox) Adding cc: two@xxxxxxxxxxx from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
+
 Dry-OK. Log says:
 Server: relay.example.com
 MAIL FROM:<from@xxxxxxxxxxx>
@@ -1036,6 +1043,7 @@ cat >expected-suppress-sob <<\EOF
 (mbox) Adding cc: A <author@xxxxxxxxxxx> from line 'From: A <author@xxxxxxxxxxx>'
 (mbox) Adding cc: One <one@xxxxxxxxxxx> from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
 (mbox) Adding cc: two@xxxxxxxxxxx from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
+
 Dry-OK. Log says:
 Server: relay.example.com
 MAIL FROM:<from@xxxxxxxxxxx>
@@ -1071,6 +1079,7 @@ cat >expected-suppress-bodycc <<\EOF
 (mbox) Adding cc: One <one@xxxxxxxxxxx> from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
 (mbox) Adding cc: two@xxxxxxxxxxx from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
 (body) Adding cc: C O Mitter <committer@xxxxxxxxxxx> from line 'Signed-off-by: C O Mitter <committer@xxxxxxxxxxx>'
+
 Dry-OK. Log says:
 Server: relay.example.com
 MAIL FROM:<from@xxxxxxxxxxx>
@@ -1105,6 +1114,7 @@ cat >expected-suppress-cc <<\EOF
 0001-Second.patch
 (mbox) Adding cc: A <author@xxxxxxxxxxx> from line 'From: A <author@xxxxxxxxxxx>'
 (body) Adding cc: C O Mitter <committer@xxxxxxxxxxx> from line 'Signed-off-by: C O Mitter <committer@xxxxxxxxxxx>'
+
 Dry-OK. Log says:
 Server: relay.example.com
 MAIL FROM:<from@xxxxxxxxxxx>




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux