public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] parseopt: add subcommand autocorrection
@ 2026-03-08 12:17 Jiamu Sun
  2026-03-08 12:17 ` [PATCH 1/5] parseopt: extract subcommand handling from parse_options_step() Jiamu Sun
                   ` (6 more replies)
  0 siblings, 7 replies; 67+ messages in thread
From: Jiamu Sun @ 2026-03-08 12:17 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Jiamu Sun

Git currently provides auto-correction for builtins and aliases, but
lacks this functionality for subcommands parsed via the parse-options
API. Subcommands are also commands, and typos will occur, too. Like:

	git remote add-rul

So, this series introduces subcommand auto-correction.

Currently, builtins with mandatory subcommands enable autocorrection by
default. However, those using PARSE_OPT_SUBCOMMAND_OPTIONAL skip it to
avoid treating valid unknown arguments as mistyped subcommands.

This series adds PARSE_OPT_SUBCOMMAND_AUTOCORR, allowing commands with
optional subcommands to explicitly opt in to autocorrection. It then
enables this flag for git-remote and git-notes.

Additionally, it extracts the existing autocorrection logic from help.c
so subcommand handling can reuse the same config parsing and
prompt/delay logic.

Jiamu Sun (5):
  parseopt: extract subcommand handling from parse_options_step()
  help: refactor command autocorrection handling
  parseopt: autocorrect mistyped subcommands
  parseopt: enable subcommand autocorrect for remote and notes
  help: add tests for subcommand autocorrection

 Makefile                          |   1 +
 autocorrect.c                     |  92 +++++++++++++++++++
 autocorrect.h                     |  23 +++++
 builtin/notes.c                   |  10 +-
 builtin/remote.c                  |  12 +--
 help.c                            | 106 ++++-----------------
 parse-options.c                   | 147 +++++++++++++++++++++++-------
 parse-options.h                   |   1 +
 t/t9004-autocorrect-subcommand.sh |  49 ++++++++++
 9 files changed, 306 insertions(+), 135 deletions(-)
 create mode 100644 autocorrect.c
 create mode 100644 autocorrect.h
 create mode 100755 t/t9004-autocorrect-subcommand.sh


base-commit: 795c338de725e13bd361214c6b768019fc45a2c1
-- 
2.53.0


^ permalink raw reply	[flat|nested] 67+ messages in thread

end of thread, other threads:[~2026-03-17  3:21 UTC | newest]

Thread overview: 67+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-08 12:17 [PATCH 0/5] parseopt: add subcommand autocorrection Jiamu Sun
2026-03-08 12:17 ` [PATCH 1/5] parseopt: extract subcommand handling from parse_options_step() Jiamu Sun
2026-03-08 23:40   ` Junio C Hamano
2026-03-09  1:56     ` Jiamu Sun
2026-03-08 12:17 ` [PATCH 2/5] help: refactor command autocorrection handling Jiamu Sun
2026-03-08 23:52   ` Junio C Hamano
2026-03-09  2:06     ` Jiamu Sun
2026-03-08 12:17 ` [PATCH 3/5] parseopt: autocorrect mistyped subcommands Jiamu Sun
2026-03-09  0:04   ` Junio C Hamano
2026-03-09  2:11     ` Jiamu Sun
2026-03-08 12:17 ` [PATCH 4/5] parseopt: enable subcommand autocorrect for remote and notes Jiamu Sun
2026-03-08 12:17 ` [PATCH 5/5] help: add tests for subcommand autocorrection Jiamu Sun
2026-03-11 17:01   ` Aaron Plattner
2026-03-11 22:45     ` Jiamu Sun
2026-03-12 13:35       ` Junio C Hamano
2026-03-08 20:11 ` [PATCH 0/5] parseopt: add " Junio C Hamano
2026-03-08 22:07   ` Jiamu Sun
2026-03-08 23:16 ` [PATCH v2 " Jiamu Sun
2026-03-08 23:16   ` [PATCH v2 1/5] parseopt: extract subcommand handling from parse_options_step() Jiamu Sun
2026-03-08 23:16   ` [PATCH v2 2/5] help: refactor command autocorrection handling Jiamu Sun
2026-03-08 23:16   ` [PATCH v2 3/5] parseopt: autocorrect mistyped subcommands Jiamu Sun
2026-03-08 23:16   ` [PATCH v2 4/5] parseopt: enable subcommand autocorrect for remote and notes Jiamu Sun
2026-03-08 23:16   ` [PATCH v2 5/5] help: add tests for subcommand autocorrection Jiamu Sun
2026-03-10 11:40   ` [PATCH v3 0/8] parseopt: add " Jiamu Sun
2026-03-10 11:41     ` [PATCH v3 1/8] parseopt: extract subcommand handling from parse_options_step() Jiamu Sun
2026-03-10 12:46       ` Karthik Nayak
2026-03-11  1:49         ` Jiamu Sun
2026-03-11  4:20           ` Junio C Hamano
2026-03-11  4:20           ` Junio C Hamano
2026-03-11  6:12             ` Jiamu Sun
2026-03-10 11:41     ` [PATCH v3 2/8] help: make autocorrect handling reusable Jiamu Sun
2026-03-10 12:52       ` Karthik Nayak
2026-03-10 20:10         ` Junio C Hamano
2026-03-11  2:05           ` Jiamu Sun
2026-03-11  1:58         ` Jiamu Sun
2026-03-10 11:41     ` [PATCH v3 3/8] help: move tty check for autocorrection to autocorrect.c Jiamu Sun
2026-03-10 14:06       ` Karthik Nayak
2026-03-11  2:16         ` Jiamu Sun
2026-03-12  0:10         ` Jiamu Sun
2026-03-10 11:41     ` [PATCH v3 4/8] autocorrect: rename AUTOCORRECT_SHOW to AUTOCORRECT_HINTONLY Jiamu Sun
2026-03-10 14:08       ` Karthik Nayak
2026-03-11  2:46         ` Jiamu Sun
2026-03-10 11:41     ` [PATCH v3 5/8] autocorrect: provide config resolution API Jiamu Sun
2026-03-10 14:15       ` Karthik Nayak
2026-03-10 11:41     ` [PATCH v3 6/8] parseopt: autocorrect mistyped subcommands Jiamu Sun
2026-03-10 20:16       ` Junio C Hamano
2026-03-11  2:48         ` Jiamu Sun
2026-03-11 23:26           ` Jiamu Sun
2026-03-12  2:38             ` Junio C Hamano
2026-03-12  4:53               ` Jiamu Sun
2026-03-10 11:41     ` [PATCH v3 7/8] parseopt: enable subcommand autocorrection for git-remote and git-notes Jiamu Sun
2026-03-10 11:41     ` [PATCH v3 8/8] help: add tests for subcommand autocorrection Jiamu Sun
2026-03-11  4:23       ` Junio C Hamano
2026-03-11  6:10         ` Jiamu Sun
2026-03-16 15:36     ` [PATCH v4 00/10] parseopt: add " Jiamu Sun
2026-03-16 15:36       ` [PATCH v4 01/10] parseopt: extract subcommand handling from parse_options_step() Jiamu Sun
2026-03-16 15:36       ` [PATCH v4 02/10] help: make autocorrect handling reusable Jiamu Sun
2026-03-16 15:36       ` [PATCH v4 03/10] help: move tty check for autocorrection to autocorrect.c Jiamu Sun
2026-03-16 15:36       ` [PATCH v4 04/10] autocorrect: use mode and delay instead of magic numbers Jiamu Sun
2026-03-16 15:36       ` [PATCH v4 05/10] autocorrect: rename AUTOCORRECT_SHOW to AUTOCORRECT_HINT Jiamu Sun
2026-03-16 15:36       ` [PATCH v4 06/10] autocorrect: provide config resolution API Jiamu Sun
2026-03-16 15:36       ` [PATCH v4 07/10] parseopt: autocorrect mistyped subcommands Jiamu Sun
2026-03-16 19:41         ` Junio C Hamano
2026-03-17  3:21           ` Jiamu Sun
2026-03-16 15:36       ` [PATCH v4 08/10] parseopt: enable subcommand autocorrection for git-remote and git-notes Jiamu Sun
2026-03-16 15:36       ` [PATCH v4 09/10] parseopt: add tests for subcommand autocorrection Jiamu Sun
2026-03-16 15:36       ` [PATCH v4 10/10] doc: document autocorrect API Jiamu Sun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox