promisor-remote: add 'local_name' to 'struct promisor_info'

In a following commit, we will store promisor remote information under a remote name different than the one the server advertised. To prepare for this change, let's add a new 'char *local_name' member to 'struct promisor_info', and let's update the related functions. While at it, let's also add a small promisor_info_local_name() helper that returns `local_name` when set, `name` otherwise, and let's use this small helper in promisor_store_advertised_fields() and in the post-loop of filter_promisor_remote() so that lookups against the local repo configuration use the right name. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed May 27, 2026 at 16:08 UTC 53951298515ad26728175182c9103eea71885220
1 file changed +15 -7
promisor-remote.c
+15 -7
@@ -434,13 +434,14 @@ static struct string_list *fields_stored(void)
434 * Struct for promisor remotes involved in the "promisor-remote"
435 * protocol capability.
436 *
437 - * Except for "name", each <member> in this struct and its <value>
438 - * should correspond (either on the client side or on the server side)
439 - * to a "remote.<name>.<member>" config variable set to <value> where
440 - * "<name>" is a promisor remote name.
437 + * Except for "name" and "local_name", each <member> in this struct
438 + * and its <value> should correspond (either on the client side or on
439 + * the server side) to a "remote.<name>.<member>" config variable set
440 + * to <value> where "<name>" is a promisor remote name.
441 */
442 struct promisor_info {
443 - const char *name;
443 + const char *name; /* name the server advertised */
444 + const char *local_name; /* name used locally (may be auto-generated) */
445 const char *url;
446 const char *filter;
447 const char *token;
@@ -449,6 +450,7 @@ struct promisor_info {
450 static void promisor_info_free(struct promisor_info *p)
451 {
452 free((char *)p->name);
453 + free((char *)p->local_name);
454 free((char *)p->url);
455 free((char *)p->filter);
456 free((char *)p->token);
@@ -462,6 +464,11 @@ static void promisor_info_list_clear(struct string_list *list)
464 string_list_clear(list, 0);
465 }
466
467 +static const char *promisor_info_local_name(struct promisor_info *p)
468 +{
469 + return p->local_name ? p->local_name : p->name;
470 +}
471 +
472 static void set_one_field(struct promisor_info *p,
473 const char *field, const char *value)
474 {
@@ -829,7 +836,7 @@ static bool promisor_store_advertised_fields(struct promisor_info *advertised,
836 {
837 struct promisor_info *p;
838 struct string_list_item *item;
832 - const char *remote_name = advertised->name;
839 + const char *remote_name = promisor_info_local_name(advertised);
840 bool reload_config = false;
841
842 if (!(store_info->store_filter || store_info->store_token))
@@ -937,7 +944,8 @@ static void filter_promisor_remote(struct repository *repo,
944 /* Apply accepted remotes to the stable repo state */
945 for_each_string_list_item(item, accepted_remotes) {
946 struct promisor_info *info = item->util;
940 - struct promisor_remote *r = repo_promisor_remote_find(repo, info->name);
947 + const char *remote_name = promisor_info_local_name(info);
948 + struct promisor_remote *r = repo_promisor_remote_find(repo, remote_name);
949
950 if (r) {
951 r->accepted = 1;