Christian Couder <christian.couder@xxxxxxxxx> writes: > 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 <chriscool@xxxxxxxxxxxxx> > --- > promisor-remote.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) Makes the code much cleaner. Nice. > diff --git a/promisor-remote.c b/promisor-remote.c > index 501cb92391..2f86c68397 100644 > --- a/promisor-remote.c > +++ b/promisor-remote.c > @@ -314,6 +314,12 @@ static int allow_unsanitized(char ch) > return ch > 32 && ch < 127; > } > > +/* > + * All the fields used in "promisor-remote" protocol capability, > + * including the mandatory "name" and "url" ones. > + */ > +static const char promisor_field_name[] = "name"; > +static const char promisor_field_url[] = "url"; > static const char promisor_field_filter[] = "partialCloneFilter"; > static const char promisor_field_token[] = "token"; > > @@ -520,9 +526,9 @@ char *promisor_remote_info(struct repository *repo) > if (item != config_info.items) > strbuf_addch(&sb, ';'); > > - strbuf_addstr(&sb, "name="); > + strbuf_addf(&sb, "%s=", promisor_field_name); > strbuf_addstr_urlencode(&sb, p->name, allow_unsanitized); > - strbuf_addstr(&sb, ",url="); > + strbuf_addf(&sb, ",%s=", promisor_field_url); > strbuf_addstr_urlencode(&sb, p->url, allow_unsanitized); > > if (p->filter) { > @@ -663,9 +669,9 @@ static struct promisor_info *parse_one_advertised_remote(struct strbuf *remote_i > *p = '\0'; > value = url_percent_decode(p + 1); > > - if (!strcmp(elem, "name")) > + if (!strcmp(elem, promisor_field_name)) > info->name = value; > - else if (!strcmp(elem, "url")) > + else if (!strcmp(elem, promisor_field_url)) > info->url = value; > else if (!strcasecmp(elem, promisor_field_filter)) > info->filter = value;