shortlog: implement `--group=committer` in terms of `--group=<format>`

In the same spirit as the previous commit, reimplement `--group=committer` as a special case of `--group=<format>`, too. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Oct 24, 2022 at 14:55 UTC 7b11234e3bee123d6d48ed175f11b26b54fa67c6
1 file changed +3 -11
builtin/shortlog.c
+3 -11
@@ -233,7 +233,6 @@ static void insert_records_from_format(struct shortlog *log,
233
234 void shortlog_add_commit(struct shortlog *log, struct commit *commit)
235 {
236 - struct strbuf ident = STRBUF_INIT;
236 struct strbuf oneline = STRBUF_INIT;
237 struct strset dups = STRSET_INIT;
238 struct pretty_print_context ctx = {0};
@@ -253,20 +252,10 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
252 }
253 oneline_str = oneline.len ? oneline.buf : "<none>";
254
256 - if (log->groups & SHORTLOG_GROUP_COMMITTER) {
257 - strbuf_reset(&ident);
258 - format_commit_message(commit,
259 - log->email ? "%cN <%cE>" : "%cN",
260 - &ident, &ctx);
261 - if (!HAS_MULTI_BITS(log->groups) ||
262 - strset_add(&dups, ident.buf))
263 - insert_one_record(log, ident.buf, oneline_str);
264 - }
255 insert_records_from_trailers(log, &dups, commit, &ctx, oneline_str);
256 insert_records_from_format(log, &dups, commit, &ctx, oneline_str);
257
258 strset_clear(&dups);
269 - strbuf_release(&ident);
259 strbuf_release(&oneline);
260 }
261
@@ -377,6 +366,9 @@ void shortlog_finish_setup(struct shortlog *log)
366 if (log->groups & SHORTLOG_GROUP_AUTHOR)
367 string_list_append(&log->format,
368 log->email ? "%aN <%aE>" : "%aN");
369 + if (log->groups & SHORTLOG_GROUP_COMMITTER)
370 + string_list_append(&log->format,
371 + log->email ? "%cN <%cE>" : "%cN");
372
373 string_list_sort(&log->trailers);
374 }