summaryrefslogtreecommitdiff
path: root/Documentation/config/core.txt
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2021-12-02 00:35:43 -0500
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-12-01 22:58:46 -0800
commit14b9c2b3e35929325329e616e122fd71e15b092c (patch)
treea986b95fd85a5ab3fc6f82f0cce037342b14b401 /Documentation/config/core.txt
parentThe first batch to start the current cycle (diff)
downloadtgif-14b9c2b3e35929325329e616e122fd71e15b092c.tar.xz
log: handle --decorate-refs with userformat "%d"
In order to show ref decorations, we first have to load them. If you run: git log --decorate then git-log will recognize the option and load them up front via cmd_log_init(). Likewise if log.decorate is set. If you don't say --decorate explicitly, but do mention "%d" or "%D" in the output format, like so: git log --format=%d then this also works, because we lazy-load the ref decorations. This has been true since 3b3d443feb (add '%d' pretty format specifier to show decoration, 2008-09-04), though the lazy-load was later moved into log-tree.c. But there's one problem: that lazy-load just uses the defaults; it doesn't take into account any --decorate-refs options (or its exclude variant, or their config). So this does not work: git log --decorate-refs=whatever --format=%d It will decorate using all refs, not just the specified ones. This has been true since --decorate-refs was added in 65516f586b (log: add option to choose which refs to decorate, 2017-11-21). Adding further confusion is that it _may_ work because of the auto-decoration feature. If that's in use (and it often is, as it's the default), then if the output is going to stdout, we do enable decorations early (and so load them up front, respecting the extra options). But otherwise we do not. So: git log --decorate-refs=whatever --format=%d >some-file would typically behave differently than it does when the output goes to the pager or terminal! The solution is simple: we should recognize in cmd_log_init() that we're going to show decorations, and make sure we load them there. We already check userformat_find_requirements(), so we can couple this with our existing code there. There are two new tests. The first shows off the actual fix. The second makes sure that our fix doesn't cause us to stomp on an existing --decorate option (see the new comment in the code, as well). Reported-by: Josh Rampersad <josh.rampersad@voiceflow.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/config/core.txt')
0 files changed, 0 insertions, 0 deletions