]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/revert: fix leaking `gpg_sign` and `strategy` config
authorPatrick Steinhardt <ps@pks.im>
Mon, 30 Sep 2024 09:13:43 +0000 (11:13 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 30 Sep 2024 18:23:05 +0000 (11:23 -0700)
commitfdf972a9df19915ef7bddf447bfecbcd0d8aea17
treef72a890e976af81145cba1ef476afb14a19d7b8f
parent58888c0401a43bfe2953b0508b5f1bd6c3f32b89
builtin/revert: fix leaking `gpg_sign` and `strategy` config

We leak the config values when `gpg_sign` or `strategy` options are
being overridden via the command line. To fix this we need to free the
old value, which requires us to figure out whether the value was changed
via an option in the first place. The easy way to do this, which is to
initialize local variables with `NULL`, doesn't work because we cannot
tell the case where the user has passed e.g. `--no-gpg-sign`. Instead,
we use a sentinel value for both values that we can compare against to
check whether the user has passed the option.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/revert.c
t/t3514-cherry-pick-revert-gpg.sh