From fa34fedf2c1053082e8219fbb45e909a5a5c3a4d Mon Sep 17 00:00:00 2001 From: Jon Simons Date: Fri, 9 Oct 2026 15:29:52 -0400 Subject: [PATCH] remote: restructure apply_push_cas() loops Restructure the apply_push_cas() loops to prepare for replacing a linear remote_refs traversal with a strmap lookup. Before this change, apply_push_cas() loops: for each advertised remote ref, apply_cas(ref): for each explicit lease entry until first match, refname_match(entry, ref) else if use_tracking_for_rest, stamp from tracking After this change the loops are inverted and apply_cas() is split into apply_one_cas() (one explicit entry, stamp every matching still-free ref) and apply_cas_tracking() (shared by the explicit use_tracking path and use_tracking_for_rest): for each explicit lease entry, apply_one_cas(entry): for each advertised remote ref not yet stamped, refname_match(entry, ref) if use_tracking_for_rest, apply_cas_tracking() on remaining refs In the next commit, apply_one_cas() is updated to use a strmap. Signed-off-by: Jon Simons Signed-off-by: Junio C Hamano --- remote.c | 66 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/remote.c b/remote.c index 8074750601..8dd163038d 100644 --- a/remote.c +++ b/remote.c @@ -2978,33 +2978,10 @@ static void check_if_includes_upstream(struct ref *remote) free_one_ref(local); } -static void apply_cas(struct push_cas_option *cas, - struct remote *remote, - struct ref *ref) +static void apply_cas_tracking(struct push_cas_option *cas, + struct remote *remote, + struct ref *ref) { - int i; - - /* Find an explicit --