diff options
author | Runxi Yu <me@runxiyu.org> | 2025-04-02 10:55:45 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-04-02 10:55:45 +0800 |
commit | 6c4e44e036c2e358e0d6ca37c41654bfc7efdcac (patch) | |
tree | e2db528da378176d3667ab9287b6fdf2e91bfb62 /git_plumbing.go | |
parent | Git: Fix command leak (need cmd.Wait()) (diff) | |
download | forge-6c4e44e036c2e358e0d6ca37c41654bfc7efdcac.tar.gz forge-6c4e44e036c2e358e0d6ca37c41654bfc7efdcac.tar.zst forge-6c4e44e036c2e358e0d6ca37c41654bfc7efdcac.zip |
Git: Simplify/lint
Diffstat (limited to 'git_plumbing.go')
-rw-r--r-- | git_plumbing.go | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/git_plumbing.go b/git_plumbing.go index 6adaf5a..c210027 100644 --- a/git_plumbing.go +++ b/git_plumbing.go @@ -26,18 +26,11 @@ func writeTree(ctx context.Context, repoPath string, entries []treeEntry) (strin } if strings.HasPrefix(nameJ, nameI) && len(nameI) < len(nameJ) { - if entries[i].mode == "40000" { - return false - } - return true + return !(entries[i].mode == "40000") } if strings.HasPrefix(nameI, nameJ) && len(nameJ) < len(nameI) { - // nameJ is a prefix of nameI - if entries[j].mode == "40000" { - return true - } - return false + return entries[j].mode == "40000" } return nameI < nameJ @@ -66,7 +59,7 @@ func writeTree(ctx context.Context, repoPath string, entries []treeEntry) (strin return strings.TrimSpace(out.String()), nil } -func buildTreeRecursive(ctx context.Context, repoPath string, baseTree string, updates map[string][]byte) (string, error) { +func buildTreeRecursive(ctx context.Context, repoPath, baseTree string, updates map[string][]byte) (string, error) { treeCache := make(map[string][]treeEntry) var walk func(string, string) error |