]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/log: stop using globals for log config
authorPatrick Steinhardt <ps@pks.im>
Mon, 27 May 2024 11:46:30 +0000 (13:46 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 May 2024 18:19:59 +0000 (11:19 -0700)
commit106a54aecb21fb17956290aee4e9204aa29174e7
tree295cb10632043754ffb3ab8ccd2c8e0e361e6ae7
parenta6cb0cc61033d10eb948057c45dea25c1ab8e151
builtin/log: stop using globals for log config

We're using global variables to store the log configuration. Many of
these can be set both via the command line and via the config, and
depending on how they are being set, they may contain allocated strings.
This leads to hard-to-track memory ownership and memory leaks.

Refactor the code to instead use a `struct log_config` that is being
allocated on the stack. This allows us to more clearly scope the
variables, track memory ownership and ultimately release the memory.

This also prepares us for a change to `git_config_string()`, which will
be adapted to have a `char **` out parameter instead of `const char **`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/log.c