diff options
| -rw-r--r-- | repository/algorithm.go | 2 | ||||
| -rw-r--r-- | repository/config.go | 2 | ||||
| -rw-r--r-- | repository/objects.go | 9 | ||||
| -rw-r--r-- | repository/open.go | 2 | ||||
| -rw-r--r-- | repository/repository.go | 5 | ||||
| -rw-r--r-- | repository/resolver.go | 2 |
6 files changed, 18 insertions, 4 deletions
diff --git a/repository/algorithm.go b/repository/algorithm.go index 90ce188c..1098f0b8 100644 --- a/repository/algorithm.go +++ b/repository/algorithm.go @@ -7,6 +7,8 @@ import ( objectid "codeberg.org/lindenii/furgit/object/id" ) +// detectObjectAlgorithm uses a repository's configuration to detect +// the expected Object ID hashing algorithm. func detectObjectAlgorithm(cfg *config.Config) (objectid.Algorithm, error) { algoName := cfg.Lookup("extensions", "", "objectformat").Value if algoName == "" { diff --git a/repository/config.go b/repository/config.go index de33e2c3..a6cf28e3 100644 --- a/repository/config.go +++ b/repository/config.go @@ -7,6 +7,8 @@ import ( "codeberg.org/lindenii/furgit/config" ) +// parseRepositoryConfig loads the configuration of the repository through +// finding the config file in the repo root, and parses the config. func parseRepositoryConfig(root *os.Root) (*config.Config, error) { configFile, err := root.Open("config") if err != nil { diff --git a/repository/objects.go b/repository/objects.go index 0aba751a..ec83f70b 100644 --- a/repository/objects.go +++ b/repository/objects.go @@ -12,6 +12,15 @@ import ( objectpacked "codeberg.org/lindenii/furgit/object/store/packed" ) +// openObjectStore opens the roots and object stores of both +// the loose and packed stores for a particular repo root and +// object ID hashing algorithm. +// +// Since real object store implementations do not take ownership of +// the roots given to them, and since composite object stores do not +// take ownership of the object stores that they consist of, all +// of them are returned and should be closed by the caller. +// //nolint:ireturn func openObjectStore( root *os.Root, diff --git a/repository/open.go b/repository/open.go index aba2c922..3c90df53 100644 --- a/repository/open.go +++ b/repository/open.go @@ -9,7 +9,7 @@ import ( // Open opens a repository and wires object/ref stores from its on-disk format. // -// Open borrows root during construction and does not close it. +// Open borrows root and does not close it. func Open(root *os.Root) (repo *Repository, err error) { repo = &Repository{} diff --git a/repository/repository.go b/repository/repository.go index 6b970c20..8c0322b7 100644 --- a/repository/repository.go +++ b/repository/repository.go @@ -1,4 +1,4 @@ -// Package repository wires object and ref storage for one Git repository. +// Package repository opens stores and other objects to access a typical on-disk repo. package repository import ( @@ -20,7 +20,8 @@ import ( // // Accessors such as Objects, Refs, Resolver, and LooseStoreForWriting return // views backed by resources owned by Repository. Those values borrow the -// repository's stores and filesystem roots and must not be used after Close. +// repository's stores and filesystem roots, must not be used after repositor yClose, +// and must not be closed manually. type Repository struct { config *config.Config algo objectid.Algorithm diff --git a/repository/resolver.go b/repository/resolver.go index f7717490..b40b060f 100644 --- a/repository/resolver.go +++ b/repository/resolver.go @@ -5,7 +5,7 @@ import "codeberg.org/lindenii/furgit/object/fetch" // Fetcher returns an object fetcher backed by the repository's object store. // // The returned fetcher is ready for use, borrows the repository's object -// store, does not need closing, and must not be used after Close. +// store, must not be closed directly, and must not be used after repository Close. func (repo *Repository) Fetcher() *fetch.Fetcher { return fetch.New(repo.objects) } |
