send-email: ask confirmation if given encoding name is very short
authorJunio C Hamano <gitster@pobox.com>
Fri, 13 Feb 2015 20:20:25 +0000 (12:20 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 13 Feb 2015 20:20:25 +0000 (12:20 -0800)
Sometimes people respond "y<ENTER>" (or "yes<ENTER>") when asked
this question:

Which 8bit encoding should I declare [UTF-8]?

We already have a mechanism to avoid accepting a mistyped e-mail
address (we ask to confirm when the given address lacks "@" in it);
reuse it to trigger the same confirmation when given a very short
answer. As a typical charset name is probably at least 4 chars or
longer (e.g. "UTF8" spelled without the dash, or "Big5"), this would
prevent such a mistake.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-send-email.perl
index fdb0029b597898559376b1b28d692450794251f3..eb3237115125ebb749a6b2e8b2cf612106a05516 100755 (executable)
@@ -733,6 +733,7 @@ sub file_declares_8bit_cte {
                print "    $f\n";
        }
        $auto_8bit_encoding = ask("Which 8bit encoding should I declare [UTF-8]? ",
+                                 valid_re => qr/.{4}/, confirm_only => 1,
                                  default => "UTF-8");
 }