]> git.ipfire.org Git - thirdparty/git.git/commit - branch.c
worktree: simplify find_shared_symref() memory ownership model
authorAnders Kaseorg <andersk@mit.edu>
Wed, 1 Dec 2021 22:15:43 +0000 (14:15 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 2 Dec 2021 06:18:25 +0000 (22:18 -0800)
commitc8dd491fa5b57ecfd9ef33ae5291eb2a9402cd59
treeb686f1bb1a587d214f3a19efa6d56b7c65d07ae2
parent7435e7e2e7645124679eedbfb1443b8408f29219
worktree: simplify find_shared_symref() memory ownership model

Storing the worktrees list in a static variable meant that
find_shared_symref() had to rebuild the list on each call (which is
inefficient when the call site is in a loop), and also that each call
invalidated the pointer returned by the previous call (which is
confusing).

Instead, make it the caller’s responsibility to pass in the worktrees
list and manage its lifetime.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
branch.c
builtin/branch.c
builtin/notes.c
builtin/receive-pack.c
worktree.c
worktree.h