Commit Graph

4 Commits

Author SHA1 Message Date
Jiamu Sun
46483152a4 autocorrect: provide config resolution API
Add autocorr_resolve(). This resolves and populates the correct values
for autocorrect config.

Make autocorrect config callback internal. The API is meant to provide
a high-level way to retrieve the config. Allowing access to the config
callback from outside violates that intent.

Additionally, in some cases, without access to the config callback, two
config iterations cannot be merged into one, which can hurt performance.
This is fine, as the code path that calls autocorr_resolve() is cold.

Signed-off-by: Jiamu Sun <39@barroit.sh>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-10 16:21:55 -07:00
Jiamu Sun
2a48e5668b autocorrect: rename AUTOCORRECT_SHOW to AUTOCORRECT_HINTONLY
AUTOCORRECT_SHOW is ambiguous. Its purpose is to show commands similar
to the unknown one and take no other action. Rename it to fit the
semantics.

Signed-off-by: Jiamu Sun <39@barroit.sh>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-10 16:21:55 -07:00
Jiamu Sun
c8ac3d589a help: move tty check for autocorrection to autocorrect.c
TTY checking is the autocorrect config parser's responsibility. It must
ensure the parsed value is correct and reliable. Thus, move the check to
autocorr_resolve_config().

Signed-off-by: Jiamu Sun <39@barroit.sh>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-10 16:21:55 -07:00
Jiamu Sun
db8b01619c help: make autocorrect handling reusable
Move config parsing and prompt/delay handling into autocorrect.c and
expose them in autocorrect.h. This makes autocorrect reusable regardless
of which target links against it.

Signed-off-by: Jiamu Sun <39@barroit.sh>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-10 16:21:55 -07:00