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

Function NewRootNodeWithOptions

utils/merkletrie/filesystem/node.go:72–93  ·  view source on GitHub ↗

NewRootNodeWithOptions returns the root node based on a given billy.Filesystem with options to set an index. Providing an index enables the metadata-first comparison optimization while correctly handling the "racy git" condition. If no index is provided, the function works without the optimization.

(
	fs billy.Filesystem,
	submodules map[string]plumbing.Hash,
	options Options,
)

Source from the content-addressed store, hash-verified

70//
71// Reference: https://git-scm.com/docs/racy-git
72func NewRootNodeWithOptions(
73 fs billy.Filesystem,
74 submodules map[string]plumbing.Hash,
75 options Options,
76) noder.Noder {
77 var idxMap map[string]*index.Entry
78
79 if options.Index != nil {
80 idxMap = make(map[string]*index.Entry, len(options.Index.Entries))
81 for _, entry := range options.Index.Entries {
82 idxMap[entry.Name] = entry
83 }
84 }
85
86 return &node{
87 fs: fs,
88 submodules: submodules,
89 idx: options.Index,
90 idxMap: idxMap,
91 isDir: true,
92 }
93}
94
95// Hash the hash of a filesystem is the result of concatenating the computed
96// plumbing.Hash of the file as a Blob and its plumbing.FileMode; that way the

Callers 4

NewRootNodeFunction · 0.85
TestRacyGitMethod · 0.85
TestZeroIndexModTimeMethod · 0.85

Calls

no outgoing calls

Tested by 2

TestRacyGitMethod · 0.68
TestZeroIndexModTimeMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…