Subject: Re: [PATCH 01/19] global: improve const correctness when assigning string constants

From: Junio C Hamano <[email-masked]>
Date: Wed, 29 May 2024 09:58:56 -0700

Patrick Steinhardt <[email-masked]> writes:

> We're about to enable `-Wwrite-strings`, which changes the type of
> string constants to `const char[]`. Fix various sites where we assign
> such constants to non-const variables.
>
> Signed-off-by: Patrick Steinhardt <[email-masked]>
> ---

This is a noisy change, and it is kind of surprising that ...

> diff --git a/builtin/bisect.c b/builtin/bisect.c
> index a58432b9d9..dabce9b542 100644
> --- a/builtin/bisect.c
> +++ b/builtin/bisect.c
> @@ -262,7 +262,8 @@ static int bisect_reset(const char *commit)
>  	return bisect_clean_state();
>  }
>  
> -static void log_commit(FILE *fp, char *fmt, const char *state,
> +static void log_commit(FILE *fp,
> +		       const char *fmt, const char *state,
>  		       struct commit *commit)
>  {
>  	struct pretty_print_context pp = {0};

... a change like this does not require any other change to the
code inside the function (e.g., by making further cascading changes
to what the function calls).

But applying this step alone and building would not give us any
constness warning/error from the compiler, so the result looks good
to the compiler, I guess?

Thanks.