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)
| 46 | // |
| 47 | // See: https://git-scm.com/docs/commit-graph |
| 48 | func 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. |
nothing calls this directly
no test coverage detected