aboutsummaryrefslogtreecommitdiff
path: root/cmd/index-pack
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-08 12:03:26 +0800
committerGravatar Runxi Yu2026-03-08 12:03:26 +0800
commitae5c818674e2c9ca950ca7a9bf93f1283e7411b7 (patch)
tree25d1702260993a8066690c93b3da81adea6d4258 /cmd/index-pack
parentreceivepack: Trivial caps (diff)
signatureNo signature
receivepack, format/pack/ingest: Two-stage ingestion
Diffstat (limited to 'cmd/index-pack')
-rw-r--r--cmd/index-pack/main.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/cmd/index-pack/main.go b/cmd/index-pack/main.go
index 0715fa05..cfd80f6a 100644
--- a/cmd/index-pack/main.go
+++ b/cmd/index-pack/main.go
@@ -85,7 +85,7 @@ func run(repoPath, destinationPath, objectFormat string, fixThin, writeRev bool)
defer func() { _ = destinationRoot.Close() }()
- result, err := ingest.Ingest(os.Stdin, destinationRoot, algo, ingest.Options{
+ pending, err := ingest.Ingest(os.Stdin, algo, ingest.Options{
FixThin: fixThin,
WriteRev: writeRev,
Base: base,
@@ -95,6 +95,22 @@ func run(repoPath, destinationPath, objectFormat string, fixThin, writeRev bool)
return err
}
+ if pending.Header().ObjectCount == 0 {
+ discarded, err := pending.Discard()
+ if err != nil {
+ return err
+ }
+
+ _, _ = fmt.Fprintf(os.Stdout, "pack\t%s\n", discarded.PackHash.String())
+
+ return nil
+ }
+
+ result, err := pending.Continue(destinationRoot)
+ if err != nil {
+ return err
+ }
+
_, _ = fmt.Fprintf(os.Stdout, "pack\t%s\n", result.PackHash.String())
return nil