Skip to content

Commit bcb08c8

Browse files
chriscoolgitster
authored andcommitted
promisor-remote: use string_list_split() in filter_promisor_remote()
A previous commit introduced a new parse_one_advertised_remote() function that takes a `const char *` argument. This function is called from filter_promisor_remote() and parses all the fields for one remote. This means that in filter_promisor_remote() we no longer need to split the remote information that will be passed to parse_one_advertised_remote() into an array of relatively heavy and complex `struct strbuf`. To use something lighter, let's then replace strbuf_split_str() with string_list_split() in filter_promisor_remote() to parse the remote information that is passed to parse_one_advertised_remote(). Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent de1efea commit bcb08c8

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

promisor-remote.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,11 @@ static void filter_promisor_remote(struct repository *repo,
623623
struct strvec *accepted,
624624
const char *info)
625625
{
626-
struct strbuf **remotes;
627626
const char *accept_str;
628627
enum accept_promisor accept = ACCEPT_NONE;
629628
struct string_list config_info = STRING_LIST_INIT_NODUP;
629+
struct string_list remote_info = STRING_LIST_INIT_DUP;
630+
struct string_list_item *item;
630631

631632
if (!repo_config_get_string_tmp(the_repository, "promisor.acceptfromserver", &accept_str)) {
632633
if (!*accept_str || !strcasecmp("None", accept_str))
@@ -652,14 +653,12 @@ static void filter_promisor_remote(struct repository *repo,
652653

653654
/* Parse remote info received */
654655

655-
remotes = strbuf_split_str(info, ';', 0);
656+
string_list_split(&remote_info, info, ";", -1);
656657

657-
for (size_t i = 0; remotes[i]; i++) {
658+
for_each_string_list_item(item, &remote_info) {
658659
struct promisor_info *advertised;
659660

660-
strbuf_strip_suffix(remotes[i], ";");
661-
662-
advertised = parse_one_advertised_remote(remotes[i]->buf);
661+
advertised = parse_one_advertised_remote(item->string);
663662

664663
if (!advertised)
665664
continue;
@@ -671,7 +670,7 @@ static void filter_promisor_remote(struct repository *repo,
671670
}
672671

673672
promisor_info_list_clear(&config_info);
674-
strbuf_list_free(remotes);
673+
string_list_clear(&remote_info, 0);
675674
}
676675

677676
char *promisor_remote_reply(const char *info)

0 commit comments

Comments
 (0)