aboutsummaryrefslogtreecommitdiff
path: root/repository
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-28 14:25:31 +0000
committerGravatar Runxi Yu2026-03-28 14:25:31 +0000
commit3dc0eefa251989eb45bf647f83ec19369660b76b (patch)
tree001457ab5e50262d98126c80f0dfc51429a949eb /repository
parentfurgit: Document contract labels (diff)
signatureNo signature
repository: Use labels v0.1.120
Diffstat (limited to 'repository')
-rw-r--r--repository/close.go5
-rw-r--r--repository/objects.go4
-rw-r--r--repository/open.go2
-rw-r--r--repository/refs.go4
-rw-r--r--repository/repository.go11
-rw-r--r--repository/resolver.go3
-rw-r--r--repository/write_loose.go4
7 files changed, 14 insertions, 19 deletions
diff --git a/repository/close.go b/repository/close.go
index b76570bb..fa6f8f85 100644
--- a/repository/close.go
+++ b/repository/close.go
@@ -2,8 +2,9 @@ package repository
import "errors"
-// Close closes owned stores and filesystem roots.
-// The behavior of the repo after Close is undefined.
+// Close closes repository-owned stores and filesystem roots.
+//
+// Labels: MT-Unsafe.
func (repo *Repository) Close() error {
var errs []error
diff --git a/repository/objects.go b/repository/objects.go
index ec83f70b..ea1956c1 100644
--- a/repository/objects.go
+++ b/repository/objects.go
@@ -77,9 +77,7 @@ func openObjectStore(
// Objects returns the configured object store.
//
-// The returned store is owned by Repository and borrows repository-managed
-// resources. Callers must not close it directly, and it must not be used after
-// Close.
+// Labels: Life-Parent, Close-No.
//
//nolint:ireturn
func (repo *Repository) Objects() objectstore.ReadingStore {
diff --git a/repository/open.go b/repository/open.go
index 3c90df53..0e47ba83 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 and does not close it.
+// Labels: Deps-Borrowed.
func Open(root *os.Root) (repo *Repository, err error) {
repo = &Repository{}
diff --git a/repository/refs.go b/repository/refs.go
index 5c085ef9..2e89aed6 100644
--- a/repository/refs.go
+++ b/repository/refs.go
@@ -4,9 +4,7 @@ import refstore "codeberg.org/lindenii/furgit/ref/store"
// Refs returns the configured ref store.
//
-// The returned store is owned by Repository and borrows repository-managed
-// resources. Callers must not close it directly, and it must not be used after
-// Close.
+// Labels: Life-Parent, Close-No.
//
//nolint:ireturn
func (repo *Repository) Refs() refstore.ReadWriteStore {
diff --git a/repository/repository.go b/repository/repository.go
index 8c0322b7..8c7c091f 100644
--- a/repository/repository.go
+++ b/repository/repository.go
@@ -13,15 +13,16 @@ import (
)
// Repository represents a typical on-disk Git repository by composing
-// their stores together for access.
+// its stores together for access.
//
// Open expects a root for the Git directory itself:
// a bare repository root or a non-bare ".git" directory.
//
-// 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, must not be used after repositor yClose,
-// and must not be closed manually.
+// Accessors such as [Repository.Objects], [Repository.Refs],
+// [Repository.Fetcher], and [Repository.LooseStoreForWriting] return
+// repository-backed views.
+//
+// Labels: MT-Safe, Close-Caller.
type Repository struct {
config *config.Config
algo objectid.Algorithm
diff --git a/repository/resolver.go b/repository/resolver.go
index b40b060f..6701b806 100644
--- a/repository/resolver.go
+++ b/repository/resolver.go
@@ -4,8 +4,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, must not be closed directly, and must not be used after repository Close.
+// Labels: Life-Parent, Close-No.
func (repo *Repository) Fetcher() *fetch.Fetcher {
return fetch.New(repo.objects)
}
diff --git a/repository/write_loose.go b/repository/write_loose.go
index 9bd05912..eeade86f 100644
--- a/repository/write_loose.go
+++ b/repository/write_loose.go
@@ -6,9 +6,7 @@ import (
// LooseStoreForWriting returns the repository's loose-object writer.
//
-// The returned store is owned by Repository and borrows repository-managed
-// resources. Callers must not close it directly, and it must not be used after
-// Close.
+// Labels: Life-Parent, Close-No.
func (repo *Repository) LooseStoreForWriting() *objectloose.Store {
return repo.objectsLoose
}