]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/gc: fix leaking config values
authorPatrick Steinhardt <ps@pks.im>
Fri, 16 Aug 2024 10:45:03 +0000 (12:45 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 Aug 2024 16:46:25 +0000 (09:46 -0700)
commit0ce44e2293352bc3636d93c156fbc2a1ebac0e45
tree8cf86d404f7e40c185a8ef8108f96ed63ee07575
parentd1ae15d68b44af4ef6e6caedb7aa2b2dcce03c02
builtin/gc: fix leaking config values

We're leaking config values in git-gc(1) when those values are tracked
as strings. Introduce a new `gc_config_release()` function that releases
this memory to plug those leaks and release old values before populating
the config fields via `git_config_string()` et al.

Note that there is one small gotcha here with the "--prune" option. Next
to passing a string, this option also accepts the "--no-prune" option
that overrides the default or configured value. We thus need to discern
between the option not having been passed by the user and the negative
variant of it. This is done by using a simple sentinel value that lets
us discern these cases.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/gc.c
t/t5304-prune.sh