git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 2/5] pretty: allow showing specific trailers

From
Anders Waldenborg <anders@0x63.nu>
Date
Nov 26, 2018, 06:56 UTC
Message-ID
<878t1g72ee.fsf@0x63.nu>
In-Reply-To
<xmqqva4kzg23.fsf@gitster-ct.c.googlers.com>
Junio C Hamano writes:
Show 12 quoted lines
> I was confused by the "only" stuff.
>
> When you give a key (or two), they cannot possibly name non-trailer
> lines, so while it may be possible to ask "oh, by the way, I also
> want non-trailer lines in addition to signed-off-by and cc lines",
> the value of being able to make such a request is dubious.
>
> The value is dubious, but logically it makes it more consistent with
> the current %(trailers) that lack 'only', which is "oh by the way, I
> also want non-trailer lines in addition to the trailers with
> keyword", to allow a way to countermand the 'only' you flip on by
> default when keywords are given.

Would it feel less inconsistent if it did not set the 'only_trailers' option?

Now that I look at it again setting 'only_trailers' is more of an implementation trick/hack to make sure it doesn't take the fast-path in format_trailer_info (and by documenting it it justifies that hack). If instead the 'filter' option is checked in the relevant places there would be no need to mix up 'only' with 'filter'.

That is, do you think something like this should be squashed in?
diff --git a/pretty.c b/pretty.c
index 302e67fa8..f45ccaf51 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1360,7 +1360,6 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */

                                        opts.filter = format_trailer_match_cb;
                                        opts.filter_data = &filter_list;
-                                       opts.only_trailers = 1;
                                } else
                                        break;
                        }
diff --git a/trailer.c b/trailer.c
index 97c8f2762..07ca2b2c6 100644
--- 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;
@@ -1156,7 +1156,7 @@ static void format_trailer_info(struct strbuf *out,
                        strbuf_release(&tok);
                        strbuf_release(&val);

-               } else if (!opts->only_trailers) {
+               } else if (!opts->only_trailers && !opts->filter) {
                        strbuf_addstr(out, trailer);
                }
        }
diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index 7548e1d38..ea3cd5b28 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -228,9 +228,9 @@ endif::git-rev-list[]
 ** 'key=<K>': only show trailers with specified key. Matching is done
    case-insensitively and trailing colon is optional. If option is
    given multiple times trailer lines matching any of the keys are
-   shown. Non-trailer lines in the trailer block are also hidden
-   (i.e. 'key' implies 'only'). E.g., `%(trailers:key=Reviewed-by)`
-   shows trailer lines with key `Reviewed-by`.
+   shown. Non-trailer lines in the trailer block are also hidden.
+   E.g., `%(trailers:key=Reviewed-by)` shows trailer lines with key
+   `Reviewed-by`.
 ** 'only': omit non-trailer lines from the trailer block.
 ** 'unfold': make it behave as if interpret-trailer's `--unfold`
    option was given. E.g., `%(trailers:only,unfold)` unfolds and
Previous: Junio C HamanoNext: Junio C Hamano
Message 37 of 69 in “pretty: Add %(trailer:X) to display single trailer”
  1. pretty: Add %(trailer:X) to display single trailerAnders Waldenborg, Oct 28, 2018
  2. Junio C HamanoOct 29, 2018
  3. Jeff KingOct 29, 2018
  4. Anders WaldenborgOct 29, 2018
  5. Jeff KingOct 31, 2018
  6. Anders WaldenborgOct 31, 2018
  7. Jeff KingNov 1, 2018
  8. 0/5 %(trailers) improvements in pretty formatAnders Waldenborg, Nov 4, 2018
  9. 1/5 pretty: single return path in %(trailers) handlingAnders Waldenborg, Nov 4, 2018
  10. 2/5 pretty: allow showing specific trailersAnders Waldenborg, Nov 4, 2018
  11. Eric SunshineNov 4, 2018
  12. Junio C HamanoNov 5, 2018
  13. Eric SunshineNov 5, 2018
  14. Anders WaldenborgNov 5, 2018
  15. Eric SunshineNov 5, 2018
  16. Junio C HamanoNov 5, 2018
  17. 3/5 pretty: add support for "nokey" option in %(trailers)Anders Waldenborg, Nov 4, 2018
  18. 4/5 pretty: extract fundamental placeholders to separate functionAnders Waldenborg, Nov 4, 2018
  19. Junio C HamanoNov 5, 2018
  20. Anders WaldenborgNov 5, 2018
  21. Junio C HamanoNov 6, 2018
  22. 5/5 pretty: add support for separator option in %(trailers)Anders Waldenborg, Nov 4, 2018
  23. Junio C HamanoNov 5, 2018
  24. Anders WaldenborgNov 5, 2018
  25. Junio C HamanoNov 6, 2018
  26. Junio C HamanoNov 5, 2018
  27. Eric SunshineNov 4, 2018
  28. Anders WaldenborgNov 5, 2018
  29. 0/5 %(trailers) improvements in pretty formatAnders Waldenborg, Nov 18, 2018
  30. 5/5 pretty: add support for separator option in %(trailers)Anders Waldenborg, Nov 18, 2018
  31. Eric SunshineNov 20, 2018
  32. 2/5 pretty: allow showing specific trailersAnders Waldenborg, Nov 18, 2018
  33. Junio C HamanoNov 20, 2018
  34. Junio C HamanoNov 20, 2018
  35. Anders WaldenborgNov 25, 2018
  36. Junio C HamanoNov 26, 2018
  37. Anders WaldenborgNov 26, 2018
  38. Junio C HamanoNov 26, 2018
  39. 3/5 pretty: add support for "valueonly" option in %(trailers)Anders Waldenborg, Nov 18, 2018
  40. Eric SunshineNov 20, 2018
  41. 1/5 pretty: single return path in %(trailers) handlingAnders Waldenborg, Nov 18, 2018
  42. 4/5 strbuf: separate callback for strbuf_expand:ing literalsAnders Waldenborg, Nov 18, 2018
  43. 0/7 %(trailers) improvements in pretty formatAnders Waldenborg, Dec 8, 2018
  44. 2/7 pretty: allow %(trailers) options with explicit valueAnders Waldenborg, Dec 8, 2018
  45. Junio C HamanoDec 10, 2018
  46. Anders WaldenborgDec 18, 2018
  47. Jeff KingJan 29, 2019
  48. Anders WaldenborgJan 29, 2019
  49. 1/7 doc: group pretty-format.txt placeholders descriptionsAnders Waldenborg, Dec 8, 2018
  50. 3/7 pretty: single return path in %(trailers) handlingAnders Waldenborg, Dec 8, 2018
  51. 5/7 pretty: add support for "valueonly" option in %(trailers)Anders Waldenborg, Dec 8, 2018
  52. 6/7 strbuf: separate callback for strbuf_expand:ing literalsAnders Waldenborg, Dec 8, 2018
  53. 7/7 pretty: add support for separator option in %(trailers)Anders Waldenborg, Dec 8, 2018
  54. 4/7 pretty: allow showing specific trailersAnders Waldenborg, Dec 8, 2018
  55. Junio C HamanoDec 10, 2018
  56. 0/7 %(trailers) improvements in pretty formatAnders Waldenborg, Jan 28, 2019
  57. 2/7 pretty: Allow %(trailers) options with explicit valueAnders Waldenborg, Jan 28, 2019
  58. Junio C HamanoJan 28, 2019
  59. Anders WaldenborgJan 29, 2019
  60. Jeff KingJan 29, 2019
  61. Anders WaldenborgJan 29, 2019
  62. 5/7 pretty: add support for "valueonly" option in %(trailers)Anders Waldenborg, Jan 28, 2019
  63. 7/7 pretty: add support for separator option in %(trailers)Anders Waldenborg, Jan 28, 2019
  64. 1/7 doc: group pretty-format.txt placeholders descriptionsAnders Waldenborg, Jan 28, 2019
  65. 6/7 strbuf: separate callback for strbuf_expand:ing literalsAnders Waldenborg, Jan 28, 2019
  66. 4/7 pretty: allow showing specific trailersAnders Waldenborg, Jan 28, 2019
  67. 3/7 pretty: single return path in %(trailers) handlingAnders Waldenborg, Jan 28, 2019
  68. Anders WaldenborgJan 31, 2019
  69. Оля ТележнаяFeb 2, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.