Subject: Re: [PATCH v5 4/6] pretty: allow caller to disable indentation

From: Junio C Hamano <[email-masked]>
Date: Wed, 16 Jul 2025 08:50:43 -0700

Toon Claes <[email-masked]> writes:

> Most pretty formats indent the commit message with 4 spaces. Add field
> `no_indent` to `struct pretty_print_context` to suppress this
> indentation.
>
> Signed-off-by: Toon Claes <[email-masked]>
>
> # Conflicts:
> #	pretty.h

Careful.  There is no need to rush your patches to send a version
that hasn't been proof-read.

>
> Signed-off-by: Toon Claes <[email-masked]>
> ---

I doubt that this is what you want in this series anyway, though.
You use this for "-z --extended", which presumably is about giving
the output that is as faithful as possible to the original, but if
you look at pretty_print_commit(), it does a LOT MORE than just
indent the log by 4 spaces.  I suspect you would rather want to
avoid even calling pretty_print_commit() in such a code path.

>  pretty.c | 2 +-
>  pretty.h | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/pretty.c b/pretty.c
> index 0bc8ad8a9a..9b1698417e 100644
> --- a/pretty.c
> +++ b/pretty.c
> @@ -2286,7 +2286,7 @@ void pretty_print_commit(struct pretty_print_context *pp,
>  			 struct strbuf *sb)
>  {
>  	unsigned long beginning_of_body;
> -	int indent = 4;
> +	int indent = pp->no_indent ? 0 : 4;
>  	const char *msg;
>  	const char *reencoded;
>  	const char *encoding;
> diff --git a/pretty.h b/pretty.h
> index df267afe4a..5d25ae2320 100644
> --- a/pretty.h
> +++ b/pretty.h
> @@ -50,6 +50,7 @@ struct pretty_print_context {
>  	struct ident_split *from_ident;
>  	unsigned encode_email_headers:1;
>  	struct pretty_print_describe_status *describe_status;
> +	int no_indent;
>
>  	/*
>  	 * Fields below here are manipulated internally by pp_* functions and
> --
> 2.50.1.327.g047016eb4a