Skip to content

Commit 6bf1996

Browse files
chriscoolgitster
authored andcommitted
promisor-remote: use string constants for 'name' and 'url' too
A previous commit started to define `promisor_field_filter` and `promisor_field_token`, and used them instead of the "partialCloneFilter" and "token" string literals. Let's do the same for "name" and "url" to avoid repeating them several times and for consistency with the other fields. Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 14ff980 commit 6bf1996

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

promisor-remote.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,12 @@ static int allow_unsanitized(char ch)
314314
return ch > 32 && ch < 127;
315315
}
316316

317+
/*
318+
* All the fields used in "promisor-remote" protocol capability,
319+
* including the mandatory "name" and "url" ones.
320+
*/
321+
static const char promisor_field_name[] = "name";
322+
static const char promisor_field_url[] = "url";
317323
static const char promisor_field_filter[] = "partialCloneFilter";
318324
static const char promisor_field_token[] = "token";
319325

@@ -520,9 +526,9 @@ char *promisor_remote_info(struct repository *repo)
520526
if (item != config_info.items)
521527
strbuf_addch(&sb, ';');
522528

523-
strbuf_addstr(&sb, "name=");
529+
strbuf_addf(&sb, "%s=", promisor_field_name);
524530
strbuf_addstr_urlencode(&sb, p->name, allow_unsanitized);
525-
strbuf_addstr(&sb, ",url=");
531+
strbuf_addf(&sb, ",%s=", promisor_field_url);
526532
strbuf_addstr_urlencode(&sb, p->url, allow_unsanitized);
527533

528534
if (p->filter) {
@@ -664,9 +670,9 @@ static struct promisor_info *parse_one_advertised_remote(struct strbuf *remote_i
664670
*p = '\0';
665671
value = url_percent_decode(p + 1);
666672

667-
if (!strcmp(elem, "name"))
673+
if (!strcmp(elem, promisor_field_name))
668674
info->name = value;
669-
else if (!strcmp(elem, "url"))
675+
else if (!strcmp(elem, promisor_field_url))
670676
info->url = value;
671677
else if (!strcmp(elem, promisor_field_filter))
672678
info->filter = value;

0 commit comments

Comments
 (0)