Skip to content

Commit 68a746e

Browse files
chriscoolgitster
authored andcommitted
promisor-remote: use string_list_split() in mark_remotes_as_accepted()
Previous commits replaced some strbuf_split*() calls with calls to string_list_split*() in "promisor-remote.c". For consistency, let's also replace the strbuf_split_str() call in mark_remotes_as_accepted() with a call to string_list_split(), as we don't need the splitted strings to be managed by a `struct strbuf`. Using the lighter-weight `string_list` API is enough for our needs. While at it let's remove a useless call to `strbuf_strip_suffix()`. Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c213820 commit 68a746e

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

promisor-remote.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -769,16 +769,15 @@ char *promisor_remote_reply(const char *info)
769769

770770
void mark_promisor_remotes_as_accepted(struct repository *r, const char *remotes)
771771
{
772-
struct strbuf **accepted_remotes = strbuf_split_str(remotes, ';', 0);
772+
struct string_list accepted_remotes = STRING_LIST_INIT_DUP;
773+
struct string_list_item *item;
773774

774-
for (size_t i = 0; accepted_remotes[i]; i++) {
775-
struct promisor_remote *p;
776-
char *decoded_remote;
775+
string_list_split(&accepted_remotes, remotes, ";", -1);
777776

778-
strbuf_strip_suffix(accepted_remotes[i], ";");
779-
decoded_remote = url_percent_decode(accepted_remotes[i]->buf);
777+
for_each_string_list_item(item, &accepted_remotes) {
778+
char *decoded_remote = url_percent_decode(item->string);
779+
struct promisor_remote *p = repo_promisor_remote_find(r, decoded_remote);
780780

781-
p = repo_promisor_remote_find(r, decoded_remote);
782781
if (p)
783782
p->accepted = 1;
784783
else
@@ -788,5 +787,5 @@ void mark_promisor_remotes_as_accepted(struct repository *r, const char *remotes
788787
free(decoded_remote);
789788
}
790789

791-
strbuf_list_free(accepted_remotes);
790+
string_list_clear(&accepted_remotes, 0);
792791
}

0 commit comments

Comments
 (0)