Skip to content

Commit 9aa1b2b

Browse files
Linus Arvergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ae0ec2e commit 9aa1b2b

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

sequencer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob,
332332
sb->buf[sb->len - ignore_footer] = '\0';
333333
}
334334

335-
trailer_info_get(&info, sb->buf, &opts);
335+
trailer_info_get(&opts, sb->buf, &info);
336336

337337
if (ignore_footer)
338338
sb->buf[sb->len - ignore_footer] = saved_char;

trailer.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ void parse_trailers(const struct process_trailer_options *opts,
997997
struct strbuf val = STRBUF_INIT;
998998
size_t i;
999999

1000-
trailer_info_get(info, str, opts);
1000+
trailer_info_get(opts, str, info);
10011001

10021002
for (i = 0; i < info->trailer_nr; i++) {
10031003
int separator_pos;
@@ -1032,8 +1032,9 @@ void free_trailers(struct list_head *trailers)
10321032
}
10331033
}
10341034

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)
10371038
{
10381039
size_t end_of_log_message = 0, trailer_block_start = 0;
10391040
struct strbuf **trailer_lines, **ptr;
@@ -1150,7 +1151,7 @@ void format_trailers_from_commit(const struct process_trailer_options *opts,
11501151
{
11511152
struct trailer_info info;
11521153

1153-
trailer_info_get(&info, msg, opts);
1154+
trailer_info_get(opts, msg, &info);
11541155
format_trailer_info(opts, &info, msg, out);
11551156
trailer_info_release(&info);
11561157
}
@@ -1161,7 +1162,7 @@ void trailer_iterator_init(struct trailer_iterator *iter, const char *msg)
11611162
strbuf_init(&iter->key, 0);
11621163
strbuf_init(&iter->val, 0);
11631164
opts.no_divider = 1;
1164-
trailer_info_get(&iter->internal.info, msg, &opts);
1165+
trailer_info_get(&opts, msg, &iter->internal.info);
11651166
iter->internal.cur = 0;
11661167
}
11671168

trailer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ void parse_trailers(const struct process_trailer_options *,
9494
const char *str,
9595
struct list_head *head);
9696

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 *);
99100

100101
void trailer_info_release(struct trailer_info *info);
101102

0 commit comments

Comments
 (0)