git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] send-email: confirm on empty mail subjects

From
JEJan Engelhardt <jengelh@medozas.de>
Date
Aug 5, 2009, 16:49 UTC
Message-ID
<1249490994-23455-1-git-send-email-jengelh@medozas.de>

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
Next: Junio C Hamano
Message 1 of 7 in “send-email: confirm on empty mail subjects”
  1. send-email: confirm on empty mail subjectsJan Engelhardt, Aug 5, 2009
  2. Junio C HamanoAug 6, 2009
  3. Jan EngelhardtAug 24, 2009
  4. Junio C HamanoAug 24, 2009
  5. Jan EngelhardtAug 25, 2009
  6. Junio C HamanoAug 25, 2009
  7. Junio C HamanoSep 11, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.