Skip to content

Commit d56e483

Browse files
chriscoolgitster
authored andcommitted
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>
1 parent e0f80d8 commit d56e483

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

promisor-remote.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -885,12 +885,11 @@ static enum accept_promisor accept_from_server(struct repository *repo)
885885
}
886886

887887
static void filter_promisor_remote(struct repository *repo,
888-
struct strvec *accepted,
888+
struct string_list *accepted_remotes,
889889
const char *info)
890890
{
891891
struct string_list config_info = STRING_LIST_INIT_NODUP;
892892
struct string_list remote_info = STRING_LIST_INIT_DUP;
893-
struct string_list accepted_remotes = STRING_LIST_INIT_NODUP;
894893
struct store_info *store_info = NULL;
895894
struct string_list_item *item;
896895
bool reload_config = false;
@@ -922,7 +921,7 @@ static void filter_promisor_remote(struct repository *repo,
922921
if (promisor_store_advertised_fields(advertised, store_info))
923922
reload_config = true;
924923

925-
string_list_append(&accepted_remotes, advertised->name)->util = advertised;
924+
string_list_append(accepted_remotes, advertised->name)->util = advertised;
926925
} else {
927926
promisor_info_free(advertised);
928927
}
@@ -936,12 +935,10 @@ static void filter_promisor_remote(struct repository *repo,
936935
repo_promisor_remote_reinit(repo);
937936

938937
/* 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) {
940939
struct promisor_info *info = item->util;
941940
struct promisor_remote *r = repo_promisor_remote_find(repo, info->name);
942941

943-
strvec_push(accepted, info->name);
944-
945942
if (r) {
946943
r->accepted = 1;
947944
if (info->filter) {
@@ -950,31 +947,31 @@ static void filter_promisor_remote(struct repository *repo,
950947
}
951948
}
952949
}
953-
954-
promisor_info_list_clear(&accepted_remotes);
955950
}
956951

957952
void promisor_remote_reply(const char *info, char **accepted_out)
958953
{
959-
struct strvec accepted = STRVEC_INIT;
954+
struct string_list accepted_remotes = STRING_LIST_INIT_NODUP;
960955

961-
filter_promisor_remote(the_repository, &accepted, info);
956+
filter_promisor_remote(the_repository, &accepted_remotes, info);
962957

963958
if (accepted_out) {
964-
if (accepted.nr) {
959+
if (accepted_remotes.nr) {
965960
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)
968965
strbuf_addch(&reply, ';');
969-
strbuf_addstr_urlencode(&reply, accepted.v[i], allow_unsanitized);
966+
strbuf_addstr_urlencode(&reply, item->string, allow_unsanitized);
970967
}
971968
*accepted_out = strbuf_detach(&reply, NULL);
972969
} else {
973970
*accepted_out = NULL;
974971
}
975972
}
976973

977-
strvec_clear(&accepted);
974+
promisor_info_list_clear(&accepted_remotes);
978975
}
979976

980977
void mark_promisor_remotes_as_accepted(struct repository *r, const char *remotes)

0 commit comments

Comments
 (0)