promisor-remote: remove the 'accepted' strvec
In a previous commit, filter_promisor_remote() was refactored to keep accepted 'struct promisor_info' instances alive instead of dismantling them into separate parallel data structures. Let's go one step further and replace the 'struct strvec *accepted' argument passed to filter_promisor_remote() with a 'struct string_list *accepted_remotes' argument. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Apr 7, 2026 at 13:52 UTC
d56e483b03bfe46340af5cdbcddec8858661d2e9
1 file changed
+12
-15
promisor-remote.c
+12
-15
@@ -885,12 +885,11 @@ static enum accept_promisor accept_from_server(struct repository *repo)
885
}
886
887
static void filter_promisor_remote(struct repository *repo,
888
- struct strvec *accepted,
888
+ struct string_list *accepted_remotes,
889
const char *info)
890
{
891
struct string_list config_info = STRING_LIST_INIT_NODUP;
892
struct string_list remote_info = STRING_LIST_INIT_DUP;
893
- struct string_list accepted_remotes = STRING_LIST_INIT_NODUP;
893
struct store_info *store_info = NULL;
894
struct string_list_item *item;
895
bool reload_config = false;
@@ -922,7 +921,7 @@ static void filter_promisor_remote(struct repository *repo,
921
if (promisor_store_advertised_fields(advertised, store_info))
922
reload_config = true;
923
925
- string_list_append(&accepted_remotes, advertised->name)->util = advertised;
924
+ string_list_append(accepted_remotes, advertised->name)->util = advertised;
925
} else {
926
promisor_info_free(advertised);
927
}
@@ -936,12 +935,10 @@ static void filter_promisor_remote(struct repository *repo,
935
repo_promisor_remote_reinit(repo);
936
937
/* Apply accepted remotes to the stable repo state */
939
- for_each_string_list_item(item, &accepted_remotes) {
938
+ for_each_string_list_item(item, accepted_remotes) {
939
struct promisor_info *info = item->util;
940
struct promisor_remote *r = repo_promisor_remote_find(repo, info->name);
941
943
- strvec_push(accepted, info->name);
944
-
942
if (r) {
943
r->accepted = 1;
944
if (info->filter) {
@@ -950,23 +947,23 @@ static void filter_promisor_remote(struct repository *repo,
947
}
948
}
949
}
953
-
954
- promisor_info_list_clear(&accepted_remotes);
950
}
951
952
void promisor_remote_reply(const char *info, char **accepted_out)
953
{
959
- struct strvec accepted = STRVEC_INIT;
954
+ struct string_list accepted_remotes = STRING_LIST_INIT_NODUP;
955
961
- filter_promisor_remote(the_repository, &accepted, info);
956
+ filter_promisor_remote(the_repository, &accepted_remotes, info);
957
958
if (accepted_out) {
964
- if (accepted.nr) {
959
+ if (accepted_remotes.nr) {
960
struct strbuf reply = STRBUF_INIT;
966
- for (size_t i = 0; i < accepted.nr; i++) {
967
- if (i)
961
+ struct string_list_item *item;
962
+
963
+ for_each_string_list_item(item, &accepted_remotes) {
964
+ if (reply.len)
965
strbuf_addch(&reply, ';');
969
- strbuf_addstr_urlencode(&reply, accepted.v[i], allow_unsanitized);
966
+ strbuf_addstr_urlencode(&reply, item->string, allow_unsanitized);
967
}
968
*accepted_out = strbuf_detach(&reply, NULL);
969
} else {
@@ -974,7 +971,7 @@ void promisor_remote_reply(const char *info, char **accepted_out)
971
}
972
}
973
977
- strvec_clear(&accepted);
974
+ promisor_info_list_clear(&accepted_remotes);
975
}
976
977
void mark_promisor_remotes_as_accepted(struct repository *r, const char *remotes)