aboutsummaryrefslogtreecommitdiff
path: root/refstore
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-22 22:07:39 +0000
committerGravatar Runxi Yu2026-03-22 22:07:39 +0000
commit7ddaf1eb2fde11a9e07df0215646c1dca08ccc50 (patch)
treeec1096bd8229fa0a3c3272e2a52e60bff0d73797 /refstore
parentobjectstore/loose, receivepack/service, repository: Lint whitespace (diff)
signatureNo signature
refstore, repository: Ownership/lifetimes fix v0.1.87
Diffstat (limited to 'refstore')
-rw-r--r--refstore/batch.go4
-rw-r--r--refstore/files/close.go13
-rw-r--r--refstore/files/store.go3
-rw-r--r--refstore/reading.go3
-rw-r--r--refstore/transaction.go4
5 files changed, 18 insertions, 9 deletions
diff --git a/refstore/batch.go b/refstore/batch.go
index 6352159c..b170916b 100644
--- a/refstore/batch.go
+++ b/refstore/batch.go
@@ -34,8 +34,12 @@ type Batch interface {
// Apply validates and applies queued operations, returning one result per
// queued operation in order. Fatal backend failures are returned separately.
+ //
+ // Apply is terminal. Further use of the batch is undefined behavior.
Apply() ([]BatchResult, error)
// Abort abandons the batch and releases any resources it holds.
+ //
+ // Abort is terminal. Further use of the batch is undefined behavior.
Abort() error
}
diff --git a/refstore/files/close.go b/refstore/files/close.go
index 37dde9b9..6dfe3668 100644
--- a/refstore/files/close.go
+++ b/refstore/files/close.go
@@ -1,13 +1,10 @@
package files
// Close releases resources associated with the store.
+//
+// Store borrows gitRoot, so Close does not close it.
+//
+// Repeated calls to Close are undefined behavior.
func (store *Store) Close() error {
- err := store.gitRoot.Close()
- commonErr := store.commonRoot.Close()
-
- if err != nil {
- return err
- }
-
- return commonErr
+ return store.commonRoot.Close()
}
diff --git a/refstore/files/store.go b/refstore/files/store.go
index 6091c000..378c0af0 100644
--- a/refstore/files/store.go
+++ b/refstore/files/store.go
@@ -14,7 +14,8 @@ import (
// Store reads and writes one Git files ref namespace rooted at one repository
// gitdir plus its commondir.
//
-// Store owns both roots and closes them in Close.
+// Store borrows gitRoot and owns commonRoot. Close releases only resources
+// opened by the store itself.
type Store struct {
gitRoot *os.Root
commonRoot *os.Root
diff --git a/refstore/reading.go b/refstore/reading.go
index c302f350..98a5bd51 100644
--- a/refstore/reading.go
+++ b/refstore/reading.go
@@ -25,5 +25,8 @@ type ReadingStore interface {
// The exact pattern language is backend-defined.
List(pattern string) ([]ref.Ref, error)
// Close releases resources associated with the store.
+ //
+ // Repeated calls to Close are undefined behavior unless the implementation
+ // explicitly documents otherwise.
Close() error
}
diff --git a/refstore/transaction.go b/refstore/transaction.go
index 539229c9..fc0a8d76 100644
--- a/refstore/transaction.go
+++ b/refstore/transaction.go
@@ -37,7 +37,11 @@ type Transaction interface {
VerifySymbolic(name, oldTarget string) error
// Commit validates and applies all queued operations atomically.
+ //
+ // Commit is terminal. Further use of the transaction is undefined behavior.
Commit() error
// Abort abandons the transaction and releases any resources it holds.
+ //
+ // Abort is terminal. Further use of the transaction is undefined behavior.
Abort() error
}