MCPcopy Create free account
hub / github.com/go-git/go-git / OpenChainOrFileIndex

Function OpenChainOrFileIndex

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

OpenChainOrFileIndex expects a billy.Filesystem representing a .git directory. It will first attempt to read a commit-graph index file, before trying to read a commit-graph chain file and its index files. If neither are present, an error is returned. Otherwise an Index will be returned. See: https:

(fs billy.Filesystem)

Source from the content-addressed store, hash-verified

46//
47// See: https://git-scm.com/docs/commit-graph
48func OpenChainOrFileIndex(fs billy.Filesystem) (Index, error) {
49 file, err := fs.Open(path.Join("objects", "info", "commit-graph"))
50 if err != nil {
51 // try to open a chain file
52 return OpenChainIndex(fs)
53 }
54
55 index, err := OpenFileIndex(file)
56 if err != nil {
57 // Ignore any file closing errors and return the error from OpenFileIndex instead
58 _ = file.Close()
59 return nil, err
60 }
61 return index, nil
62}
63
64// OpenChainIndex expects a billy.Filesystem representing a .git directory.
65// It will read a commit-graph chain file and return a coalesced index.

Callers

nothing calls this directly

Calls 5

OpenChainIndexFunction · 0.85
JoinMethod · 0.80
OpenFileIndexFunction · 0.70
CloseMethod · 0.65
OpenMethod · 0.45

Tested by

no test coverage detected