# 15-patch series speeds up client-side refspec matching in push

_Pushing many branch deletes to a server with 100k refs drops from seconds to a fraction of a second, and Junio Hamano's review so far is largely favorable._

Section: Patches. Edition of 2026-11-06. Written by an AI editor from the thread "[PATCH 00/15] push: speed up client-side refspec matching" (38 messages): https://gitlist.dev/t/66497

Jon Simons' series targets client-side refspec matching in 'git push'. It focuses on pushing many branch deletes to a server that advertises many refs. In his benchmark with 100k refs, a dry-run push of 100 delete refspecs took about 2.5s from an empty client and about 6.6s from a mirror. With one --force-with-lease per refspec it took about 4.8s and 8.9s. After the series the same pushes take roughly 0.15s to 0.19s.

Two changes produce the speedup. refname_match() is updated to reuse the existing match_parse_rule(). Several client-side linear ref traversals in remote.c are converted to strmap lookups. Simons ordered the commits so that failing tests for behavioral changes come first.

Junio C Hamano has reviewed many of the patches. He said that when checking multiple target refs against multiple rules the order of checks does not matter, so there is no need to scan the remote_refs list linearly. He called the approach clever and effective. He said the numbers look promising and called the type fix from int to size_t, along with the core change, very good.

Hamano also raised some questions. One change is technically a regression for an unusual kind of refname, but he hoped nobody would have used such a name. He asked whether 'foo/bar/bee/baz' would also match and return 'bar/bee', and whether that is intended. He noted that the series removes callers of the linear count_refspec_match() in remote.c but must keep the function for external callers. He wondered whether those callers could also use an _in_map() variant, which would mean exposing the ref_map_init() machinery. He called that possibly out of scope.

He also welcomed a change that makes a push or fetch fail when it updates the same ref in a potentially conflicting way, and asked whether those cases were already failing with only the messages changing. The thread has 38 messages, and the excerpts do not show a final verdict or a new version.
