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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 11, 2009, 23:27 UTC
Message-ID
<7v4or9qczc.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1249490994-23455-1-git-send-email-jengelh@medozas.de>
Jan Engelhardt <jengelh@medozas.de> writes:
Show 8 quoted lines
> 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(-)

We have had this for quite a long time but I have two niggling worries, one minor, another one showstopper from maintainability point of view.

 - With --confirm=never the program still seems to talk with the terminal.
   I think with --confirm=neber we should not ask but just fail.
 - This does not hook into the confirmation framework the program already
   has, and does not have any way to turn it off.
Show 38 quoted lines
> 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
Previous: Junio C Hamano
Message 7 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.