git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] send-email: confirm on empty mail subjects
@ 2009-08-05 16:49 Jan Engelhardt
  2009-08-06  6:25 ` Junio C Hamano
  2009-09-11 23:27 ` Junio C Hamano
  0 siblings, 2 replies; 7+ messages in thread
From: Jan Engelhardt @ 2009-08-05 16:49 UTC (permalink / raw)
  To: git

When the user forgot to enter a subject in a compose session,
send-email will now inquire whether this is really intended, similar
to what the Alpine MUA does when a subject is absent.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
 git-send-email.perl |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index d508f83..7d56fba 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -553,11 +553,26 @@ EOT
 	}
 	close(C);
 
-	if ($annotate) {
-		do_edit($compose_filename, @files);
-	} else {
-		do_edit($compose_filename);
-	}
+	my $re_edit = 0;
+	do {
+		if ($annotate) {
+			do_edit($compose_filename, @files);
+		} else {
+			do_edit($compose_filename);
+		}
+
+		open(C, "<", $compose_filename) ||
+			die "Failed to open $compose_filename: $!";
+		if (grep(/^Subject:\s*$/i, <C>)) {
+			my $r = ask("No Subject, send anyway? ".
+			            "([y]es|[n]o|[e]dit again): ",
+			            valid_re => qr/^[yne]/i,
+			            default => "n");
+			$re_edit = lc(substr($r, 0, 1)) eq "e";
+			exit(0) if lc(substr($r, 0, 1)) eq "n";
+		}
+		close C;
+	} while ($re_edit);
 
 	open(C2,">",$compose_filename . ".final")
 		or die "Failed to open $compose_filename.final : " . $!;
-- 
1.6.4

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

end of thread, other threads:[~2009-09-11 23:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-05 16:49 [PATCH] send-email: confirm on empty mail subjects Jan Engelhardt
2009-08-06  6:25 ` Junio C Hamano
2009-08-24 17:27   ` Jan Engelhardt
2009-08-24 18:19     ` Junio C Hamano
2009-08-25 16:27       ` Jan Engelhardt
2009-08-25 17:35         ` Junio C Hamano
2009-09-11 23:27 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).