mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
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>
This commit is contained in:
committed by
Junio C Hamano
parent
c213820c51
commit
68a746e9a8
@@ -769,16 +769,15 @@ char *promisor_remote_reply(const char *info)
|
|||||||
|
|
||||||
void mark_promisor_remotes_as_accepted(struct repository *r, const char *remotes)
|
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++) {
|
string_list_split(&accepted_remotes, remotes, ";", -1);
|
||||||
struct promisor_remote *p;
|
|
||||||
char *decoded_remote;
|
|
||||||
|
|
||||||
strbuf_strip_suffix(accepted_remotes[i], ";");
|
for_each_string_list_item(item, &accepted_remotes) {
|
||||||
decoded_remote = url_percent_decode(accepted_remotes[i]->buf);
|
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)
|
if (p)
|
||||||
p->accepted = 1;
|
p->accepted = 1;
|
||||||
else
|
else
|
||||||
@@ -788,5 +787,5 @@ void mark_promisor_remotes_as_accepted(struct repository *r, const char *remotes
|
|||||||
free(decoded_remote);
|
free(decoded_remote);
|
||||||
}
|
}
|
||||||
|
|
||||||
strbuf_list_free(accepted_remotes);
|
string_list_clear(&accepted_remotes, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user