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

Re: [PATCH v4 00/28] Enrich Trailer API

From
Christian Couder <christian.couder@gmail.com>
Date
Feb 12, 2024, 23:37 UTC
Message-ID
<CAP8UFD3qLGua5PTA+i29N+yJH8iKVBPwUn=S606B2E+s959JFQ@mail.gmail.com>
In-Reply-To
<pull.1632.v4.git.1707196348.gitgitgadget@gmail.com>

On Tue, Feb 6, 2024 at 6:12 AM Linus Arver via GitGitGadget <gitgitgadget@gmail.com> wrote:

>
> This patch series is the first 10 patches of a larger cleanup/bugfix series
> (henceforth "larger series") I've been working on.
There are now 28 patches in this series.

I took a look at all of them, and I think that this series should be split into 4 or more series.

For example perhaps one series until the "trailer: move interpret_trailers() to interpret-trailers.c" patch, then another one until "trailer: finish formatting unification". etc.

Also I think it might be possible to avoid some test failures introduced by some patches. If it's not possible, I agree with Junio that it would be nice if the failing tests were changed to use 'test_expect_failure'.

Also it seems to me that many patches towards the end of this series should be split.

Show 5 quoted lines
> The main goal of this
> series is to begin the process of "libifying" the trailer API. By "API" I
> mean the interface exposed in trailer.h. The larger series brings a number
> of additional cleanups (exposing and fixing some bugs along the way), and
> builds on top of this series.
[...]
> With the libification-focused goals out of the way, let's turn to this patch
> series in more detail.

I like the goal of libifying Git the trailer API, and the way you want to do it seems reasonable to me.

[...]
> In summary this series breaks up "process_trailers()" into smaller pieces,
> exposing many of the parts relevant to trailer-related processing in
> trailer.h. This will force us to eventually introduce unit tests for these
> API functions, but that is a good thing for API stability.

I am a bit sad that this series doesn't introduce unit tests using the new test framework in C yet. I understand that this series is mostly a big refactoring and maybe it's better to introduce unit tests only when the refactoring is finished though. Anyway I hope the next series will introduce such tests.

Show 6 quoted lines
> In the future after libification is "complete", users external to Git will
> be able to use the same trailer processing API used by the
> interpret-trailers builtin. For example, a web server may want to parse
> trailers the same way that Git would parse them, without having to call
> interpret-trailers as a subprocess. This use case was the original
> motivation behind my work in this area.
Thanks for telling us about this use case.
Show 9 quoted lines
> Thanks to the aggressive refactoring in this series, I've been able to
> identify and fix several bugs in our existing implementation. Those fixes
> build on top of this series but were not included here, in order to keep
> this series small. Below is a "shortlog" of those fixes I have locally:
>
>  * "trailer: trailer replacement should not change its position" (If we
>    found a trailer we'd like to replace, preserve its position relative to
>    the other trailers found in the trailer block, instead of always moving
>    it to the beginning or end of the entire trailer block.)

I believe there was a reason why it was done this way. I don't remember what it was though.

Show 5 quoted lines
>  * "interpret-trailers: preserve trailers coming from the input" (Sometimes,
>    the parsed trailers from the input will be formatted differently
>    depending on whether we provide --only-trailers or not. Make the trailers
>    that were not modified and which are coming directly from the input get
>    formatted the same way, regardless of this flag.)
It could be a feature to be able to normalize trailers in a certain way.
>  * "interpret-trailers: do not modify the input if NOP" (Refrain from
>    subtracting or adding a newline around the patch divider "---" if we are
>    not adding new trailers.)
It could be a feature to be able to normalize this too.
>  * "trailer formatter: split up format_trailer() monolith" (Fix a bug in
>    git-log where we still printed a blank newline even if we didn't want to
>    format anything.)
I am not sure this is a bug fix either. It could perhaps be a normalization too.
>  * "interpret-trailers: fail if given unrecognized arguments" (E.g., for
>    "--where", only accept recognized WHERE_* enum values. If we get
>    something unrecognized, fail with an error instead of silently doing
>    nothing. Ditto for "--if-exists" and "--if-missing".)
It's possible that there was a reason why it was done this way.

I think you might want to take a look at the discussions on the mailing list when "interpret-trailers" was developed. There were a lot of discussions over a long time, and there were a lot of requests and suggestions about what it should do.

Previous: Linus ArverNext: Junio C Hamano
Message 157 of 202 in “Enrich Trailer API”
  1. 00/10 Enrich Trailer APILinus Arver via GitGitGadget, Jan 10, 2024
  2. 01/10 trailer: move process_trailers() to interpret-trailers.cLinus Arver via GitGitGadget, Jan 10, 2024
  3. Junio C HamanoJan 18, 2024
  4. Linus ArverJan 19, 2024
  5. 02/10 trailer: include "trailer" term in API functionsLinus Arver via GitGitGadget, Jan 10, 2024
  6. Junio C HamanoJan 18, 2024
  7. Linus ArverJan 19, 2024
  8. Junio C HamanoJan 19, 2024
  9. 03/10 trailer: unify trailer formatting machineryLinus Arver via GitGitGadget, Jan 10, 2024
  10. Junio C HamanoJan 18, 2024
  11. Linus ArverJan 19, 2024
  12. 04/10 trailer: delete obsolete formatting functionsLinus Arver via GitGitGadget, Jan 10, 2024
  13. Junio C HamanoJan 19, 2024
  14. 05/10 sequencer: use the trailer iteratorLinus Arver via GitGitGadget, Jan 10, 2024
  15. Junio C HamanoJan 19, 2024
  16. Linus ArverJan 20, 2024
  17. Linus ArverJan 22, 2024
  18. 06/10 trailer: make trailer_info struct privateLinus Arver via GitGitGadget, Jan 10, 2024
  19. Junio C HamanoJan 19, 2024
  20. Josh SteadmonJan 25, 2024
  21. Junio C HamanoJan 25, 2024
  22. 07/10 trailer: spread usage of "trailer_block" languageLinus Arver via GitGitGadget, Jan 10, 2024
  23. Junio C HamanoJan 19, 2024
  24. Linus ArverJan 20, 2024
  25. 08/10 trailer: prepare to move parse_trailers_from_command_line_args() to builtinLinus Arver via GitGitGadget, Jan 10, 2024
  26. Josh SteadmonJan 25, 2024
  27. Linus ArverJan 26, 2024
  28. 09/10 trailer: move arg handling to interpret-trailers.cLinus Arver via GitGitGadget, Jan 10, 2024
  29. Junio C HamanoJan 19, 2024
  30. Linus ArverJan 20, 2024
  31. 10/10 trailer: delete obsolete argument handling code from APILinus Arver via GitGitGadget, Jan 10, 2024
  32. Junio C HamanoJan 10, 2024
  33. Linus ArverJan 13, 2024
  34. Linus ArverJan 14, 2024
  35. Josh SteadmonJan 25, 2024
  36. 00/10 Enrich Trailer APILinus Arver via GitGitGadget, Jan 26, 2024
  37. 01/10 trailer: prepare to expose functions as part of APILinus Arver via GitGitGadget, Jan 26, 2024
  38. Josh SteadmonJan 30, 2024
  39. Linus ArverJan 30, 2024
  40. 02/10 trailer: move interpret_trailers() to interpret-trailers.cLinus Arver via GitGitGadget, Jan 26, 2024
  41. 03/10 trailer: unify trailer formatting machineryLinus Arver via GitGitGadget, Jan 26, 2024
  42. Josh SteadmonJan 30, 2024
  43. Linus ArverJan 30, 2024
  44. 04/10 trailer: delete obsolete formatting functionsLinus Arver via GitGitGadget, Jan 26, 2024
  45. 05/10 sequencer: use the trailer iteratorLinus Arver via GitGitGadget, Jan 26, 2024
  46. 06/10 trailer: make trailer_info struct privateLinus Arver via GitGitGadget, Jan 26, 2024
  47. 07/10 trailer: spread usage of "trailer_block" languageLinus Arver via GitGitGadget, Jan 26, 2024
  48. 08/10 trailer: prepare to move parse_trailers_from_command_line_args() to builtinLinus Arver via GitGitGadget, Jan 26, 2024
  49. 09/10 trailer: move arg handling to interpret-trailers.cLinus Arver via GitGitGadget, Jan 26, 2024
  50. Linus ArverJan 28, 2024
  51. Linus ArverJan 28, 2024
  52. 10/10 trailer: delete obsolete argument handling code from APILinus Arver via GitGitGadget, Jan 26, 2024
  53. 00/10 Enrich Trailer APILinus Arver via GitGitGadget, Jan 31, 2024
  54. 01/10 trailer: prepare to expose functions as part of APILinus Arver via GitGitGadget, Jan 31, 2024
  55. 02/10 trailer: move interpret_trailers() to interpret-trailers.cLinus Arver via GitGitGadget, Jan 31, 2024
  56. Junio C HamanoJan 31, 2024
  57. Linus ArverJan 31, 2024
  58. 03/10 trailer: unify trailer formatting machineryLinus Arver via GitGitGadget, Jan 31, 2024
  59. Josh SteadmonJan 31, 2024
  60. Linus ArverJan 31, 2024
  61. Junio C HamanoFeb 1, 2024
  62. Linus ArverFeb 1, 2024
  63. Junio C HamanoJan 31, 2024
  64. Junio C HamanoJan 31, 2024
  65. Linus ArverFeb 1, 2024
  66. Junio C HamanoFeb 1, 2024
  67. Junio C HamanoFeb 1, 2024
  68. Linus ArverFeb 1, 2024
  69. Junio C HamanoFeb 1, 2024
  70. Linus ArverFeb 2, 2024
  71. Junio C HamanoFeb 2, 2024
  72. Linus ArverJan 31, 2024
  73. 04/10 sequencer: use the trailer iteratorLinus Arver via GitGitGadget, Jan 31, 2024
  74. Junio C HamanoFeb 1, 2024
  75. Linus ArverFeb 1, 2024
  76. Linus ArverFeb 3, 2024
  77. 05/10 trailer: make trailer_info struct privateLinus Arver via GitGitGadget, Jan 31, 2024
  78. Junio C HamanoFeb 1, 2024
  79. Linus ArverFeb 3, 2024
  80. Junio C HamanoFeb 3, 2024
  81. 06/10 trailer: spread usage of "trailer_block" languageLinus Arver via GitGitGadget, Jan 31, 2024
  82. Junio C HamanoFeb 1, 2024
  83. Linus ArverFeb 3, 2024
  84. 07/10 trailer: prepare to move parse_trailers_from_command_line_args() to builtinLinus Arver via GitGitGadget, Jan 31, 2024
  85. Junio C HamanoFeb 1, 2024
  86. 08/10 trailer: move arg handling to interpret-trailers.cLinus Arver via GitGitGadget, Jan 31, 2024
  87. Junio C HamanoFeb 1, 2024
  88. Linus ArverFeb 3, 2024
  89. Linus ArverFeb 6, 2024
  90. 09/10 trailer: delete obsolete argument handling code from APILinus Arver via GitGitGadget, Jan 31, 2024
  91. Junio C HamanoFeb 1, 2024
  92. Linus ArverFeb 3, 2024
  93. 10/10 trailer: introduce "template" term for readabilityLinus Arver via GitGitGadget, Jan 31, 2024
  94. 00/28 Enrich Trailer APILinus Arver via GitGitGadget, Feb 6, 2024
  95. 01/28 trailer: free trailer_info _after_ all related usageLinus Arver via GitGitGadget, Feb 6, 2024
  96. 02/28 shortlog: add test for de-duplicating folded trailersLinus Arver via GitGitGadget, Feb 6, 2024
  97. 03/28 trailer: prepare to expose functions as part of APILinus Arver via GitGitGadget, Feb 6, 2024
  98. 04/28 trailer: move interpret_trailers() to interpret-trailers.cLinus Arver via GitGitGadget, Feb 6, 2024
  99. 05/28 trailer: start preparing for formatting unificationLinus Arver via GitGitGadget, Feb 6, 2024
  100. 06/28 trailer_info_get(): reorder parametersLinus Arver via GitGitGadget, Feb 6, 2024
  101. 07/28 format_trailers(): use strbuf instead of FILELinus Arver via GitGitGadget, Feb 6, 2024
  102. 08/28 format_trailer_info(): move "fast path" to callerLinus Arver via GitGitGadget, Feb 6, 2024
  103. 09/28 format_trailers_from_commit(): indirectly call trailer_info_get()Linus Arver via GitGitGadget, Feb 6, 2024
  104. 10/28 format_trailer_info(): use trailer_item objectsLinus Arver via GitGitGadget, Feb 6, 2024
  105. Junio C HamanoFeb 9, 2024
  106. Linus ArverFeb 13, 2024
  107. 11/28 format_trailer_info(): drop redundant unfold_value()Linus Arver via GitGitGadget, Feb 6, 2024
  108. Junio C HamanoFeb 9, 2024
  109. 12/28 format_trailer_info(): append newline for non-trailer linesLinus Arver via GitGitGadget, Feb 6, 2024
  110. Junio C HamanoFeb 9, 2024
  111. Christian CouderFeb 12, 2024
  112. Linus ArverFeb 13, 2024
  113. 13/28 trailer: begin formatting unificationLinus Arver via GitGitGadget, Feb 6, 2024
  114. 14/28 format_trailer_info(): teach it about opts->trim_emptyLinus Arver via GitGitGadget, Feb 6, 2024
  115. Christian CouderFeb 12, 2024
  116. Linus ArverFeb 13, 2024
  117. Christian CouderFeb 13, 2024
  118. 15/28 format_trailer_info(): avoid double-printing the separatorLinus Arver via GitGitGadget, Feb 6, 2024
  119. Christian CouderFeb 12, 2024
  120. Linus ArverFeb 13, 2024
  121. Christian CouderFeb 13, 2024
  122. Linus ArverFeb 13, 2024
  123. Linus ArverMar 15, 2024
  124. Kristoffer HaugsbakkFeb 13, 2024
  125. 16/28 trailer: finish formatting unificationLinus Arver via GitGitGadget, Feb 6, 2024
  126. Junio C HamanoFeb 9, 2024
  127. Christian CouderFeb 12, 2024
  128. Linus ArverFeb 13, 2024
  129. 17/28 trailer: teach iterator about non-trailer linesLinus Arver via GitGitGadget, Feb 6, 2024
  130. 18/28 sequencer: use the trailer iteratorLinus Arver via GitGitGadget, Feb 6, 2024
  131. 19/28 trailer: make trailer_info struct privateLinus Arver via GitGitGadget, Feb 6, 2024
  132. Junio C HamanoFeb 9, 2024
  133. Linus ArverFeb 13, 2024
  134. Christian CouderFeb 12, 2024
  135. Linus ArverFeb 13, 2024
  136. 20/28 trailer: retire trailer_info_get() from APILinus Arver via GitGitGadget, Feb 6, 2024
  137. 21/28 trailer: spread usage of "trailer_block" languageLinus Arver via GitGitGadget, Feb 6, 2024
  138. Christian CouderFeb 12, 2024
  139. Linus ArverFeb 13, 2024
  140. 22/28 trailer: prepare to delete "parse_trailers_from_command_line_args()"Linus Arver via GitGitGadget, Feb 6, 2024
  141. Christian CouderFeb 12, 2024
  142. Linus ArverFeb 13, 2024
  143. 23/28 trailer: add new helper functions to APILinus Arver via GitGitGadget, Feb 6, 2024
  144. Christian CouderFeb 12, 2024
  145. Linus ArverFeb 13, 2024
  146. 24/28 trailer_add_arg_item(): drop new_trailer_item usageLinus Arver via GitGitGadget, Feb 6, 2024
  147. 25/28 trailer: deprecate "new_trailer_item" struct from APILinus Arver via GitGitGadget, Feb 6, 2024
  148. 26/28 trailer: unify "--trailer ..." arg handlingLinus Arver via GitGitGadget, Feb 6, 2024
  149. Christian CouderFeb 12, 2024
  150. Linus ArverFeb 13, 2024
  151. 27/28 trailer_set_*(): put out parameter at the endLinus Arver via GitGitGadget, Feb 6, 2024
  152. Christian CouderFeb 12, 2024
  153. Linus ArverFeb 13, 2024
  154. 28/28 trailer: introduce "template" term for readabilityLinus Arver via GitGitGadget, Feb 6, 2024
  155. Christian CouderFeb 12, 2024
  156. Linus ArverFeb 13, 2024
  157. Christian CouderFeb 12, 2024
  158. Junio C HamanoFeb 13, 2024
  159. Christian CouderFeb 13, 2024
  160. Junio C HamanoFeb 13, 2024
  161. Christian CouderFeb 13, 2024
  162. Linus ArverFeb 16, 2024
  163. Linus ArverFeb 13, 2024
  164. Junio C HamanoFeb 13, 2024
  165. Kristoffer HaugsbakkFeb 13, 2024
  166. Christian CouderFeb 13, 2024
  167. Linus ArverFeb 16, 2024
  168. 0/9 Enrich Trailer APILinus Arver via GitGitGadget, Feb 16, 2024
  169. 1/9 trailer: free trailer_info _after_ all related usageLinus Arver via GitGitGadget, Feb 16, 2024
  170. 2/9 shortlog: add test for de-duplicating folded trailersLinus Arver via GitGitGadget, Feb 16, 2024
  171. 3/9 trailer: prepare to expose functions as part of APILinus Arver via GitGitGadget, Feb 16, 2024
  172. Christian CouderFeb 19, 2024
  173. Linus ArverFeb 29, 2024
  174. Junio C HamanoFeb 29, 2024
  175. Linus ArverFeb 29, 2024
  176. 4/9 trailer: move interpret_trailers() to interpret-trailers.cLinus Arver via GitGitGadget, Feb 16, 2024
  177. 5/9 trailer: start preparing for formatting unificationLinus Arver via GitGitGadget, Feb 16, 2024
  178. Christian CouderFeb 19, 2024
  179. Linus ArverFeb 29, 2024
  180. 6/9 trailer_info_get(): reorder parametersLinus Arver via GitGitGadget, Feb 16, 2024
  181. 7/9 format_trailers(): use strbuf instead of FILELinus Arver via GitGitGadget, Feb 16, 2024
  182. 8/9 format_trailer_info(): move "fast path" to callerLinus Arver via GitGitGadget, Feb 16, 2024
  183. 9/9 format_trailers_from_commit(): indirectly call trailer_info_get()Linus Arver via GitGitGadget, Feb 16, 2024
  184. Christian CouderFeb 19, 2024
  185. Linus ArverFeb 29, 2024
  186. Christian CouderFeb 19, 2024
  187. 0/9 Enrich Trailer APILinus Arver via GitGitGadget, Mar 1, 2024
  188. 1/9 trailer: free trailer_info _after_ all related usageLinus Arver via GitGitGadget, Mar 1, 2024
  189. 2/9 shortlog: add test for de-duplicating folded trailersLinus Arver via GitGitGadget, Mar 1, 2024
  190. 3/9 trailer: rename functions to use 'trailer'Linus Arver via GitGitGadget, Mar 1, 2024
  191. 4/9 trailer: move interpret_trailers() to interpret-trailers.cLinus Arver via GitGitGadget, Mar 1, 2024
  192. 5/9 trailer: reorder format_trailers_from_commit() parametersLinus Arver via GitGitGadget, Mar 1, 2024
  193. 6/9 trailer_info_get(): reorder parametersLinus Arver via GitGitGadget, Mar 1, 2024
  194. 7/9 format_trailers(): use strbuf instead of FILELinus Arver via GitGitGadget, Mar 1, 2024
  195. 8/9 format_trailer_info(): move "fast path" to callerLinus Arver via GitGitGadget, Mar 1, 2024
  196. 9/9 format_trailers_from_commit(): indirectly call trailer_info_get()Linus Arver via GitGitGadget, Mar 1, 2024
  197. Junio C HamanoMar 5, 2024
  198. Josh SteadmonMar 5, 2024
  199. Junio C HamanoMar 5, 2024
  200. Christian CouderMar 6, 2024
  201. Junio C HamanoMar 6, 2024
  202. Junio C HamanoMar 6, 2024

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.