On Mon, Oct 10 2022, Taylor Blau wrote: > Instead of handling SHORTLOG_GROUP_AUTHOR separately, reimplement it as > a special case of the new `--group=<format>` mode, where the author mode > is a shorthand for `--group='%aN <%aE>'. > > Note that we still need to keep the SHORTLOG_GROUP_AUTHOR enum since it > has a different meaning in `read_from_stdin()`, where it is still used > for a different purpose. > > Signed-off-by: Taylor Blau <me@xxxxxxxxxxxx> > --- > builtin/log.c | 1 + > builtin/shortlog.c | 23 ++++++++++++----------- > shortlog.h | 1 + > 3 files changed, 14 insertions(+), 11 deletions(-) > > diff --git a/builtin/log.c b/builtin/log.c > index ee19dc5d45..6b77e520b5 100644 > --- a/builtin/log.c > +++ b/builtin/log.c > @@ -1334,6 +1334,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file, > log.in2 = 4; > log.file = rev->diffopt.file; > log.groups = SHORTLOG_GROUP_AUTHOR; > + shortlog_init_group(&log); > for (i = 0; i < nr; i++) > shortlog_add_commit(&log, list[i]); > > diff --git a/builtin/shortlog.c b/builtin/shortlog.c > index f708d96558..aac8c7afa4 100644 > --- a/builtin/shortlog.c > +++ b/builtin/shortlog.c > @@ -245,15 +245,6 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit) > } > oneline_str = oneline.len ? oneline.buf : "<none>"; > > - if (log->groups & SHORTLOG_GROUP_AUTHOR) { > - strbuf_reset(&ident); > - format_commit_message(commit, > - log->email ? "%aN <%aE>" : "%aN", > - &ident, &ctx); > - if (!HAS_MULTI_BITS(log->groups) || > - strset_add(&dups, ident.buf)) > - insert_one_record(log, ident.buf, oneline_str); > - } > if (log->groups & SHORTLOG_GROUP_COMMITTER) { > strbuf_reset(&ident); > format_commit_message(commit, > @@ -372,6 +363,16 @@ void shortlog_init(struct shortlog *log) > log->format.strdup_strings = 1; > } > > +void shortlog_init_group(struct shortlog *log) > +{ > + if (!log->groups) > + log->groups = SHORTLOG_GROUP_AUTHOR; > + > + if (log->groups & SHORTLOG_GROUP_AUTHOR) Nit (easier reading): if (!x) ... else if (x & FLAG) ...