X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=trailer.c;h=0c414f2fed2b5701f616eb2d88a386e5da16fda8;hb=95399788d158e4628e25db20569d44af21a40906;hp=d0d9e91631ca4fa5eab0c9b7b4f5fd23763f1cd3;hpb=d9b936db5226ed4b87d42a2c91324adc50c768b6;p=thirdparty%2Fgit.git diff --git a/trailer.c b/trailer.c index d0d9e91631..0c414f2fed 100644 --- a/trailer.c +++ b/trailer.c @@ -1129,10 +1129,11 @@ static void format_trailer_info(struct strbuf *out, const struct trailer_info *info, const struct process_trailer_options *opts) { + 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) { + if (!opts->only_trailers && !opts->unfold && !opts->filter && !opts->separator) { strbuf_add(out, info->trailer_start, info->trailer_end - info->trailer_start); return; @@ -1150,16 +1151,26 @@ static void format_trailer_info(struct strbuf *out, if (!opts->filter || opts->filter(&tok, opts->filter_data)) { if (opts->unfold) unfold_value(&val); + + if (opts->separator && out->len != origlen) + strbuf_addbuf(out, opts->separator); if (!opts->value_only) strbuf_addf(out, "%s: ", tok.buf); strbuf_addbuf(out, &val); - strbuf_addch(out, '\n'); + if (!opts->separator) + strbuf_addch(out, '\n'); } strbuf_release(&tok); strbuf_release(&val); } else if (!opts->only_trailers) { + if (opts->separator && out->len != origlen) { + strbuf_addbuf(out, opts->separator); + } strbuf_addstr(out, trailer); + if (opts->separator) { + strbuf_rtrim(out); + } } }