pretty: allow showing specific trailers
[gitweb.git] / trailer.c
index 0796f326b36bac334cbf7ca5162cb22c4b62d1e8..d6da555cd71bed97acae89bc37787b81dfe423f4 100644 (file)
--- a/trailer.c
+++ b/trailer.c
@@ -1132,7 +1132,7 @@ static void format_trailer_info(struct strbuf *out,
        size_t i;
 
        /* If we want the whole block untouched, we can take the fast path. */
-       if (!opts->only_trailers && !opts->unfold) {
+       if (!opts->only_trailers && !opts->unfold && !opts->filter) {
                strbuf_add(out, info->trailer_start,
                           info->trailer_end - info->trailer_start);
                return;
@@ -1147,10 +1147,12 @@ static void format_trailer_info(struct strbuf *out,
                        struct strbuf val = STRBUF_INIT;
 
                        parse_trailer(&tok, &val, NULL, trailer, separator_pos);
-                       if (opts->unfold)
-                               unfold_value(&val);
+                       if (!opts->filter || opts->filter(&tok, opts->filter_data)) {
+                               if (opts->unfold)
+                                       unfold_value(&val);
 
-                       strbuf_addf(out, "%s: %s\n", tok.buf, val.buf);
+                               strbuf_addf(out, "%s: %s\n", tok.buf, val.buf);
+                       }
                        strbuf_release(&tok);
                        strbuf_release(&val);