aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Couder <christian.couder@gmail.com>2025-09-08 07:30:53 +0200
committerJunio C Hamano <gitster@pobox.com>2025-09-08 10:30:56 -0700
commit68a746e9a892f8afa910cdf5c5360dae69193599 (patch)
tree291dbb7dadfd7f9dd648dc895cd8d9c0f9053280
parentc213820c512dc0a5cfe11a075e41f789f3225923 (diff)
downloadgit-68a746e9a892f8afa910cdf5c5360dae69193599.tar.xz
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>
-rw-r--r--promisor-remote.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/promisor-remote.c b/promisor-remote.c
index a6cfade223..77ebf537e2 100644
--- a/promisor-remote.c
+++ b/promisor-remote.c
@@ -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);
}