shithub: furgit

Download patch

ref: 07eba7b54d3836e76996c0b06714b6e505bead5e
parent: a4eeb727468a178a4de0dfc718828f26740484ac
author: Runxi Yu <runxiyu@umich.edu>
date: Mon Mar 30 11:19:18 EDT 2026

object/store: Expose pack writing options

--- a/object/store/packed/options.go
+++ b/object/store/packed/options.go
@@ -3,4 +3,5 @@
 // Options configures a packed object store.
 type Options struct {
 	RefreshPolicy RefreshPolicy
+	WriteRev      bool
 }
--- a/object/store/packed/writer.go
+++ b/object/store/packed/writer.go
@@ -10,8 +10,13 @@
 var _ objectstore.PackWriter = (*Store)(nil)
 
 // WritePack ingests one pack stream into the packed store.
-func (store *Store) WritePack(src io.Reader, _ objectstore.PackWriteOptions) error {
-	_, err := ingest.WritePack(store.root, store.algo, src, ingest.Options{})
+func (store *Store) WritePack(src io.Reader, opts objectstore.PackWriteOptions) error {
+	_, err := ingest.WritePack(store.root, store.algo, src, ingest.Options{
+		WriteRev:           store.opts.WriteRev,
+		Base:               opts.ThinBase,
+		Progress:           opts.Progress,
+		RequireTrailingEOF: opts.RequireTrailingEOF,
+	})
 
 	return err
 }
--- a/object/store/writer_pack.go
+++ b/object/store/writer_pack.go
@@ -1,9 +1,41 @@
 package objectstore
 
-import "io"
+import (
+	"io"
 
+	"codeberg.org/lindenii/furgit/common/iowrap"
+)
+
 // PackWriteOptions controls one pack write operation.
-type PackWriteOptions struct{}
+type PackWriteOptions struct {
+	// ThinBase supplies the wider object reader used to complete thin packs
+	// during ingestion.
+	//
+	// This is an option for the write operation rather than on a particular
+	// pack-backed store because any pack-accepting store is not generally
+	// expected to know the entire repository object universe around it.
+	// In a normal repository, thin bases usually come from a broader view
+	// such as mix(loose, packed), and should not be treated as a property of
+	// the destination pack-accepting store. Thus, in almost all pack-ingesting
+	// operations, a thin base reader would be required, and hence it is
+	// included here.
+	//
+	// When nil, external thin-base repair is disabled and unresolved thin deltas
+	// fail ingestion.
+	ThinBase Reader
+
+	// Progress receives human-readable progress messages.
+	//
+	// When nil, no progress output is emitted.
+	Progress iowrap.WriteFlusher
+
+	// RequireTrailingEOF requires the source to hit EOF after the pack trailer.
+	//
+	// This is suitable for exact pack-file readers, but should be disabled for
+	// full-duplex transport streams like receive-pack where the peer keeps the
+	// connection open to read the server response.
+	RequireTrailingEOF bool
+}
 
 // PackWriter writes Git pack streams.
 type PackWriter interface {
--