From: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
To: git@vger.kernel.org
Cc: ben.knoble@gmail.com, gitster@pobox.com, philipoakley@iee.email
Subject: Re: [PATCH v3] send-email: validate charset name in 8bit encoding prompt
Date: Sat, 28 Feb 2026 14:06:15 +0530 [thread overview]
Message-ID: <20260228083803.238503-1-shreyanshpaliwalcmsmn@gmail.com> (raw)
In-Reply-To: <xmqq8qcf2vk8.fsf@gitster.g>
[...]
> > +sub confirm_ask {
> > + my ($resp) = @_;
> > + my $term = term();
> > + return 0
> > + unless defined $term->IN and defined fileno($term->IN) and
> > + defined $term->OUT and defined fileno($term->OUT);
> > + my $yesno = $term->readline(
> > + # TRANSLATORS: please keep [y/N] as is.
> > + sprintf(__("Are you sure you want to use <%s> [y/N]? "), $resp));
> > + return defined $yesno && $yesno =~ /y/i;
> > +}
>
> This is a bit incosistent with what "sub ask" (the only caller of
> this sub) does, isn't it? Before entering the loop that makes a
> call into this, it does this:
>
> sub ask {
> my ($prompt, %arg) = @_;
> my $valid_re = $arg{valid_re};
> my $default = $arg{default};
> my $confirm_only = $arg{confirm_only};
> my $resp;
> my $i = 0;
> my $term = term();
> return defined $default ? $default : undef
> unless defined $term->IN and defined fileno($term->IN) and
> defined $term->OUT and defined fileno($term->OUT);
>
> If $term is not usable for interactive prompt, it uses the default
> setting. But the new confirm_ask always says "no".
>
> confirm_ask does its own "check term() to see it is usable" because
> it is called from another code path which does not have its own
> logic, but it may be a wrong abstraction to give uneven interface.
> It would make it more clear what is going on if you just do the
> interactive $term->readline() thing in "sub ask", instead of calling
> "sub confirm_ask" that does tghe $term thing redundantly.
>
> Can't the other confirm_ask() caller call a normal "sub ask"?
>
> I am not sure why we want to add a dedicated sub, just to ask "are
> you sure you want to use X [y/N]? ".
>
> > The intended flow is,
> >
> > Declare which 8bit encoding to use [default: UTF-8]? foobar
> > warning: 'foobar' does not appear to be a valid charset name.
> > Are you sure you want to use <foobar> [y/N]?
>
> It somehow looks uneven to have three lines, two of them
> capitalizing their first word while the other one is all lowercase.
> I wonder if this would be simpler?
>
> Declare which 8bit encoding to use [default: UTF-8]? foobar<RET>
> Do you really mean 'foobar', not a valid charset name [y/N]?
>
Actually that makes sense, because if we need to add a special warning
in between the two prompts (what I was aiming for), either we need to
modify ask() to add the warning into the flow, or we had to seperate the
confirm_ask because we have to change the flow in any case, but if we
drop the additional warning, and instead warn/confirm together in the
second prompt we dont need this abstraction.
>
>
> So, taking all of the above together, perhaps:
>
> * Discard changes to "sub ask" and addition of "sub confirm_ask".
>
> * Tweak this part a bit to call ask().
>
> > + while(1) {
>
> Style. missing SP before "(".
>
> > + my $encoding = ask(__("Declare which 8bit encoding to use [default: UTF-8]? "),
>
> Overly long line.
>
my bad. will fix.
> > + valid_re => qr/^\S+$/,
> > + default => "UTF-8");
> > + next unless defined $encoding;
> > + if (find_encoding($encoding)) {
> > + $auto_8bit_encoding = $encoding;
> > + last;
> > + }
>
> > + printf STDERR __("warning: '%s' does not appear to be a valid charset name.\n"), $encoding;
> > + if (confirm_ask($encoding)) {
>
> Use ask() to ask
>
> Do you really mean 'foobar', not a valid charset name [y/N]?
>
> here, perhaps?
>
Understood. I am hoping now this doesn't need any additional
abstraction as Ben suggested.
Sorry for the delay in response to the review.
I will send a reroll.
Thanks,
Shreyansh
next prev parent reply other threads:[~2026-02-28 8:38 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-20 14:50 [RFC] send-email: UTF-8 encoding in subject line Shreyansh Paliwal
2026-02-21 2:28 ` Ben Knoble
2026-02-21 13:38 ` Shreyansh Paliwal
2026-02-21 17:30 ` Junio C Hamano
2026-02-22 14:03 ` Shreyansh Paliwal
2026-02-22 14:53 ` Philip Oakley
2026-02-22 15:00 ` D. Ben Knoble
2026-02-22 15:52 ` Shreyansh Paliwal
2026-02-23 21:38 ` Ben Knoble
2026-02-24 7:55 ` [GSOC] Discuss: Refactoring in order to reduce global state Shreyansh Paliwal
2026-02-22 14:53 ` [RFC] send-email: UTF-8 encoding in subject line D. Ben Knoble
2026-02-24 14:33 ` [PATCH] send-email: validate charset name in 8bit encoding prompt Shreyansh Paliwal
2026-02-24 21:11 ` Junio C Hamano
2026-02-24 21:37 ` [PATCH v2] " Shreyansh Paliwal
2026-02-24 22:06 ` Junio C Hamano
2026-02-24 22:20 ` Shreyansh Paliwal
2026-02-25 16:37 ` D. Ben Knoble
2026-02-26 17:32 ` Shreyansh Paliwal
2026-02-26 16:16 ` [PATCH v3] " Shreyansh Paliwal
2026-02-26 18:45 ` Junio C Hamano
2026-02-26 19:06 ` Junio C Hamano
2026-02-28 8:41 ` Shreyansh Paliwal
2026-02-28 8:36 ` Shreyansh Paliwal [this message]
2026-02-28 11:20 ` [PATCH v4] " Shreyansh Paliwal
2026-02-28 21:16 ` D. Ben Knoble
2026-03-02 16:10 ` Junio C Hamano
2026-03-03 19:06 ` Shreyansh Paliwal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260228083803.238503-1-shreyanshpaliwalcmsmn@gmail.com \
--to=shreyanshpaliwalcmsmn@gmail.com \
--cc=ben.knoble@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=philipoakley@iee.email \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox