]> git.ipfire.org Git - thirdparty/git.git/commit
checkout: clarify memory ownership in `unique_tracking_name()`
authorPatrick Steinhardt <ps@pks.im>
Mon, 27 May 2024 11:46:06 +0000 (13:46 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 May 2024 18:19:58 +0000 (11:19 -0700)
commitcc395d6b47e4af59b3e87a64b34dffa79e8dc262
treeb1e71b4797f89fe945f2ee87860ee24bcefa37be
parent94e2aa555e7dab4f5296a8dcd8605d751e02b12d
checkout: clarify memory ownership in `unique_tracking_name()`

The function `unique_tracking_name()` returns an allocated string, but
does not clearly indicate this because its return type is `const char *`
instead of `char *`. This has led to various callsites where we never
free its returned memory at all, which causes memory leaks.

Plug those leaks and mark now-passing tests as leak free.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 files changed:
builtin/checkout.c
builtin/worktree.c
checkout.c
checkout.h
t/t2024-checkout-dwim.sh
t/t2060-switch.sh
t/t3426-rebase-submodule.sh
t/t3512-cherry-pick-submodule.sh
t/t3513-revert-submodule.sh
t/t3600-rm.sh
t/t3906-stash-submodule.sh
t/t4137-apply-submodule.sh
t/t6041-bisect-submodule.sh
t/t6438-submodule-directory-file-conflicts.sh