pretty: allow showing specific trailers
[gitweb.git] / trailer.c
index 8392c6c030c970ada5899dd05fb882ca043e10bf..d6da555cd71bed97acae89bc37787b81dfe423f4 100644 (file)
--- a/trailer.c
+++ b/trailer.c
@@ -1080,7 +1080,11 @@ void trailer_info_get(struct trailer_info *info, const char *str,
 
        ensure_configured();
 
-       patch_start = find_patch_start(str);
+       if (opts->no_divider)
+               patch_start = strlen(str);
+       else
+               patch_start = find_patch_start(str);
+
        trailer_end = find_trailer_end(str, patch_start);
        trailer_start = find_trailer_start(str, trailer_end);
 
@@ -1128,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;
@@ -1143,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);