summaryrefslogtreecommitdiff
path: root/pretty.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2021-06-22 16:04:50 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-06-29 03:30:17 (GMT)
commitb2086b518366ed71caac498857b9c5765dd73ed1 (patch)
tree8e47d1a2368c3a1d758dacec201f9669928e4f37 /pretty.h
parent3c7e2e8f0acfe94220cdd3bbd3a35a955ae80294 (diff)
downloadgit-b2086b518366ed71caac498857b9c5765dd73ed1.zip
git-b2086b518366ed71caac498857b9c5765dd73ed1.tar.gz
git-b2086b518366ed71caac498857b9c5765dd73ed1.tar.bz2
log: avoid loading decorations for userformats that don't need it
If no --decorate option is given, we default to auto-decoration. And when that kicks in, cmd_log_init_finish() will unconditionally load the decoration refs. However, if we are using a user-format that does not include "%d" or "%D", we won't show the decorations at all, so we don't need to load them. We can detect this case and auto-disable them by adding a new field to our userformat_want helper. We can do this even when the user explicitly asked for --decorate, because it can't affect the output at all. This patch consistently reduces the time to run "git log -1 --format=%H" on my git.git clone (with ~2k refs) from 34ms to 7ms. On a much more extreme real-world repository (with ~220k refs), it goes from 2.5s to 4ms. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pretty.h')
-rw-r--r--pretty.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/pretty.h b/pretty.h
index c81cf40..2f16acd 100644
--- a/pretty.h
+++ b/pretty.h
@@ -73,6 +73,7 @@ static inline int cmit_fmt_is_mail(enum cmit_fmt fmt)
struct userformat_want {
unsigned notes:1;
unsigned source:1;
+ unsigned decorate:1;
};
void userformat_find_requirements(const char *fmt, struct userformat_want *w);