Skip to content

Commit 35ca441

Browse files
Linus Arvergitster
authored andcommitted
format_trailers_from_commit(): indirectly call trailer_info_get()
This is another preparatory refactor to unify the trailer formatters. For background, note that the "trailers" string array is the `char **trailers` member in `struct trailer_info` and that the trailer_item objects are the elements of the `struct list_head *head` linked list. Currently trailer_info_get() only populates `char **trailers`. And parse_trailers() first calls trailer_info_get() so that it can use the `char **trailers` to populate a list of `struct trailer_item` objects Instead of calling trailer_info_get() directly from format_trailers_from_commit(), make it call parse_trailers() instead because parse_trailers() already calls trailer_info_get(). This change is a NOP because format_trailer_info() (which format_trailers_from_commit() wraps around) only looks at the "trailers" string array, not the trailer_item objects which parse_trailers() populates. For now we do need to create a dummy LIST_HEAD(trailer_objects); because parse_trailers() expects it in its signature. In a future patch, we'll change format_trailer_info() to use the parsed trailer_item objects (trailer_objects) instead of the `char **trailers` array. Signed-off-by: Linus Arver <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2c948a7 commit 35ca441

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

trailer.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,9 +1140,11 @@ void format_trailers_from_commit(const struct process_trailer_options *opts,
11401140
const char *msg,
11411141
struct strbuf *out)
11421142
{
1143+
LIST_HEAD(trailer_objects);
11431144
struct trailer_info info;
11441145

1145-
trailer_info_get(opts, msg, &info);
1146+
parse_trailers(opts, &info, msg, &trailer_objects);
1147+
11461148
/* If we want the whole block untouched, we can take the fast path. */
11471149
if (!opts->only_trailers && !opts->unfold && !opts->filter &&
11481150
!opts->separator && !opts->key_only && !opts->value_only &&
@@ -1152,6 +1154,7 @@ void format_trailers_from_commit(const struct process_trailer_options *opts,
11521154
} else
11531155
format_trailer_info(opts, &info, out);
11541156

1157+
free_trailers(&trailer_objects);
11551158
trailer_info_release(&info);
11561159
}
11571160

0 commit comments

Comments
 (0)