[PATCH] scripts: git-resolve: search beyond ten body-only matches
From: Hamdy Abou El Anein
Date: Tue Nov 03 2026 - 13:46:37 EST
From: Hamdy Abou El Anein <hamdy.aea@xxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxx>
---
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"