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

Method BuildTree

worktree_commit.go:206–218  ·  view source on GitHub ↗

BuildTree builds the tree objects and push its to the storer, the hash of the root tree is returned.

(idx *index.Index, opts *CommitOptions)

Source from the content-addressed store, hash-verified

204// BuildTree builds the tree objects and push its to the storer, the hash
205// of the root tree is returned.
206func (h *buildTreeHelper) BuildTree(idx *index.Index, opts *CommitOptions) (plumbing.Hash, error) {
207 const rootNode = ""
208 h.trees = map[string]*object.Tree{rootNode: {}}
209 h.entries = map[string]*object.TreeEntry{}
210
211 for _, e := range idx.Entries {
212 if err := h.commitIndexEntry(e); err != nil {
213 return plumbing.ZeroHash, err
214 }
215 }
216
217 return h.copyTreeToStorageRecursive(rootNode, h.trees[rootNode])
218}
219
220func (h *buildTreeHelper) commitIndexEntry(e *index.Entry) error {
221 parts := strings.Split(e.Name, "/")

Callers 1

CommitMethod · 0.95

Calls 2

commitIndexEntryMethod · 0.95

Tested by

no test coverage detected