MCPcopy
hub / github.com/go-git/go-git / getFileHashes

Function getFileHashes

_examples/ls/main.go:132–155  ·  view source on GitHub ↗
(c commitgraph.CommitNode, treePath string, paths []string)

Source from the content-addressed store, hash-verified

130}
131
132func getFileHashes(c commitgraph.CommitNode, treePath string, paths []string) (map[string]plumbing.Hash, error) {
133 tree, err := getCommitTree(c, treePath)
134 if err == object.ErrDirectoryNotFound {
135 // The whole tree didn't exist, so return empty map
136 return make(map[string]plumbing.Hash), nil
137 }
138 if err != nil {
139 return nil, err
140 }
141
142 hashes := make(map[string]plumbing.Hash)
143 for _, path := range paths {
144 if path != "" {
145 entry, err := tree.FindEntry(path)
146 if err == nil {
147 hashes[path] = entry.Hash
148 }
149 } else {
150 hashes[path] = tree.Hash
151 }
152 }
153
154 return hashes, nil
155}
156
157func getLastCommitForPaths(c commitgraph.CommitNode, treePath string, paths []string) (map[string]*object.Commit, error) {
158 // We do a tree traversal with nodes sorted by commit time

Callers 1

getLastCommitForPathsFunction · 0.85

Calls 2

getCommitTreeFunction · 0.85
FindEntryMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…