Message ID | xmqqr0dvb1sh.fsf_-_@gitster.g (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Re* [PATCH] add-patch: response to unknown command | expand |
On Tue, May 21, 2024 at 08:52:14AM -0700, Junio C Hamano wrote: > Patrick Steinhardt <ps@pks.im> writes: > > > I'm a bit on the edge here. Is it really less confusing if we confront > > the user with a command that they have never even provided in the first > > place? They implicitly specified the first letter, only, but the user > > first needs to be aware that we discard everything but the first letter > > in the first place. > > I share your doubt. If what the user said (e.g. "ues") when they > wanted to say "yes", I find "You said 'u', which I do not understand" > more confusiong than "You said 'ues', which I do not understand". Same here. The below patch provides compelling reasoning and has my: Acked-by: Taylor Blau <me@ttaylorr.com> Thanks, Taylor
Taylor Blau <me@ttaylorr.com> writes: >> >> I share your doubt. If what the user said (e.g. "ues") when they >> wanted to say "yes", I find "You said 'u', which I do not understand" >> more confusiong than "You said 'ues', which I do not understand". > > Same here. The below patch provides compelling reasoning and has my: > > Acked-by: Taylor Blau <me@ttaylorr.com> Heh, this breaks '/' command hence t3701.45 as it takes an argument hence not limited to a single letter. I wonder how singlekey folks invoke that feature, though ;-)
diff --git c/add-patch.c w/add-patch.c index 2252895c28..7126bc5d70 100644 --- c/add-patch.c +++ w/add-patch.c @@ -1227,6 +1227,7 @@ static int prompt_yesno(struct add_p_state *s, const char *prompt) fflush(stdout); if (read_single_character(s) == EOF) return -1; + /* do not limit to 1-byte input to allow 'no' etc. */ switch (tolower(s->answer.buf[0])) { case 'n': return 0; case 'y': return 1; @@ -1509,6 +1510,10 @@ static int patch_update_file(struct add_p_state *s, if (!s->answer.len) continue; + if (1 < s->answer.len) { + error(_("only one letter is expected, got '%s'"), s->answer.buf); + continue; + } ch = tolower(s->answer.buf[0]); if (ch == 'y') { hunk->use = USE_HUNK;