From: Junio C Hamano Date: Mon, 16 Mar 2026 19:41:30 GMT Subject: Re: [PATCH v4 07/10] parseopt: autocorrect mistyped subcommands Message-ID: In-Reply-To: Jiamu Sun <39@barroit.sh> writes: > Try to autocorrect the mistyped mandatory subcommand before showing an > error and exiting. Subcommands parsed with PARSE_OPT_SUBCOMMAND_OPTIONAL > are skipped. > > Use standard Damerau-Levenshtein distance (weights 1, 1, 1, 1) to > establish a predictable, mathematically sound baseline. > > Scale the allowed edit distance based on input length to prevent > false positives on short commands, following common practice for > fuzziness thresholds (e.g., Elasticsearch's AUTO fuzziness): > - Length 0-2: 0 edits allowed > - Length 3-5: 1 edit allowed > - Length 6+: 2 edits allowed 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. > + /* > + * 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?