aboutsummaryrefslogtreecommitdiff
path: root/refstore/loose/store.go
blob: 4102ea0de35ffcfa8fccbcfa398a54fcb01de1b7 (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 read access to loose Git references.
package loose

import (
	"os"

	"codeberg.org/lindenii/furgit/objectid"
	"codeberg.org/lindenii/furgit/refstore"
)

// Store reads loose references from a repository root.
//
// Store does not own root. Callers are responsible for closing root.
type Store struct {
	// root is the repository root capability.
	root *os.Root
	// algo is the object ID algorithm used by this repository.
	algo objectid.Algorithm
}

var _ refstore.Store = (*Store)(nil)

// New creates a loose ref store rooted at a repository root.
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 {
	return nil
}