trailer_info_get(): reorder parameters

This is another preparatory refactor to unify the trailer formatters.

Take

    const struct process_trailer_options *opts

as the first parameter, because these options are required for
parsing trailers (e.g., whether to treat "---" as the end of the log
message). And take

    struct trailer_info *info

last, because it's an "out parameter" (something that the caller wants
to use as the output of this function).

Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Linus Arver 2024-03-01 00:14:43 +00:00 committed by Junio C Hamano
parent ae0ec2e0e0
commit 9aa1b2bc89
3 changed files with 10 additions and 8 deletions

View File

@ -332,7 +332,7 @@ static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob,
sb->buf[sb->len - ignore_footer] = '\0'; sb->buf[sb->len - ignore_footer] = '\0';
} }
trailer_info_get(&info, sb->buf, &opts); trailer_info_get(&opts, sb->buf, &info);
if (ignore_footer) if (ignore_footer)
sb->buf[sb->len - ignore_footer] = saved_char; sb->buf[sb->len - ignore_footer] = saved_char;

View File

@ -997,7 +997,7 @@ void parse_trailers(const struct process_trailer_options *opts,
struct strbuf val = STRBUF_INIT; struct strbuf val = STRBUF_INIT;
size_t i; size_t i;
trailer_info_get(info, str, opts); trailer_info_get(opts, str, info);
for (i = 0; i < info->trailer_nr; i++) { for (i = 0; i < info->trailer_nr; i++) {
int separator_pos; int separator_pos;
@ -1032,8 +1032,9 @@ void free_trailers(struct list_head *trailers)
} }
} }
void trailer_info_get(struct trailer_info *info, const char *str, void trailer_info_get(const struct process_trailer_options *opts,
const struct process_trailer_options *opts) const char *str,
struct trailer_info *info)
{ {
size_t end_of_log_message = 0, trailer_block_start = 0; size_t end_of_log_message = 0, trailer_block_start = 0;
struct strbuf **trailer_lines, **ptr; struct strbuf **trailer_lines, **ptr;
@ -1150,7 +1151,7 @@ void format_trailers_from_commit(const struct process_trailer_options *opts,
{ {
struct trailer_info info; struct trailer_info info;
trailer_info_get(&info, msg, opts); trailer_info_get(opts, msg, &info);
format_trailer_info(opts, &info, msg, out); format_trailer_info(opts, &info, msg, out);
trailer_info_release(&info); trailer_info_release(&info);
} }
@ -1161,7 +1162,7 @@ void trailer_iterator_init(struct trailer_iterator *iter, const char *msg)
strbuf_init(&iter->key, 0); strbuf_init(&iter->key, 0);
strbuf_init(&iter->val, 0); strbuf_init(&iter->val, 0);
opts.no_divider = 1; opts.no_divider = 1;
trailer_info_get(&iter->internal.info, msg, &opts); trailer_info_get(&opts, msg, &iter->internal.info);
iter->internal.cur = 0; iter->internal.cur = 0;
} }

View File

@ -94,8 +94,9 @@ void parse_trailers(const struct process_trailer_options *,
const char *str, const char *str,
struct list_head *head); struct list_head *head);
void trailer_info_get(struct trailer_info *info, const char *str, void trailer_info_get(const struct process_trailer_options *,
const struct process_trailer_options *opts); const char *str,
struct trailer_info *);
void trailer_info_release(struct trailer_info *info); void trailer_info_release(struct trailer_info *info);