blob: b06d8a78faaa851467538b71fe6befcd19cf4bd5 (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// Package loose provides loose-object reads from a Git objects directory.
package loose
import (
"os"
"codeberg.org/lindenii/furgit/objectid"
)
// Store reads loose Git objects from an objects directory root.
//
// Store does not own root. Callers are responsible for closing root.
type Store struct {
// root is the objects directory capability used for all object file access.
// Object files are opened by relative paths like "<first2>/<rest>".
// Store does not own this root.
root *os.Root
// algo is the expected object ID algorithm for lookups.
algo objectid.Algorithm
}
// New creates a loose-object store rooted at an objects directory for algo.
func New(root *os.Root, algo objectid.Algorithm) (*Store, error) {
if algo.Size() == 0 {
return nil, objectid.ErrInvalidAlgorithm
}
return &Store{
root: root,
algo: algo,
}, nil
}
// Close releases resources associated with the backend.
func (store *Store) Close() error {
_ = store
return nil
}
|