]> git.ipfire.org Git - thirdparty/git.git/commit
promisor-remote: pass config entry to all_fields_match() directly
authorChristian Couder <christian.couder@gmail.com>
Tue, 7 Apr 2026 11:52:35 +0000 (13:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 Apr 2026 15:45:43 +0000 (08:45 -0700)
commit720b7c26c82ef212852897bedb0d38eee78cb531
tree650379dcf3b8e70acc505dfda0ced1d120655361
parent8808e61fd3e953c3534633b8b5adc5b243dd696f
promisor-remote: pass config entry to all_fields_match() directly

The `in_list == 0` path of all_fields_match() looks up the remote in
`config_info` by `advertised->name` repeatedly, even though every
caller in should_accept_remote() has already performed this
lookup and holds the result in `p`.

To avoid this useless work, let's replace the `int in_list`
parameter with a `struct promisor_info *config_entry` pointer:

 - When NULL (ACCEPT_ALL mode): scan the whole `config_info` list, as
   the old `in_list == 1` path did.

 - When non-NULL: match against that single config entry directly,
   avoiding the redundant string_list_lookup() call.

This removes the hidden dependency on `advertised->name` inside
all_fields_match(), which would be wrong if in the future
auto-configured remotes are implemented, as the local config name may
differ from the server's advertised name.

While at it, let's also add a comment before all_fields_match() and
match_field_against_config() to help understand how things work and
help avoid similar issues.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
promisor-remote.c