Re: [PATCH v4 07/10] parseopt: autocorrect mistyped subcommands
- From
- Jiamu Sun <39@barroit.sh>
- Date
- Mar 17, 2026, 03:21 UTC
- Message-ID
- <ME0P300MB08117F31CDFE8D038C3E0557CE41A@ME0P300MB0811.AUSP300.PROD.OUTLOOK.COM>
- In-Reply-To
- <xmqqse9zo93p.fsf@gitster.g>
On Mon, Mar 16, 2026 at 12:41:30PM -0700, Junio C Hamano wrote:
Show 8 quoted lines
> Is there a reason why this needs to differ from the settings for the > typo detection/fixes for main commands? Would the same reasoning > apply to both, and if not why not? > > I would have expected that we would just emulate what we already do > to the main commands, and later with experience with the subcommand > typo detection/fixes, would tweak the parameters either only to the > subcommand part or to the both with justifications.
I initially wanted to emulate the existing behavior. However, I noticed a huge difference in how prefix-matched commands are handled, which affects the autocorrection behavior. And we can only use the same parameters if we do the exact same thing on prefix match handling in subcommand autocorrection.
I looked through the old mailing list. If I didn't miss anything, the patch that introduced this behavior (e.g., not correcting "statu" to "status") was only trying to fix a UX issue, where the suggestion output didn't include prefix-matched commands. In that thread, they didn't mention that this would also change the typo detection behavior, and no one discussed this side effect. I treat it as an accident.
Because of this, I was confused about whether I should copy this behavior. I chose not to.
However, if we want the main commands and subcommands to act the same, I can do that and try to move the logic to autocorrect.c so both places share the exact same typo detection.
Do you want me to do this?
Show 8 quoted lines
> > + /* > > + * Builtin subcommands are small enough that printing them all via > > + * usage_with_options() is sufficient. Therefore, AUTOCORRECT_HINT > > + * acts like AUTOCORRECT_NEVER. > > + */ > > Sorry, but I am a bit confused with this reference to "Builtin > subcommands". Are there subcommands that are not built-in?
No, that's just poor wording. Will fix it.
--
Jiamu Sun <39@barroit.sh>
<sunjiamu@outlook.com>