From ae5c818674e2c9ca950ca7a9bf93f1283e7411b7 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 8 Mar 2026 12:03:26 +0800 Subject: receivepack, format/pack/ingest: Two-stage ingestion --- cmd/index-pack/main.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'cmd') 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 -- cgit v1.3.1-10-gc9f91