Skip to content

Commit a348195

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 2d2ef70 commit a348195

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

@@ -510,9 +516,9 @@ char *promisor_remote_info(struct repository *repo)
510516
if (p != config_info)
511517
strbuf_addch(&sb, ';');
512518

513-
strbuf_addstr(&sb, "name=");
519+
strbuf_addf(&sb, "%s=", promisor_field_name);
514520
strbuf_addstr_urlencode(&sb, p->name, allow_unsanitized);
515-
strbuf_addstr(&sb, ",url=");
521+
strbuf_addf(&sb, ",%s=", promisor_field_url);
516522
strbuf_addstr_urlencode(&sb, p->url, allow_unsanitized);
517523

518524
if (p->filter) {
@@ -661,9 +667,9 @@ static struct promisor_info *parse_one_advertised_remote(struct strbuf *remote_i
661667
*p = '\0';
662668
value = url_percent_decode(p + 1);
663669

664-
if (!strcmp(elem, "name"))
670+
if (!strcmp(elem, promisor_field_name))
665671
info->name = value;
666-
else if (!strcmp(elem, "url"))
672+
else if (!strcmp(elem, promisor_field_url))
667673
info->url = value;
668674
else if (!strcasecmp(elem, promisor_field_filter))
669675
info->filter = value;

0 commit comments

Comments
 (0)