shithub: furgit

Download patch

ref: f50ac551c56569e109a8350f27dab53bb2378d4d
parent: 5b0b1441ea90d08985ec48cd8f15fc4ff1f2cd92
author: Runxi Yu <runxiyu@umich.edu>
date: Sun Mar 29 11:43:50 EDT 2026

*: Remove Close from object/ref store interfaces

At places where you own the object, you should have the literal
implementation with Close. If you're using it via the interface, then
you probably don't own that store, and you shouldn't be closing it.

Thanks to Michael Muré from git-bug for this point.

--- a/TODO
+++ b/TODO
@@ -60,6 +60,3 @@
   try to resolve that probably
 * Needs much better diff API
 * revwalk/log
-
-
-* Does Close belong in interfaces at all?
--- a/network/receivepack/service/run_hook.go
+++ b/network/receivepack/service/run_hook.go
@@ -96,10 +96,6 @@
 		}
 
 		defer func() {
-			if quarantineObjectsStore != nil {
-				_ = quarantineObjectsStore.Close()
-			}
-
 			if quarantinePackedStore != nil {
 				_ = quarantinePackedStore.Close()
 			}
--- a/object/store/reading.go
+++ b/object/store/reading.go
@@ -52,9 +52,4 @@
 	//
 	// Backends without dynamic discovery should do nothing and return nil.
 	Refresh() error
-
-	// Close releases resources associated with the backend.
-	//
-	// Labels: MT-Unsafe.
-	Close() error
 }
--- a/ref/store/reading.go
+++ b/ref/store/reading.go
@@ -31,10 +31,4 @@
 	//
 	// Labels: Life-Parent.
 	List(pattern string) ([]ref.Ref, error)
-	// Close releases resources associated with the store.
-	//
-	// Transactions and batches borrowing the store are invalid after Close.
-	//
-	// Labels: MT-Unsafe.
-	Close() error
 }
--- a/repository/close.go
+++ b/repository/close.go
@@ -8,20 +8,6 @@
 func (repo *Repository) Close() error {
 	var errs []error
 
-	if repo.refs != nil {
-		err := repo.refs.Close()
-		if err != nil {
-			errs = append(errs, err)
-		}
-	}
-
-	if repo.objects != nil {
-		err := repo.objects.Close()
-		if err != nil {
-			errs = append(errs, err)
-		}
-	}
-
 	if repo.commitGraph != nil {
 		err := repo.commitGraph.Close()
 		if err != nil {
--- a/repository/objects.go
+++ b/repository/objects.go
@@ -81,7 +81,7 @@
 // bytes, or streamed object contents. Callers who want typed object values
 // should usually prefer [Repository.Fetcher].
 //
-// Labels: Life-Parent, Close-No.
+// Labels: Life-Parent.
 //
 //nolint:ireturn
 func (repo *Repository) Objects() objectstore.ReadingStore {
--- a/repository/refs.go
+++ b/repository/refs.go
@@ -8,7 +8,7 @@
 // A common pattern is to resolve a reference first and then pass the resulting
 // object ID to [Repository.Fetcher] or [Repository.Objects].
 //
-// Labels: Life-Parent, Close-No.
+// Labels: Life-Parent.
 //
 //nolint:ireturn
 func (repo *Repository) Refs() refstore.ReadWriteStore {
--