]> git.ipfire.org Git - thirdparty/git.git/commitdiff
promisor-remote: use string_list_split() in mark_remotes_as_accepted()
authorChristian Couder <christian.couder@gmail.com>
Mon, 8 Sep 2025 05:30:53 +0000 (07:30 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 Sep 2025 17:30:56 +0000 (10:30 -0700)
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>
promisor-remote.c

index a6cfade22377f4063ac6fb457935e11628a1284a..77ebf537e2b3ee3eb9904d3b904badf9c9e64e0e 100644 (file)
@@ -769,16 +769,15 @@ char *promisor_remote_reply(const char *info)
 
 void mark_promisor_remotes_as_accepted(struct repository *r, const char *remotes)
 {
-       struct strbuf **accepted_remotes = strbuf_split_str(remotes, ';', 0);
+       struct string_list accepted_remotes = STRING_LIST_INIT_DUP;
+       struct string_list_item *item;
 
-       for (size_t i = 0; accepted_remotes[i]; i++) {
-               struct promisor_remote *p;
-               char *decoded_remote;
+       string_list_split(&accepted_remotes, remotes, ";", -1);
 
-               strbuf_strip_suffix(accepted_remotes[i], ";");
-               decoded_remote = url_percent_decode(accepted_remotes[i]->buf);
+       for_each_string_list_item(item, &accepted_remotes) {
+               char *decoded_remote = url_percent_decode(item->string);
+               struct promisor_remote *p = repo_promisor_remote_find(r, decoded_remote);
 
-               p = repo_promisor_remote_find(r, decoded_remote);
                if (p)
                        p->accepted = 1;
                else
@@ -788,5 +787,5 @@ void mark_promisor_remotes_as_accepted(struct repository *r, const char *remotes
                free(decoded_remote);
        }
 
-       strbuf_list_free(accepted_remotes);
+       string_list_clear(&accepted_remotes, 0);
 }