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, )
| 70 | // |
| 71 | // Reference: https://git-scm.com/docs/racy-git |
| 72 | func 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 |
no outgoing calls
searching dependent graphs…