MCPcopy Index your code
hub / github.com/go-git/go-git / OpenChainIndex

Function OpenChainIndex

plumbing/format/commitgraph/v2/chain.go:69–100  ·  view source on GitHub ↗

OpenChainIndex expects a billy.Filesystem representing a .git directory. It will read a commit-graph chain file and return a coalesced index. If the chain file or a graph in that chain is not present, an error is returned. See: https://git-scm.com/docs/commit-graph

(fs billy.Filesystem)

Source from the content-addressed store, hash-verified

67//
68// See: https://git-scm.com/docs/commit-graph
69func OpenChainIndex(fs billy.Filesystem) (Index, error) {
70 chainFile, err := fs.Open(path.Join("objects", "info", "commit-graphs", "commit-graph-chain"))
71 if err != nil {
72 return nil, err
73 }
74
75 chain, err := OpenChainFile(chainFile)
76 _ = chainFile.Close()
77 if err != nil {
78 return nil, err
79 }
80
81 var index Index
82 for _, hash := range chain {
83
84 file, err := fs.Open(path.Join("objects", "info", "commit-graphs", "graph-"+hash+".graph"))
85 if err != nil {
86 // Ignore all other file closing errors and return the error from opening the last file in the graph
87 _ = index.Close()
88 return nil, err
89 }
90
91 index, err = OpenFileIndexWithParent(file, index)
92 if err != nil {
93 // Ignore file closing errors and return the error from OpenFileIndex instead
94 _ = index.Close()
95 return nil, err
96 }
97 }
98
99 return index, nil
100}

Callers 1

OpenChainOrFileIndexFunction · 0.85

Calls 5

OpenChainFileFunction · 0.85
OpenFileIndexWithParentFunction · 0.85
JoinMethod · 0.80
CloseMethod · 0.65
OpenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…