From: "Martin Ågren" <martin.agren@gmail.com>
To: Jeff King <peff@peff.net>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH 3/8] trailer: add interface for iterating over commit trailers
Date: Sat, 26 Sep 2020 14:39:32 +0200 [thread overview]
Message-ID: <CAN0heSrhmf9-Ep+SWe7Wy-7c3M9-1NFBybSA=6aJ1vDYGTdciA@mail.gmail.com> (raw)
In-Reply-To: <20200925070249.GC62741@coredump.intra.peff.net>
On Fri, 25 Sep 2020 at 09:04, Jeff King <peff@peff.net> wrote:
>
> The trailer code knows how to parse out the trailers and re-format them,
> but there's no easy way to iterate over the trailers (you can use
> trailer_info, but you have to then do a bunch of extra parsing).
>
> Let's add an iteration interface that makes this easy to do.
> +void trailer_iterator_init(struct trailer_iterator *iter, const char *msg)
> +{
> + struct process_trailer_options opts = PROCESS_TRAILER_OPTIONS_INIT;
> + strbuf_init(&iter->key, 0);
> + strbuf_init(&iter->val, 0);
> + opts.no_divider = 1;
> + trailer_info_get(&iter->info, msg, &opts);
> + iter->cur = 0;
> +}
Ok, this does initialize everything...
> +void trailer_iterator_release(struct trailer_iterator *iter)
> +{
> + trailer_info_release(&iter->info);
> + strbuf_release(&iter->val);
> + strbuf_release(&iter->key);
> +}
... and this side takes care of everything, too.
> #define TRAILER_H
>
> #include "list.h"
> -
> -struct strbuf;
> +#include "strbuf.h"
Spotting and removing the forward declaration, ok.
> +/*
> + * An interface for iterating over the trailers found in a particular commit
> + * message. Use like:
> + *
> + * struct trailer_iterator iter;
> + * trailer_iterator_init(&iter, msg);
> + * while (trailer_iterator_advance(&iter))
> + * ... do something with iter.key and iter.val ...
> + * trailer_iterator_release(&iter);
> + */
> +struct trailer_iterator {
> + struct strbuf key;
> + struct strbuf val;
> +
> + /* private */
> + struct trailer_info info;
> + size_t cur;
> +};
Ok.
> +/*
> + * Initialize "iter" in preparation for walking over the trailers in the commit
> + * message "msg". The "msg" pointer must remain valid until the iterator is
> + * released.
> + *
> + * After initializing, we are not yet pointing
> + */
Truncated sentence. "... not yet pointing at any trailer"?
Martin
next prev parent reply other threads:[~2020-09-26 12:41 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-25 7:01 [PATCH 0/8] parsing trailers with shortlog Jeff King
2020-09-25 7:01 ` [PATCH 1/8] shortlog: change "author" variables to "ident" Jeff King
2020-09-25 7:02 ` [PATCH 2/8] shortlog: refactor committer/author grouping Jeff King
2020-09-25 20:05 ` Eric Sunshine
2020-09-27 8:03 ` Jeff King
2020-09-27 8:08 ` Jeff King
2020-09-27 8:23 ` Eric Sunshine
2020-09-26 12:31 ` Martin Ågren
2020-09-27 7:59 ` Jeff King
2020-09-25 7:02 ` [PATCH 3/8] trailer: add interface for iterating over commit trailers Jeff King
2020-09-26 12:39 ` Martin Ågren [this message]
2020-09-27 8:20 ` Jeff King
2020-09-25 7:03 ` [PATCH 4/8] shortlog: match commit trailers with --group Jeff King
2020-09-25 7:05 ` [PATCH 5/8] shortlog: de-duplicate trailer values Jeff King
2020-09-25 7:05 ` [PATCH 6/8] shortlog: rename parse_stdin_ident() Jeff King
2020-09-25 7:05 ` [PATCH 7/8] shortlog: parse trailer idents Jeff King
2020-09-25 7:05 ` [PATCH 8/8] shortlog: allow multiple groups to be specified Jeff King
2020-09-25 20:23 ` Eric Sunshine
2020-09-27 8:06 ` Jeff King
2020-09-26 12:48 ` Martin Ågren
2020-09-27 8:25 ` Jeff King
2020-09-25 14:27 ` [PATCH 0/8] parsing trailers with shortlog Derrick Stolee
2020-09-25 16:57 ` Junio C Hamano
2020-09-27 8:39 ` [PATCH v2 " Jeff King
2020-09-27 8:39 ` [PATCH v2 1/8] shortlog: change "author" variables to "ident" Jeff King
2020-09-27 19:18 ` Junio C Hamano
2020-09-27 8:39 ` [PATCH v2 2/8] shortlog: add grouping option Jeff King
2020-09-27 8:40 ` [PATCH v2 3/8] trailer: add interface for iterating over commit trailers Jeff King
2020-09-27 8:40 ` [PATCH v2 4/8] shortlog: match commit trailers with --group Jeff King
2020-09-27 19:51 ` Junio C Hamano
2020-09-28 3:17 ` Jeff King
2020-09-28 17:01 ` Junio C Hamano
2020-09-27 8:40 ` [PATCH v2 5/8] shortlog: de-duplicate trailer values Jeff King
2020-09-27 20:23 ` Junio C Hamano
2020-09-28 3:19 ` Jeff King
2020-09-27 8:40 ` [PATCH v2 6/8] shortlog: rename parse_stdin_ident() Jeff King
2020-09-27 8:40 ` [PATCH v2 7/8] shortlog: parse trailer idents Jeff King
2020-09-27 20:49 ` Junio C Hamano
2020-09-27 8:40 ` [PATCH v2 8/8] shortlog: allow multiple groups to be specified Jeff King
2020-09-27 21:18 ` Junio C Hamano
2020-09-28 3:25 ` Jeff King
2020-12-28 11:29 ` Junio C Hamano
2021-02-04 6:44 ` Junio C Hamano
2020-09-27 14:38 ` [PATCH v2 0/8] parsing trailers with shortlog Martin Ågren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAN0heSrhmf9-Ep+SWe7Wy-7c3M9-1NFBybSA=6aJ1vDYGTdciA@mail.gmail.com' \
--to=martin.agren@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).