* [PATCH] scripts: git-resolve: search beyond ten body-only matches
@ 2026-11-03 16:42 Hamdy Abou El Anein
2026-11-03 17:26 ` Sasha Levin
0 siblings, 1 reply; 2+ messages in thread
From: Hamdy Abou El Anein @ 2026-11-03 16:42 UTC (permalink / raw)
To: sashal; +Cc: hamdy.aea, linux-kernel
From: Hamdy Abou El Anein <hamdy.aea@protonmail.com>
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.
Tested with a target commit followed by eleven commits whose bodies,
but not subjects, match the query. Forced lookup now returns the target.
AI assistance: ChatGPT/Codex identified the issue and prepared the
change, commit message and executable regression tests.
Fixes: 7ae52a3d7f51 ("scripts: Add git-resolve tool for full SHA-1 resolution")
Signed-off-by: Hamdy Abou El Anein <hamdy.aea@protonmail.com>
---
scripts/git-resolve.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/git-resolve.sh b/scripts/git-resolve.sh
index 0be8838cd13..4b51d40bebf 100755
--- a/scripts/git-resolve.sh
+++ b/scripts/git-resolve.sh
@@ -74,7 +74,7 @@ git_resolve_commit() {
if [ ${#matches[@]} -eq 0 ] && [ $force -eq 1 ]; then
# Use git log to search, but filter to ensure subject matches exactly
local match
- match=$(git log --format="%H %s" --grep="$grep_pattern" --perl-regexp -10 | \
+ match=$(git log --format="%H %s" --grep="$grep_pattern" --perl-regexp | \
while read -r hash subject; do
if echo "$subject" | grep -qP "$grep_pattern"; then
echo "$hash"
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] scripts: git-resolve: search beyond ten body-only matches
2026-11-03 16:42 [PATCH] scripts: git-resolve: search beyond ten body-only matches Hamdy Abou El Anein
@ 2026-11-03 17:26 ` Sasha Levin
0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2026-11-03 17:26 UTC (permalink / raw)
To: Hamdy Abou El Anein; +Cc: Hamdy Abou El Anein, linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-03 17:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 16:42 [PATCH] scripts: git-resolve: search beyond ten body-only matches Hamdy Abou El Anein
2026-11-03 17:26 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®