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 <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Sep 8, 2025 at 07:30 UTC 68a746e9a892f8afa910cdf5c5360dae69193599
1 file changed +7 -8
promisor-remote.c
+7 -8
@@ -769,16 +769,15 @@ char *promisor_remote_reply(const char *info)
769
770 void mark_promisor_remotes_as_accepted(struct repository *r, const char *remotes)
771 {
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;
774
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);
776
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);
780
781 - p = repo_promisor_remote_find(r, decoded_remote);
781 if (p)
782 p->accepted = 1;
783 else
@@ -788,5 +787,5 @@ void mark_promisor_remotes_as_accepted(struct repository *r, const char *remotes
787 free(decoded_remote);
788 }
789
791 - strbuf_list_free(accepted_remotes);
790 + string_list_clear(&accepted_remotes, 0);
791 }