aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Couder <christian.couder@gmail.com>2025-09-08 07:30:51 +0200
committerJunio C Hamano <gitster@pobox.com>2025-09-08 10:30:55 -0700
commitbcb08c837570f24a82d6484fc5f475372820e3f3 (patch)
tree6773d22d2a7d17144e47d7c4f9020bf548e15063
parentde1efeaf0cee5ca8947ead8b83235e84652c657f (diff)
downloadgit-bcb08c837570f24a82d6484fc5f475372820e3f3.tar.xz
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 <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--promisor-remote.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/promisor-remote.c b/promisor-remote.c
index c22128d09e..afec0d081d 100644
--- a/promisor-remote.c
+++ b/promisor-remote.c
@@ -623,10 +623,11 @@ static void filter_promisor_remote(struct repository *repo,
struct strvec *accepted,
const char *info)
{
- struct strbuf **remotes;
const char *accept_str;
enum accept_promisor accept = ACCEPT_NONE;
struct string_list config_info = STRING_LIST_INIT_NODUP;
+ struct string_list remote_info = STRING_LIST_INIT_DUP;
+ struct string_list_item *item;
if (!repo_config_get_string_tmp(the_repository, "promisor.acceptfromserver", &accept_str)) {
if (!*accept_str || !strcasecmp("None", accept_str))
@@ -652,14 +653,12 @@ static void filter_promisor_remote(struct repository *repo,
/* Parse remote info received */
- remotes = strbuf_split_str(info, ';', 0);
+ string_list_split(&remote_info, info, ";", -1);
- for (size_t i = 0; remotes[i]; i++) {
+ for_each_string_list_item(item, &remote_info) {
struct promisor_info *advertised;
- strbuf_strip_suffix(remotes[i], ";");
-
- advertised = parse_one_advertised_remote(remotes[i]->buf);
+ advertised = parse_one_advertised_remote(item->string);
if (!advertised)
continue;
@@ -671,7 +670,7 @@ static void filter_promisor_remote(struct repository *repo,
}
promisor_info_list_clear(&config_info);
- strbuf_list_free(remotes);
+ string_list_clear(&remote_info, 0);
}
char *promisor_remote_reply(const char *info)