aboutsummaryrefslogtreecommitdiffstats
path: root/trailer.c
diff options
context:
space:
mode:
authorLinus Arver <linusa@google.com>2024-03-01 00:14:45 +0000
committerJunio C Hamano <gitster@pobox.com>2024-03-01 10:35:42 -0800
commit2c948a78fd449a03c114802772acd4abfec25bba (patch)
tree715489292c6bbba25756c9cb40c51ac6d5a04c00 /trailer.c
parentbf35e0a018cf6d35834e762ac524754024800ad6 (diff)
downloadgit-2c948a78fd449a03c114802772acd4abfec25bba.tar.gz
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 <linusa@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'trailer.c')
-rw-r--r--trailer.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/trailer.c b/trailer.c
index cbd643cd1f..e92d0154d9 100644
--- a/trailer.c
+++ b/trailer.c
@@ -1087,21 +1087,11 @@ void trailer_info_release(struct trailer_info *info)
static void format_trailer_info(const struct process_trailer_options *opts,
const struct trailer_info *info,
- const char *msg,
struct strbuf *out)
{
size_t origlen = out->len;
size_t i;
- /* If we want the whole block untouched, we can take the fast path. */
- if (!opts->only_trailers && !opts->unfold && !opts->filter &&
- !opts->separator && !opts->key_only && !opts->value_only &&
- !opts->key_value_separator) {
- strbuf_add(out, msg + info->trailer_block_start,
- info->trailer_block_end - info->trailer_block_start);
- return;
- }
-
for (i = 0; i < info->trailer_nr; i++) {
char *trailer = info->trailers[i];
ssize_t separator_pos = find_separator(trailer, separators);
@@ -1153,7 +1143,15 @@ void format_trailers_from_commit(const struct process_trailer_options *opts,
struct trailer_info info;
trailer_info_get(opts, msg, &info);
- format_trailer_info(opts, &info, msg, out);
+ /* If we want the whole block untouched, we can take the fast path. */
+ if (!opts->only_trailers && !opts->unfold && !opts->filter &&
+ !opts->separator && !opts->key_only && !opts->value_only &&
+ !opts->key_value_separator) {
+ strbuf_add(out, msg + info.trailer_block_start,
+ info.trailer_block_end - info.trailer_block_start);
+ } else
+ format_trailer_info(opts, &info, out);
+
trailer_info_release(&info);
}