aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-05 20:55:17 +0800
committerGravatar Runxi Yu2026-03-05 20:55:17 +0800
commit915fca6a9c2923a3bcf7a5a257e5832fab8cd432 (patch)
tree1726c92257263033da5cadb4a570c97b68332ee7 /cmd
parentlint: Exclude compress/{flate,internal} (diff)
signatureNo signature
*: Fix lint wsl_v5
Diffstat (limited to 'cmd')
-rw-r--r--cmd/index-pack/main.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/cmd/index-pack/main.go b/cmd/index-pack/main.go
index 12d01ed8..6b6404b1 100644
--- a/cmd/index-pack/main.go
+++ b/cmd/index-pack/main.go
@@ -39,17 +39,20 @@ func run(repoPath, destinationPath, objectFormat string, fixThin, writeRev bool)
base objectstore.Store
repo *repository.Repository
)
+
if repoPath != "" {
repoRoot, err := os.OpenRoot(repoPath)
if err != nil {
return fmt.Errorf("open repo root: %w", err)
}
+
defer func() { _ = repoRoot.Close() }()
repo, err = repository.Open(repoRoot)
if err != nil {
return fmt.Errorf("open repository: %w", err)
}
+
defer func() { _ = repo.Close() }()
}
@@ -62,9 +65,11 @@ func run(repoPath, destinationPath, objectFormat string, fixThin, writeRev bool)
if repo == nil {
return fmt.Errorf("fix-thin requires -r <repo>")
}
+
if repo.Algorithm() != algo {
return fmt.Errorf("algorithm mismatch: repo=%s flag=%s", repo.Algorithm(), algo)
}
+
base = repo.Objects()
}
@@ -77,6 +82,7 @@ func run(repoPath, destinationPath, objectFormat string, fixThin, writeRev bool)
if err != nil {
return fmt.Errorf("open destination root: %w", err)
}
+
defer func() { _ = destinationRoot.Close() }()
result, err := ingest.Ingest(os.Stdin, destinationRoot, algo, fixThin, writeRev, base)