diff mbox series

[v4,11/28] format_trailer_info(): drop redundant unfold_value()

Message ID 457f2a839d5da9da225e842275bbf8b15f194f1f.1707196348.git.gitgitgadget@gmail.com (mailing list archive)
State Accepted
Commit 41ea0a900221897c5ba36afb9f0b31bf543cea7e
Headers show
Series Enrich Trailer API | expand

Commit Message

Linus Arver Feb. 6, 2024, 5:12 a.m. UTC
From: Linus Arver <linusa@google.com>

This is another preparatory refactor to unify the trailer formatters.

In the last patch we made format_trailer_info() use trailer_item objects
instead of the "trailers" string array. This means that the call to
unfold_value() here is redundant because the trailer_item objects are
already unfolded in parse_trailers() which is a dependency of our
caller, format_trailers_from_commit().

Remove the redundant call.

Signed-off-by: Linus Arver <linusa@google.com>
---
 trailer.c | 3 ---
 1 file changed, 3 deletions(-)

Comments

Junio C Hamano Feb. 9, 2024, 9:54 p.m. UTC | #1
"Linus Arver via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Linus Arver <linusa@google.com>
>
> This is another preparatory refactor to unify the trailer formatters.
>
> In the last patch we made format_trailer_info() use trailer_item objects
> instead of the "trailers" string array. This means that the call to
> unfold_value() here is redundant because the trailer_item objects are
> already unfolded in parse_trailers() which is a dependency of our
> caller, format_trailers_from_commit().
>
> Remove the redundant call.

OK.  The previous step had this hunk:

-			parse_trailer(&tok, &val, NULL, trailer, separator_pos);
 			if (!opts->filter || opts->filter(&tok, opts->filter_data)) {
 				if (opts->unfold)
 					unfold_value(&val);

where parse_trailers() already has a call to parse_trailer()
followed by a call to unfold_value(), so in a sense, switching
to use the result of calling parse_trailers() by the caller instead
of duplicating our own parsing in format_trailer_info() that started
at step [09/28] made both parse_trailer() call (removed in step [10/28])
and unfold_value() call (removed in this step [11/28]).

So it would have also made sense if this were done as part of
[10/28], but it is also OK to keep them separated.

In either way, breaking the transition into these steps does make
them easier to follow.

> Signed-off-by: Linus Arver <linusa@google.com>
> ---
>  trailer.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/trailer.c b/trailer.c
> index 6333dfe1c11..12cae5b73d2 100644
> --- a/trailer.c
> +++ b/trailer.c
> @@ -1102,9 +1102,6 @@ static void format_trailer_info(const struct process_trailer_options *opts,
>  			strbuf_addstr(&val, item->value);
>  
>  			if (!opts->filter || opts->filter(&tok, opts->filter_data)) {
> -				if (opts->unfold)
> -					unfold_value(&val);
> -
>  				if (opts->separator && out->len != origlen)
>  					strbuf_addbuf(out, opts->separator);
>  				if (!opts->value_only)
diff mbox series

Patch

diff --git a/trailer.c b/trailer.c
index 6333dfe1c11..12cae5b73d2 100644
--- a/trailer.c
+++ b/trailer.c
@@ -1102,9 +1102,6 @@  static void format_trailer_info(const struct process_trailer_options *opts,
 			strbuf_addstr(&val, item->value);
 
 			if (!opts->filter || opts->filter(&tok, opts->filter_data)) {
-				if (opts->unfold)
-					unfold_value(&val);
-
 				if (opts->separator && out->len != origlen)
 					strbuf_addbuf(out, opts->separator);
 				if (!opts->value_only)