Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2022-10-24 21:55:33 +0300
committerJunio C Hamano <gitster@pobox.com>2022-10-25 00:48:05 +0300
commit0b293df9642bc8731e45e636ef8f1c0c5749d4b2 (patch)
tree669f39930b3eb4f5bf800058b44341cf0751af45 /builtin/shortlog.c
parent251554c26931bec94e86d0e5740084d6116dd263 (diff)
shortlog: make trailer insertion a noop when appropriate
When there are no trailers to insert, it is natural that insert_records_from_trailers() should return without having done any work. But instead we guard this call unnecessarily by first checking whether `log->groups` has the `SHORTLOG_GROUP_TRAILER` bit set. Prepare to match a similar pattern in the future where a function which inserts records of a certain type does no work when no specifiers matching that type are given. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/shortlog.c')
-rw-r--r--builtin/shortlog.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 53c379a51d..18f0800c82 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -170,6 +170,9 @@ static void insert_records_from_trailers(struct shortlog *log,
const char *commit_buffer, *body;
struct strbuf ident = STRBUF_INIT;
+ if (!log->trailers.nr)
+ return;
+
/*
* Using format_commit_message("%B") would be simpler here, but
* this saves us copying the message.
@@ -240,9 +243,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
strset_add(&dups, ident.buf))
insert_one_record(log, ident.buf, oneline_str);
}
- if (log->groups & SHORTLOG_GROUP_TRAILER) {
- insert_records_from_trailers(log, &dups, commit, &ctx, oneline_str);
- }
+ insert_records_from_trailers(log, &dups, commit, &ctx, oneline_str);
strset_clear(&dups);
strbuf_release(&ident);