Re: [PATCH] scripts: git-resolve: search beyond ten body-only matches

From: Sasha Levin

Date: Tue Nov 03 2026 - 12:33:01 EST


On Tue, Nov 03, 2026 at 05:42:02PM +0100, Hamdy Abou El Anein wrote:
>The forced subject lookup asks git log for at most ten matches before
>checking their subjects. Since --grep also searches message bodies, ten
>newer body-only matches can hide an older commit with the requested
>subject.
>
>Remove the premature limit. The existing reader still stops at the
>first matching subject.

The fix is correct, but without the limit a broad wildcard that matches many
bodies and no subject gets slow. In linux.git, --force 999999999
'("...Tested-by...")' went from returning immediately to over a minute, since
the loop runs grep once for each of the 78000 commits whose message matches.

Matching the subject directly avoids body matches altogether:

match=$(git log --format="%H %s" | grep -m1 -P "^[0-9a-f]+ ${grep_pattern#^}" | cut -d" " -f1)

No limit is needed then. It gives the same results on the selftest and on your
eleven commit case, finds an existing subject in 0.1s instead of 10s, and takes
12s for the wildcard above. It also resolves subjects with leading whitespace
or that span several lines, which the read loop misses today.

Could you send a v2 that does this instead?

--
Thanks,
Sasha