diff options
author | Jeff King <peff@peff.net> | 2017-08-15 06:23:56 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-08-15 11:13:58 -0700 |
commit | a388b10fc17c435df32c3875225a1468edad9535 (patch) | |
tree | 7c27599344e6d39edcafe1cd631ed63ea7c12b48 /trailer.c | |
parent | 99e09dafd7b7bcac4d8189b41dc6038bf36334f5 (diff) | |
download | git-a388b10fc17c435df32c3875225a1468edad9535.tar.gz |
pretty: move trailer formatting to trailer.c
The next commit will add many features to the %(trailer)
placeholder in pretty.c. We'll need to access some internal
functions of trailer.c for that, so our options are either:
1. expose those functions publicly
or
2. make an entry point into trailer.c to do the formatting
Doing (2) ends up exposing less surface area, though do note
that caveats in the docstring of the new function.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'trailer.c')
-rw-r--r-- | trailer.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -1090,3 +1090,21 @@ void trailer_info_release(struct trailer_info *info) free(info->trailers[i]); free(info->trailers); } + +static void format_trailer_info(struct strbuf *out, + const struct trailer_info *info, + const struct process_trailer_options *opts) +{ + strbuf_add(out, info->trailer_start, + info->trailer_end - info->trailer_start); +} + +void format_trailers_from_commit(struct strbuf *out, const char *msg, + const struct process_trailer_options *opts) +{ + struct trailer_info info; + + trailer_info_get(&info, msg); + format_trailer_info(out, &info, opts); + trailer_info_release(&info); +} |