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

Re: [PATCH] send-email: validate & reconfirm interactive responses

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 6, 2012, 03:29 UTC
Message-ID
<7vsjav6d85.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CALaEz9WVCj0gu-CbUJgydik1bC7z7JCcveKTdyxgrTWokXq5JA@mail.gmail.com>
Stephen Boyd <bebarino@gmail.com> writes:
Show 15 quoted lines
> On Tue, Aug 14, 2012 at 3:25 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> @@ -745,13 +752,15 @@ sub file_declares_8bit_cte {
>>  if (!defined $sender) {
>>         $sender = $repoauthor || $repocommitter || '';
>>         $sender = ask("Who should the emails appear to be from? [$sender] ",
>> -                     default => $sender);
>> +                     default => $sender,
>> +                     valid_re => qr/\@.*\./, confirm_only => 1);
>
> This is now bugging me if I just hit enter and don't want to specify
> anything for
> these headers (I want the defaults or what's in the files already).
> Can we allow
> the empty string to be valid as well so I don't have to go through
> these prompts?

That indeed was the intention, and if it is not behaving, you found a bug.

The relevant code in "sub ask" does this:
		...
                $resp = $term->readline($prompt);
                if (!defined $resp) { # EOF
                        print "\n";
                        return defined $default ? $default : undef;
                }
                if ($resp eq '' and defined $default) {
                        return $default;
                }
                if (!defined $valid_re or $resp =~ /$valid_re/) {
                        return $resp;
                }

I am scratching my head wondering why your "just hit enter" does not trigger the "if response is empty and we have default, just return it" codepath we can see above. It shouldn't even trigger the regexp based validation codepath in the first place.

Previous: Stephen BoydNext: Stephen Boyd
Message 8 of 13 in “send-email and in-reply-to = n”
  1. Stephen BoydAug 13, 2012
  2. Junio C HamanoAug 13, 2012
  3. Martin von ZweigbergkAug 14, 2012
  4. send-email: validate & reconfirm interactive responsesJunio C Hamano, Aug 14, 2012
  5. Martin von ZweigbergkAug 14, 2012
  6. Junio C HamanoAug 14, 2012
  7. Stephen BoydSep 5, 2012
  8. Junio C HamanoSep 6, 2012
  9. Stephen BoydSep 6, 2012
  10. Junio C HamanoSep 6, 2012
  11. send-email: initial_to and initial_reply_to are both optionalJunio C Hamano, Sep 6, 2012
  12. Stephen BoydSep 6, 2012
  13. Stephen BoydSep 6, 2012

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.