Re: [PATCH v3 2/8] help: make autocorrect handling reusable
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 10, 2026, 20:10 UTC
- Message-ID
- <xmqqcy1btpht.fsf@gitster.g>
- In-Reply-To
- <CAOLa=ZQypadiSnU1hqHBUzzayGvvvv0z-X+-vNJRFgREmdB+qg@mail.gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 15 quoted lines
>> +#define AUTOCORRECT_SHOW (-4) >> +#define AUTOCORRECT_PROMPT (-3) >> +#define AUTOCORRECT_NEVER (-2) >> +#define AUTOCORRECT_IMMEDIATELY (-1) >> + >> +struct config_context; >> + >> +void autocorr_resolve_config(const char *var, const char *value, >> + const struct config_context *ctx, void *data); >> + >> +void autocorr_confirm(int autocorr, const char *assumed); >> + > > Why not use s/autocorr/autocorrect/ ? Also would be nice to add some > documentation about each of the functions here.
Good.
Show 7 quoted lines
> > [snip] > > Also got this from running `git-clang-format` on this commit. Generally > applying changes while moving code makes it harder to review. But here > the changes are small enough that we could get away with it. I'll leave > it to you.
No, you cannot leave it to the author.
Leave it to CodingGuidelines; case and switch would start at the same column.
Show 40 quoted lines
> diff --git a/autocorrect.c b/autocorrect.c
> index 1037f03201..87351fd08f 100644
> --- a/autocorrect.c
> +++ b/autocorrect.c
> @@ -9,12 +9,12 @@
> static int parse_autocorrect(const char *value)
> {
> switch (git_parse_maybe_bool_text(value)) {
> - case 1:
> - return AUTOCORRECT_IMMEDIATELY;
> - case 0:
> - return AUTOCORRECT_SHOW;
> - default: /* other random text */
> - break;
> + case 1:
> + return AUTOCORRECT_IMMEDIATELY;
> + case 0:
> + return AUTOCORRECT_SHOW;
> + default: /* other random text */
> + break;
> }
>
> if (!strcmp(value, "prompt"))
> diff --git a/autocorrect.h b/autocorrect.h
> index 45609990c7..38f1e73131 100644
> --- a/autocorrect.h
> +++ b/autocorrect.h
> @@ -1,9 +1,9 @@
> #ifndef AUTOCORRECT_H
> #define AUTOCORRECT_H
>
> -#define AUTOCORRECT_SHOW (-4)
> -#define AUTOCORRECT_PROMPT (-3)
> -#define AUTOCORRECT_NEVER (-2)
> +#define AUTOCORRECT_SHOW (-4)
> +#define AUTOCORRECT_PROMPT (-3)
> +#define AUTOCORRECT_NEVER (-2)
> #define AUTOCORRECT_IMMEDIATELY (-1)
>
> struct config_context;