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>

Linus Arver committed Mar 1, 2024 at 00:14 UTC 9aa1b2bc890cea43f2b9aa3379ca88e98a17801f
3 files changed +10 -8
sequencer.c
+1 -1
@@ -332,7 +332,7 @@ static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob,
332 sb->buf[sb->len - ignore_footer] = '\0';
333 }
334
335 - trailer_info_get(&info, sb->buf, &opts);
335 + trailer_info_get(&opts, sb->buf, &info);
336
337 if (ignore_footer)
338 sb->buf[sb->len - ignore_footer] = saved_char;
trailer.c
+6 -5
@@ -997,7 +997,7 @@ void parse_trailers(const struct process_trailer_options *opts,
997 struct strbuf val = STRBUF_INIT;
998 size_t i;
999
1000 - trailer_info_get(info, str, opts);
1000 + trailer_info_get(opts, str, info);
1001
1002 for (i = 0; i < info->trailer_nr; i++) {
1003 int separator_pos;
@@ -1032,8 +1032,9 @@ void free_trailers(struct list_head *trailers)
1032 }
1033 }
1034
1035 -void trailer_info_get(struct trailer_info *info, const char *str,
1036 - const struct process_trailer_options *opts)
1035 +void trailer_info_get(const struct process_trailer_options *opts,
1036 + const char *str,
1037 + struct trailer_info *info)
1038 {
1039 size_t end_of_log_message = 0, trailer_block_start = 0;
1040 struct strbuf **trailer_lines, **ptr;
@@ -1150,7 +1151,7 @@ void format_trailers_from_commit(const struct process_trailer_options *opts,
1151 {
1152 struct trailer_info info;
1153
1153 - trailer_info_get(&info, msg, opts);
1154 + trailer_info_get(opts, msg, &info);
1155 format_trailer_info(opts, &info, msg, out);
1156 trailer_info_release(&info);
1157 }
@@ -1161,7 +1162,7 @@ void trailer_iterator_init(struct trailer_iterator *iter, const char *msg)
1162 strbuf_init(&iter->key, 0);
1163 strbuf_init(&iter->val, 0);
1164 opts.no_divider = 1;
1164 - trailer_info_get(&iter->internal.info, msg, &opts);
1165 + trailer_info_get(&opts, msg, &iter->internal.info);
1166 iter->internal.cur = 0;
1167 }
1168
trailer.h
+3 -2
@@ -94,8 +94,9 @@ void parse_trailers(const struct process_trailer_options *,
94 const char *str,
95 struct list_head *head);
96
97 -void trailer_info_get(struct trailer_info *info, const char *str,
98 - const struct process_trailer_options *opts);
97 +void trailer_info_get(const struct process_trailer_options *,
98 + const char *str,
99 + struct trailer_info *);
100
101 void trailer_info_release(struct trailer_info *info);
102