refactor: simplify ParseCatFileTreeLine and catBatchParseTreeEntries (#37210)

Simplify ParseCatFileTreeLine: it is faster without the preset buffers,
and easier to read and maintain.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: wxiaoguang <2114189+wxiaoguang@users.noreply.github.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Copilot
2026-04-14 12:03:26 +00:00
committed by GitHub
parent b55528b1a2
commit 84d5c99e64
6 changed files with 84 additions and 107 deletions

View File

@@ -66,9 +66,10 @@ func ParseEntryMode(mode string) EntryMode {
return EntryModeSymlink
case "160000":
return EntryModeCommit
case "040000":
case "040000", "40000": // leading-zero is optional
return EntryModeTree
default:
// if the faster path didn't work, try parsing the mode as an integer and masking off the file type bits
// git uses 040000 for tree object, but some users may get 040755 from non-standard git implementations
m, _ := strconv.ParseInt(mode, 8, 32)
modeInt := EntryMode(m)