]> git.ipfire.org Git - thirdparty/git.git/commit
promisor-remote: refactor to get rid of 'struct strvec'
authorChristian Couder <christian.couder@gmail.com>
Mon, 8 Sep 2025 05:30:47 +0000 (07:30 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 Sep 2025 17:30:54 +0000 (10:30 -0700)
commit57af9cc2e628165bef849576e2d42d8b200717ee
tree061a703810d6703c55ac8e6ea64c88a250b4a180
parent6ad802182101d622e6a4132f48292ddfa79e2024
promisor-remote: refactor to get rid of 'struct strvec'

In a following commit, we will use the new 'promisor-remote' protocol
capability introduced by d460267613 (Add 'promisor-remote' capability
to protocol v2, 2025-02-18) to pass and process more information
about promisor remotes than just their name and url.

For that purpose, we will need to store information about other
fields, especially information that might or might not be available
for different promisor remotes. Unfortunately using 'struct strvec',
as we currently do, to store information about the promisor remotes
with one 'struct strvec' for each field like "name" or "url" does not
scale easily in that case. We would need one 'struct strvec' for each
new field, and then we would have to pass all these 'struct strvec'
around.

Let's refactor this and introduce a new 'struct promisor_info'.

It will only store promisor remote information in its members. For now
it has only a 'name' member for the promisor remote name and an 'url'
member for its URL. We will use a 'struct string_list' to store the
instances of 'struct promisor_info'. For each 'item' in the
string_list, 'item->string' will point to the promisor remote name and
'item->util' will point to the corresponding 'struct promisor_info'
instance.

Explicit members are used within 'struct promisor_info' for type
safety and clarity regarding the specific information being handled,
rather than a generic key-value store. We want to specify and document
each field and its content, so adding new members to the struct as
more fields are supported is fine.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
promisor-remote.c