Use case-insensitive matching for Git error "Not a valid object name" in lstree
Summary
Git is changing the capitalization of its fatal: Not a valid object name error message to lowercase (fatal: not a valid object name) to follow Git's CodingGuidelines, which state that error messages should begin with a lowercase letter.
Mailing list discussion: https://lore.kernel.org/git/pull.2052.git.1771836302101.gitgitgadget@gmail.com
Affected code
File: internal/git/lstree/list_entries.go
The code currently uses:
strings.HasPrefix(errorMessage, "fatal: Not a valid object name")
After the Git change, the error message will use lowercase:
fatal: not a valid object name
Suggested fix
Use case-insensitive comparison:
strings.HasPrefix(strings.ToLower(errorMessage), "fatal: not a valid object name")
This will work with both the current and future Git versions.
Impact
Without this fix, Gitaly will fail to properly detect "not a valid object name" errors from newer versions of Git when listing tree entries, potentially causing incorrect error handling.