]> git.ipfire.org Git - thirdparty/git.git/commit
revision: fix leaking display notes
authorPatrick Steinhardt <ps@pks.im>
Tue, 11 Jun 2024 09:19:45 +0000 (11:19 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Jun 2024 20:15:05 +0000 (13:15 -0700)
commit97485374377fa62fdd36f4b707e2fcd8f1a7c6c3
treef37b7563648e311dc7f7d86f179bb38731e6c0b5
parent3d31d382557527bf945a088931e3e28a717cc547
revision: fix leaking display notes

We never free the display notes options embedded into `struct revision`.
Implement a new function `release_display_notes()` that we can call in
`release_revisions()` to fix this.

There is another gotcha here though: we play some games with the string
list used to track extra notes refs, where we sometimes set the bit that
indicates that strings should be strdup'd and sometimes unset it. This
dance is done to avoid a copy of an already-allocated string when we
call `enable_ref_display_notes()`. But this dance is rather pointless as
we can instead call `string_list_append_nodup()` to transfer ownership
of the allocated string to the list.

Refactor the code to do so and drop the `strdup_strings` dance.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
notes.c
notes.h
revision.c
t/t3301-notes.sh