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