Skip to content

Commit 2c948a7

Browse files
Linus Arvergitster
authored andcommitted
format_trailer_info(): move "fast path" to caller
This is another preparatory refactor to unify the trailer formatters. This allows us to drop the "msg" parameter from format_trailer_info(), so that it take 3 parameters, similar to format_trailers() which also takes 3 parameters: void format_trailers(const struct process_trailer_options *opts, struct list_head *trailers, struct strbuf *out) The short-term goal is to make format_trailer_info() be smart enough to deprecate format_trailers(). And then ultimately we will rename format_trailer_info() to format_trailers(). Signed-off-by: Linus Arver <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bf35e0a commit 2c948a7

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

trailer.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,21 +1087,11 @@ void trailer_info_release(struct trailer_info *info)
10871087

10881088
static void format_trailer_info(const struct process_trailer_options *opts,
10891089
const struct trailer_info *info,
1090-
const char *msg,
10911090
struct strbuf *out)
10921091
{
10931092
size_t origlen = out->len;
10941093
size_t i;
10951094

1096-
/* If we want the whole block untouched, we can take the fast path. */
1097-
if (!opts->only_trailers && !opts->unfold && !opts->filter &&
1098-
!opts->separator && !opts->key_only && !opts->value_only &&
1099-
!opts->key_value_separator) {
1100-
strbuf_add(out, msg + info->trailer_block_start,
1101-
info->trailer_block_end - info->trailer_block_start);
1102-
return;
1103-
}
1104-
11051095
for (i = 0; i < info->trailer_nr; i++) {
11061096
char *trailer = info->trailers[i];
11071097
ssize_t separator_pos = find_separator(trailer, separators);
@@ -1153,7 +1143,15 @@ void format_trailers_from_commit(const struct process_trailer_options *opts,
11531143
struct trailer_info info;
11541144

11551145
trailer_info_get(opts, msg, &info);
1156-
format_trailer_info(opts, &info, msg, out);
1146+
/* If we want the whole block untouched, we can take the fast path. */
1147+
if (!opts->only_trailers && !opts->unfold && !opts->filter &&
1148+
!opts->separator && !opts->key_only && !opts->value_only &&
1149+
!opts->key_value_separator) {
1150+
strbuf_add(out, msg + info.trailer_block_start,
1151+
info.trailer_block_end - info.trailer_block_start);
1152+
} else
1153+
format_trailer_info(opts, &info, out);
1154+
11571155
trailer_info_release(&info);
11581156
}
11591157

0 commit comments

Comments
 (0)