ref: 06b3648782c860ac0bc096e30e72587d5016e4e4
parent: f762271dbfc121eaac7eb59c0beb01620a09118f
author: Runxi Yu <me@runxiyu.org>
date: Fri Jan 30 12:15:49 EST 2026
packed: Factor out packWriteObjects and clean up
--- a/packed_write_pack.go
+++ b/packed_write_pack.go
@@ -3,7 +3,6 @@
import (
"crypto/rand"
"encoding/binary"
- "errors"
"hash"
"io"
@@ -10,9 +9,6 @@
"codeberg.org/lindenii/furgit/internal/zlib"
)
-// TODO
-var errThinPackUnimplemented = errors.New("furgit: pack: thin packs not implemented")-
// packWriter writes a PACKv2 stream.
type packWriter struct {w io.Writer
@@ -281,14 +277,6 @@
return out[:pos], nil
}
-// packWrite writes a pack stream for the provided object ids.
-func (repo *Repository) packWrite(w io.Writer, objects []Hash, opts packWriteOptions) (Hash, error) {- if opts.EnableThinPack {- return Hash{}, errThinPackUnimplemented- }
- return repo.packWriteObjects(w, objects, opts, nil)
-}
-
// packWriteReachable writes a pack stream for objects reachable from the
// provided reachability query.
func (repo *Repository) packWriteReachable(w io.Writer, query ReachabilityQuery, opts packWriteOptions) (Hash, error) {@@ -307,10 +295,11 @@
if err := walk.Err(); err != nil { return Hash{}, err}
- return repo.packWriteObjects(w, objects, opts, walk)
+ return repo.packWrite(w, objects, opts, walk)
}
-func (repo *Repository) packWriteObjects(w io.Writer, objects []Hash, opts packWriteOptions, have *ReachabilityWalk) (Hash, error) {+// packWrite writes a pack stream for the provided object ids.
+func (repo *Repository) packWrite(w io.Writer, objects []Hash, opts packWriteOptions, have *ReachabilityWalk) (Hash, error) { if repo == nil { return Hash{}, ErrInvalidObject}
--- a/packed_write_test.go
+++ b/packed_write_test.go
@@ -159,7 +159,7 @@
}
packPath := pf.Name()
idxPath := strings.TrimSuffix(packPath, ".pack") + ".idx"
- if _, err := repo.packWrite(pf, objects, packWriteOptions{}); err != nil {+ if _, err := repo.packWrite(pf, objects, packWriteOptions{}, nil); err != nil {_ = pf.Close()
t.Fatalf("packWrite failed: %v", err)}
@@ -287,7 +287,7 @@
if _, err := repo.packWrite(pf, objects, packWriteOptions{EnableDeltas: true,
MinDeltaSavings: 1,
- }); err != nil {+ }, nil); err != nil {_ = pf.Close()
t.Fatalf("packWrite failed: %v", err)}
--
⑨