]> git.ipfire.org Git - thirdparty/git.git/commit - bundle.c
bundle: remove "ref_list" in favor of string-list.c API
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 2 Jul 2021 09:57:32 +0000 (11:57 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 6 Jul 2021 19:10:17 +0000 (12:10 -0700)
commit10b635b77311badcbb5045b7421e6826c4536613
tree82fda8f84620a0dfc3c48770430194f848ca92e0
parent15e7c7dca66ab7b020316696f54433f76e5e1084
bundle: remove "ref_list" in favor of string-list.c API

Move away from the "struct ref_list" in bundle.c in favor of the
almost identical string-list.c API.

That API fits this use-case perfectly, but did not exist in its
current form when this code was added in 2e0afafebd (Add git-bundle:
move objects and references by archive, 2007-02-22), with hindsight we
could have used the path-list API, which later got renamed to
string-list. See 8fd2cb4069 (Extract helper bits from
c-merge-recursive work, 2006-07-25)

We need to change "name" to "string" and "oid" to "util" to make this
conversion, but other than that the APIs are pretty much identical for
what bundle.c made use of.

Let's also replace the memset(..,0,...) pattern with a more idiomatic
"INIT" macro, and finally add a *_release() function so to free the
allocated memory.

Before this the add_to_ref_list() would leak memory, now e.g. "bundle
list-heads" reports no memory leaks at all under valgrind.

In the bundle_header_init() function we're using a clever trick to
memcpy() what we'd get from the corresponding
BUNDLE_HEADER_INIT. There is a concurrent series to make use of that
pattern more generally, see [1].

1. https://lore.kernel.org/git/cover-0.5-00000000000-20210701T104855Z-avarab@gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/bundle.c
bundle.c
bundle.h
transport.c