Thanks, Peff, for the pointer to list.h. Using list.h does simplify the code by a similar amount to switching it to a singly-linked list, so I have done that (replacing my earlier "trailer: use singly-linked list, not doubly" patch). Another advantage is that I no longer need to change the algorithm, making for a smaller patch.
(There are some quirks resulting from list.h implementing a circular list, like needing to pass "head" as a sentinel when iterating from the middle of the list, but those are minor, and my original singly-linked list implementation had quirks too anyway like needing to pass a pointer to the next pointer.) Updates: (-> 1/6) - Added separate patch for const correctness changes (1/5 -> 2/6) - Dropped singly-linked list patch, instead replacing existing doubly-linked list implementation with list.h (5/5 -> 6/6) - Used "char *" instead of "struct strbuf" - Modified test slightly to test whitespace at beginning of line Jonathan Tan (6): trailer: improve const correctness trailer: use list.h for doubly-linked list trailer: streamline trailer item create and add trailer: make args have their own struct trailer: allow non-trailers in trailer block trailer: support values folded to multiple lines Documentation/git-interpret-trailers.txt | 10 +- t/t7513-interpret-trailers.sh | 174 ++++++++++ trailer.c | 538 +++++++++++++++---------------- 3 files changed, 444 insertions(+), 278 deletions(-) -- 2.8.0.rc3.226.g39d4020