summaryrefslogtreecommitdiff
path: root/trailer.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-10-04 19:49:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-10-04 19:49:14 (GMT)
commit2fa8aacc723d4c76b84d449fa7cf0de6cf40e5ad (patch)
treee1a865fa66fadcd8cc2380ddb206b86f572aabf3 /trailer.c
parentea1f6118b772d8d03302937afc16e71719d33587 (diff)
parent63d24fa0b055d3f0386ee3686c07428450add708 (diff)
downloadgit-2fa8aacc723d4c76b84d449fa7cf0de6cf40e5ad.zip
git-2fa8aacc723d4c76b84d449fa7cf0de6cf40e5ad.tar.gz
git-2fa8aacc723d4c76b84d449fa7cf0de6cf40e5ad.tar.bz2
Merge branch 'jk/shortlog-group-by-trailer'
"git shortlog" has been taught to group commits by the contents of the trailer lines, like "Reviewed-by:", "Coauthored-by:", etc. * jk/shortlog-group-by-trailer: shortlog: allow multiple groups to be specified shortlog: parse trailer idents shortlog: rename parse_stdin_ident() shortlog: de-duplicate trailer values shortlog: match commit trailers with --group trailer: add interface for iterating over commit trailers shortlog: add grouping option shortlog: change "author" variables to "ident"
Diffstat (limited to 'trailer.c')
-rw-r--r--trailer.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/trailer.c b/trailer.c
index 68dabc2..3f7391d 100644
--- a/trailer.c
+++ b/trailer.c
@@ -1183,3 +1183,39 @@ void format_trailers_from_commit(struct strbuf *out, const char *msg,
format_trailer_info(out, &info, opts);
trailer_info_release(&info);
}
+
+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;
+}
+
+int trailer_iterator_advance(struct trailer_iterator *iter)
+{
+ while (iter->cur < iter->info.trailer_nr) {
+ char *trailer = iter->info.trailers[iter->cur++];
+ int separator_pos = find_separator(trailer, separators);
+
+ if (separator_pos < 1)
+ continue; /* not a real trailer */
+
+ strbuf_reset(&iter->key);
+ strbuf_reset(&iter->val);
+ parse_trailer(&iter->key, &iter->val, NULL,
+ trailer, separator_pos);
+ unfold_value(&iter->val);
+ return 1;
+ }
+ return 0;
+}
+
+void trailer_iterator_release(struct trailer_iterator *iter)
+{
+ trailer_info_release(&iter->info);
+ strbuf_release(&iter->val);
+ strbuf_release(&iter->key);
+}