diff options
author | Jeff King <peff@peff.net> | 2021-06-22 18:04:50 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-06-29 05:30:17 +0200 |
commit | b2086b518366ed71caac498857b9c5765dd73ed1 (patch) | |
tree | 8e47d1a2368c3a1d758dacec201f9669928e4f37 /builtin/log.c | |
parent | pretty.h: update and expand docstring for userformat_find_requirements() (diff) | |
download | git-b2086b518366ed71caac498857b9c5765dd73ed1.tar.xz git-b2086b518366ed71caac498857b9c5765dd73ed1.zip |
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 'builtin/log.c')
-rw-r--r-- | builtin/log.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/builtin/log.c b/builtin/log.c index 6102893fcc..6ba7f20726 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -245,6 +245,9 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix, rev->abbrev_commit = 0; } + if (rev->commit_format == CMIT_FMT_USERFORMAT && !w.decorate) + decoration_style = 0; + if (decoration_style) { const struct string_list *config_exclude = repo_config_get_value_multi(the_repository, |