trailer: pass process_trailer_opts to trailer_info_get()
Most of the trailer code has an "opts" struct which is filled in by the caller. We don't pass it down to trailer_info_get(), which does the initial parsing, because there hasn't yet been a need to do so. Let's start passing it down in preparation for adding new options. Note that there's a single caller which doesn't otherwise have such an options struct. Since it's just one caller (that we'd have to modify anyway), let's not bother with any special treatment like accepting a NULL options struct, and just have it allocate one with the defaults. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Aug 22, 2018 at 20:46 UTC
00a21f5cbda35eb5d355b453849b625eeca7eac4
3 files changed
+8
-5
sequencer.c
+2
-1
@@ -224,11 +224,12 @@ static const char *get_todo_path(const struct replay_opts *opts)
224
static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob,
225
int ignore_footer)
226
{
227
+ struct process_trailer_options opts = PROCESS_TRAILER_OPTIONS_INIT;
228
struct trailer_info info;
229
size_t i;
230
int found_sob = 0, found_sob_last = 0;
231
231
- trailer_info_get(&info, sb->buf);
232
+ trailer_info_get(&info, sb->buf, &opts);
233
234
if (info.trailer_start == info.trailer_end)
235
return 0;
trailer.c
+4
-3
@@ -950,7 +950,7 @@ static size_t process_input_file(FILE *outfile,
950
struct strbuf val = STRBUF_INIT;
951
size_t i;
952
953
- trailer_info_get(&info, str);
953
+ trailer_info_get(&info, str, opts);
954
955
/* Print lines before the trailers as is */
956
if (!opts->only_trailers)
@@ -1067,7 +1067,8 @@ void process_trailers(const char *file,
1067
strbuf_release(&sb);
1068
}
1069
1070
-void trailer_info_get(struct trailer_info *info, const char *str)
1070
+void trailer_info_get(struct trailer_info *info, const char *str,
1071
+ const struct process_trailer_options *opts)
1072
{
1073
int patch_start, trailer_end, trailer_start;
1074
struct strbuf **trailer_lines, **ptr;
@@ -1159,7 +1160,7 @@ void format_trailers_from_commit(struct strbuf *out, const char *msg,
1160
{
1161
struct trailer_info info;
1162
1162
- trailer_info_get(&info, msg);
1163
+ trailer_info_get(&info, msg, opts);
1164
format_trailer_info(out, &info, opts);
1165
trailer_info_release(&info);
1166
}
trailer.h
+2
-1
@@ -77,7 +77,8 @@ void process_trailers(const char *file,
77
const struct process_trailer_options *opts,
78
struct list_head *new_trailer_head);
79
80
-void trailer_info_get(struct trailer_info *info, const char *str);
80
+void trailer_info_get(struct trailer_info *info, const char *str,
81
+ const struct process_trailer_options *opts);
82
83
void trailer_info_release(struct trailer_info *info);
84