ACCEPT_ALL
};
+/*
+ * Check if a specific field and its advertised value match the local
+ * configuration of a given promisor remote.
+ *
+ * Returns 1 if they match, 0 otherwise.
+ */
static int match_field_against_config(const char *field, const char *value,
struct promisor_info *config_info)
{
return 0;
}
+/*
+ * Check that the advertised fields match the local configuration.
+ *
+ * When 'config_entry' is NULL (ACCEPT_ALL mode), every checked field
+ * must match at least one remote in 'config_info'.
+ *
+ * When 'config_entry' points to a specific remote's config, the
+ * checked fields are compared against that single remote only.
+ */
static int all_fields_match(struct promisor_info *advertised,
struct string_list *config_info,
- int in_list)
+ struct promisor_info *config_entry)
{
struct string_list *fields = fields_checked();
struct string_list_item *item_checked;
int match = 0;
const char *field = item_checked->string;
const char *value = NULL;
- struct string_list_item *item;
if (!strcasecmp(field, promisor_field_filter))
value = advertised->filter;
if (!value)
return 0;
- if (in_list) {
+ if (config_entry) {
+ match = match_field_against_config(field, value,
+ config_entry);
+ } else {
+ struct string_list_item *item;
for_each_string_list_item(item, config_info) {
struct promisor_info *p = item->util;
if (match_field_against_config(field, value, p)) {
break;
}
}
- } else {
- item = string_list_lookup(config_info, advertised->name);
- if (item) {
- struct promisor_info *p = item->util;
- match = match_field_against_config(field, value, p);
- }
}
if (!match)
const char *remote_url = advertised->url;
if (accept == ACCEPT_ALL)
- return all_fields_match(advertised, config_info, 1);
+ return all_fields_match(advertised, config_info, NULL);
/* Get config info for that promisor remote */
item = string_list_lookup(config_info, remote_name);
p = item->util;
if (accept == ACCEPT_KNOWN_NAME)
- return all_fields_match(advertised, config_info, 0);
+ return all_fields_match(advertised, config_info, p);
if (accept != ACCEPT_KNOWN_URL)
BUG("Unhandled 'enum accept_promisor' value '%d'", accept);
}
if (!strcmp(p->url, remote_url))
- return all_fields_match(advertised, config_info, 0);
+ return all_fields_match(advertised, config_info, p);
warning(_("known remote named '%s' but with URL '%s' instead of '%s'"),
remote_name, p->url, remote_url);