diff mbox series

[v2,6/6] shortlog: implement `--group=committer` in terms of `--group=<format>`

Message ID 6a9e204177d486e786574ec682e6d73907a3ce7e.1666320509.git.me@ttaylorr.com (mailing list archive)
State Superseded
Headers show
Series shortlog: introduce `--group=<format>` | expand

Commit Message

Taylor Blau Oct. 21, 2022, 3:11 a.m. UTC
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>
---
 builtin/shortlog.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

Comments

Jeff King Oct. 21, 2022, 5:51 a.m. UTC | #1
On Thu, Oct 20, 2022 at 11:11:44PM -0400, Taylor Blau wrote:

> 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>
> ---
>  builtin/shortlog.c | 14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)

And this one is nice and simple, the AUTHOR one having dealt with all of
the shortlog_finish_setup() parts for us. :)

-Peff
diff mbox series

Patch

diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index fceb84f12f..b9f5af22d3 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -229,7 +229,6 @@  static void insert_records_from_format(struct shortlog *log,
 
 void shortlog_add_commit(struct shortlog *log, struct commit *commit)
 {
-	struct strbuf ident = STRBUF_INIT;
 	struct strbuf oneline = STRBUF_INIT;
 	struct strset dups = STRSET_INIT;
 	struct pretty_print_context ctx = {0};
@@ -249,20 +248,10 @@  void shortlog_add_commit(struct shortlog *log, struct commit *commit)
 	}
 	oneline_str = oneline.len ? oneline.buf : "<none>";
 
-	if (log->groups & SHORTLOG_GROUP_COMMITTER) {
-		strbuf_reset(&ident);
-		format_commit_message(commit,
-				      log->email ? "%cN <%cE>" : "%cN",
-				      &ident, &ctx);
-		if (!HAS_MULTI_BITS(log->groups) ||
-		    strset_add(&dups, ident.buf))
-			insert_one_record(log, ident.buf, oneline_str);
-	}
 	insert_records_from_trailers(log, &dups, commit, &ctx, oneline_str);
 	insert_records_from_format(log, &dups, commit, &ctx, oneline_str);
 
 	strset_clear(&dups);
-	strbuf_release(&ident);
 	strbuf_release(&oneline);
 }
 
@@ -373,6 +362,9 @@  void shortlog_finish_setup(struct shortlog *log)
 	if (log->groups & SHORTLOG_GROUP_AUTHOR)
 		string_list_append(&log->format,
 				   log->email ? "%aN <%aE>" : "%aN");
+	if (log->groups & SHORTLOG_GROUP_COMMITTER)
+		string_list_append(&log->format,
+				   log->email ? "%cN <%cE>" : "%cN");
 
 	string_list_sort(&log->trailers);
 }