diff options
author | Linus Arver <linusa@google.com> | 2024-03-01 01:14:44 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-03-01 19:35:42 +0100 |
commit | bf35e0a018cf6d35834e762ac524754024800ad6 (patch) | |
tree | 2221c373bc12ecefc597f6509706a3378c19f091 /trailer.c | |
parent | trailer_info_get(): reorder parameters (diff) | |
download | git-bf35e0a018cf6d35834e762ac524754024800ad6.tar.xz git-bf35e0a018cf6d35834e762ac524754024800ad6.zip |
format_trailers(): use strbuf instead of FILE
This is another preparatory refactor to unify the trailer formatters.
Make format_trailers() also write to a strbuf, to align with
format_trailers_from_commit() which also does the same. Doing this makes
format_trailers() behave similar to format_trailer_info() (which will
soon help us replace one with the other).
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.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -144,12 +144,12 @@ static char last_non_space_char(const char *s) return '\0'; } -static void print_tok_val(FILE *outfile, const char *tok, const char *val) +static void print_tok_val(struct strbuf *out, const char *tok, const char *val) { char c; if (!tok) { - fprintf(outfile, "%s\n", val); + strbuf_addf(out, "%s\n", val); return; } @@ -157,13 +157,14 @@ static void print_tok_val(FILE *outfile, const char *tok, const char *val) if (!c) return; if (strchr(separators, c)) - fprintf(outfile, "%s%s\n", tok, val); + strbuf_addf(out, "%s%s\n", tok, val); else - fprintf(outfile, "%s%c %s\n", tok, separators[0], val); + strbuf_addf(out, "%s%c %s\n", tok, separators[0], val); } void format_trailers(const struct process_trailer_options *opts, - struct list_head *trailers, FILE *outfile) + struct list_head *trailers, + struct strbuf *out) { struct list_head *pos; struct trailer_item *item; @@ -171,7 +172,7 @@ void format_trailers(const struct process_trailer_options *opts, item = list_entry(pos, struct trailer_item, list); if ((!opts->trim_empty || strlen(item->value) > 0) && (!opts->only_trailers || item->token)) - print_tok_val(outfile, item->token, item->value); + print_tok_val(out, item->token, item->value); } } |