All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] send-email: Much readable error output
@ 2014-12-26 12:06 Alexander Kuleshov
  2014-12-26 23:38 ` Thomas Gummerer
  2014-12-27 11:09 ` [PATCH v2] " Alexander Kuleshov
  0 siblings, 2 replies; 4+ messages in thread
From: Alexander Kuleshov @ 2014-12-26 12:06 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, 0xAX

Signed-off-by: 0xAX <kuleshovmail@gmail.com>
---
 git-send-email.perl | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 82c6fea..6a995c4 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1274,11 +1274,11 @@ X-Mailer: git-send-email $gitversion
 		}
 
 		if (!$smtp) {
-			die "Unable to initialize SMTP properly. Check config and use --smtp-debug. ",
-			    "VALUES: server=$smtp_server ",
-			    "encryption=$smtp_encryption ",
-			    "hello=$smtp_domain",
-			    defined $smtp_server_port ? " port=$smtp_server_port" : "";
+			die "Unable to initialize SMTP properly. Check config and use --smtp-debug.\n",
+			    "VALUES: server=$smtp_server\n\t",
+			    "encryption=$smtp_encryption\n\t",
+			    "hello=$smtp_domain\n\t",
+			    defined $smtp_server_port ? "port=$smtp_server_port\n" : "\n";
 		}
 
 		smtp_auth_maybe or die $smtp->message;
-- 
2.2.1.202.g98acd41

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] send-email: Much readable error output
  2014-12-26 12:06 [PATCH] send-email: Much readable error output Alexander Kuleshov
@ 2014-12-26 23:38 ` Thomas Gummerer
  2014-12-27 11:09 ` [PATCH v2] " Alexander Kuleshov
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Gummerer @ 2014-12-26 23:38 UTC (permalink / raw)
  To: Alexander Kuleshov, Junio C Hamano; +Cc: git, 0xAX

Hi,

Alexander Kuleshov <kuleshovmail@gmail.com> writes:

> Signed-off-by: 0xAX <kuleshovmail@gmail.com>

Please use your full name for the sign-off.

> ---
>  git-send-email.perl | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/git-send-email.perl b/git-send-email.perl
> index 82c6fea..6a995c4 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -1274,11 +1274,11 @@ X-Mailer: git-send-email $gitversion
>  		}
>
>  		if (!$smtp) {
> -			die "Unable to initialize SMTP properly. Check config and use --smtp-debug. ",
> -			    "VALUES: server=$smtp_server ",
> -			    "encryption=$smtp_encryption ",
> -			    "hello=$smtp_domain",
> -			    defined $smtp_server_port ? " port=$smtp_server_port" : "";
> +			die "Unable to initialize SMTP properly. Check config and use --smtp-debug.\n",
> +			    "VALUES: server=$smtp_server\n\t",
> +			    "encryption=$smtp_encryption\n\t",
> +			    "hello=$smtp_domain\n\t",
> +			    defined $smtp_server_port ? "port=$smtp_server_port\n" : "\n";

Minor nits:
  - I think this would be easier to read if the \t was on the line which
    should be indented.
  - If $smtp_server_port is not defined we produce an unnecessary empty line

>  		}
>
>  		smtp_auth_maybe or die $smtp->message;
> --
> 2.2.1.202.g98acd41
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] send-email: Much readable error output
  2014-12-26 12:06 [PATCH] send-email: Much readable error output Alexander Kuleshov
  2014-12-26 23:38 ` Thomas Gummerer
@ 2014-12-27 11:09 ` Alexander Kuleshov
  2014-12-28  8:56   ` Eric Sunshine
  1 sibling, 1 reply; 4+ messages in thread
From: Alexander Kuleshov @ 2014-12-27 11:09 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Alexander Kuleshov

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
---
 git-send-email.perl | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 82c6fea..eb02ef9 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -38,7 +38,7 @@ sub new {
 }
 sub readline {
 	my $self = shift;
-	die "Cannot use readline on FakeTerm: $$self";
+	die "Cannot use readline on FakeTerm: $$self\n";
 }
 package main;
 
@@ -185,13 +185,13 @@ sub do_edit {
 		map {
 			system('sh', '-c', $editor.' "$@"', $editor, $_);
 			if (($? & 127) || ($? >> 8)) {
-				die("the editor exited uncleanly, aborting everything");
+				die("the editor exited uncleanly, aborting everything\n");
 			}
 		} @_;
 	} else {
 		system('sh', '-c', $editor.' "$@"', $editor, @_);
 		if (($? & 127) || ($? >> 8)) {
-			die("the editor exited uncleanly, aborting everything");
+			die("the editor exited uncleanly, aborting everything\n");
 		}
 	}
 }
@@ -546,7 +546,7 @@ while (defined(my $f = shift @ARGV)) {
 		@ARGV = ();
 	} elsif (-d $f and !is_format_patch_arg($f)) {
 		opendir my $dh, $f
-			or die "Failed to opendir $f: $!";
+			or die "Failed to opendir $f: $!\n";
 
 		push @files, grep { -f $_ } map { catfile($f, $_) }
 				sort readdir $dh;
@@ -591,7 +591,7 @@ sub get_patch_subject {
 		return "GIT: $1\n";
 	}
 	close $fh;
-	die "No subject line in $fn ?";
+	die "No subject line in $fn ?\n";
 }
 
 if ($compose) {
@@ -601,7 +601,7 @@ if ($compose) {
 		tempfile(".gitsendemail.msg.XXXXXX", DIR => $repo->repo_path()) :
 		tempfile(".gitsendemail.msg.XXXXXX", DIR => "."))[1];
 	open my $c, ">", $compose_filename
-		or die "Failed to open for writing $compose_filename: $!";
+		or die "Failed to open for writing $compose_filename: $!\n";
 
 
 	my $tpl_sender = $sender || $repoauthor || $repocommitter || '';
@@ -1205,7 +1205,7 @@ X-Mailer: git-send-email $gitversion
 		$_ = ask("Send this email? ([y]es|[n]o|[q]uit|[a]ll): ",
 		         valid_re => qr/^(?:yes|y|no|n|quit|q|all|a)/i,
 		         default => $ask_default);
-		die "Send this email reply required" unless defined $_;
+		die "Send this email reply required\n" unless defined $_;
 		if (/^n/i) {
 			return 0;
 		} elsif (/^q/i) {
@@ -1231,7 +1231,7 @@ X-Mailer: git-send-email $gitversion
 	} else {
 
 		if (!defined $smtp_server) {
-			die "The required SMTP server is not properly defined."
+			die "The required SMTP server is not properly defined.\n"
 		}
 
 		if ($smtp_encryption eq 'ssl') {
@@ -1274,11 +1274,11 @@ X-Mailer: git-send-email $gitversion
 		}
 
 		if (!$smtp) {
-			die "Unable to initialize SMTP properly. Check config and use --smtp-debug. ",
-			    "VALUES: server=$smtp_server ",
-			    "encryption=$smtp_encryption ",
-			    "hello=$smtp_domain",
-			    defined $smtp_server_port ? " port=$smtp_server_port" : "";
+			die "Unable to initialize SMTP properly. Check config and use --smtp-debug.\n",
+			    "VALUES: server=$smtp_server\n\t",
+			    "encryption=$smtp_encryption\n\t",
+			    "hello=$smtp_domain\n\t",
+			    defined $smtp_server_port ? "port=$smtp_server_port\n" : "\n";
 		}
 
 		smtp_auth_maybe or die $smtp->message;
@@ -1321,7 +1321,7 @@ $subject = $initial_subject;
 $message_num = 0;
 
 foreach my $t (@files) {
-	open my $fh, "<", $t or die "can't open file $t";
+	open my $fh, "<", $t or die "can't open file $t\n";
 
 	my $author = undef;
 	my $sauthor = undef;
@@ -1543,7 +1543,7 @@ sub recipients_cmd {
 
 	my @addresses = ();
 	open my $fh, "-|", "$cmd \Q$file\E"
-	    or die "($prefix) Could not execute '$cmd'";
+	    or die "($prefix) Could not execute '$cmd'\n";
 	while (my $address = <$fh>) {
 		$address =~ s/^\s*//g;
 		$address =~ s/\s*$//g;
@@ -1554,7 +1554,7 @@ sub recipients_cmd {
 		       $what, $address, $cmd) unless $quiet;
 		}
 	close $fh
-	    or die "($prefix) failed to close pipe to '$cmd'";
+	    or die "($prefix) failed to close pipe to '$cmd'\n";
 	return @addresses;
 }
 
@@ -1581,7 +1581,7 @@ sub apply_transfer_encoding {
 	$message = MIME::Base64::decode($message)
 		if ($from eq 'base64');
 
-	die "cannot send message as 7bit"
+	die "cannot send message as 7bit\n"
 		if ($to eq '7bit' and $message =~ /[^[:ascii:]]/);
 	return $message
 		if ($to eq '7bit' or $to eq '8bit');
@@ -1589,7 +1589,7 @@ sub apply_transfer_encoding {
 		if ($to eq 'quoted-printable');
 	return MIME::Base64::encode($message, "\n")
 		if ($to eq 'base64');
-	die "invalid transfer encoding";
+	die "invalid transfer encoding\n";
 }
 
 sub unique_email_list {
-- 
2.2.1.202.g98acd41.dirty

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] send-email: Much readable error output
  2014-12-27 11:09 ` [PATCH v2] " Alexander Kuleshov
@ 2014-12-28  8:56   ` Eric Sunshine
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Sunshine @ 2014-12-28  8:56 UTC (permalink / raw)
  To: Alexander Kuleshov; +Cc: Junio C Hamano, Git List, Thomas Gummerer

On Sat, Dec 27, 2014 at 6:09 AM, Alexander Kuleshov
<kuleshovmail@gmail.com> wrote:
> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>

This patch has two distinct goals. First, it's adding "\n" to 'die'
messages to suppress the file+line# information which Perl appends
automatically to 'die' output. Second, it's trying to format the "SMTP
initialization" error message in a more human-readable way. The two
goals should be covered by two patches, rather than just one.

When you split your change into multiple patches, reviewers don't need
to divide their concentration between unrelated changes. Also, if the
project maintainer (Junio) decides that some of the changes are
worthwhile, but others are not, having multiple patches makes it
easier for him to pick and choose the ones he wants.

It's also worthwhile to write a suitable commit message explaining the
change if it's not obvious. For instance, the casual reader might not
realize that adding "\n" to 'die' messages suppresses the file+line#
information, and that you want to suppress that information because it
does not particularly add value to these user-facing message.

More below.

> ---
> diff --git a/git-send-email.perl b/git-send-email.perl
> index 82c6fea..eb02ef9 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -38,7 +38,7 @@ sub new {
>  }
>  sub readline {
>         my $self = shift;
> -       die "Cannot use readline on FakeTerm: $$self";
> +       die "Cannot use readline on FakeTerm: $$self\n";
>  }
>  package main;
>
> @@ -1274,11 +1274,11 @@ X-Mailer: git-send-email $gitversion
>                 }
>
>                 if (!$smtp) {
> -                       die "Unable to initialize SMTP properly. Check config and use --smtp-debug. ",
> -                           "VALUES: server=$smtp_server ",
> -                           "encryption=$smtp_encryption ",
> -                           "hello=$smtp_domain",
> -                           defined $smtp_server_port ? " port=$smtp_server_port" : "";
> +                       die "Unable to initialize SMTP properly. Check config and use --smtp-debug.\n",
> +                           "VALUES: server=$smtp_server\n\t",
> +                           "encryption=$smtp_encryption\n\t",
> +                           "hello=$smtp_domain\n\t",
> +                           defined $smtp_server_port ? "port=$smtp_server_port\n" : "\n";

Thomas made a couple points in his review[1] which are very much worth
considering:

1. Move the "\t" to the beginning of the lines you want to indent;
don't leave it at the end of the preceding line following the "\n".

2. Don't emit an unnecessary blank line if $smtp_server_port is not defined.

A third point he didn't mention:

3. If you're indenting "encryption", "hello", and "port", for
consistency, it also makes sense to indent "server". (That is, insert
a newline after "VALUES:", before "server=".)

[1]: http://article.gmane.org/gmane.comp.version-control.git/261833

>                 }
>
>                 smtp_auth_maybe or die $smtp->message;

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-12-28  8:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-26 12:06 [PATCH] send-email: Much readable error output Alexander Kuleshov
2014-12-26 23:38 ` Thomas Gummerer
2014-12-27 11:09 ` [PATCH v2] " Alexander Kuleshov
2014-12-28  8:56   ` Eric Sunshine

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.