Skip to content

Commit 146a800

Browse files
author
Scott Arbeit
committed
Merge branch 'Add-unreachable-objects' of https://github.com/ScottArbeit/git-sizer into Add-unreachable-objects
2 parents 13288f3 + 470d43e commit 146a800

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

git/git.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,11 @@ type UnreachableStats struct {
189189
// batch mode to efficiently retrieve their sizes.
190190
func (repo *Repository) GetUnreachableStats() (UnreachableStats, error) {
191191
// Run git fsck. Using CombinedOutput captures both stdout and stderr.
192-
cmd := exec.Command(repo.gitBin, "-C", repo.gitDir, "fsck", "--unreachable", "--no-reflogs", "--full")
192+
gitDir, err := repo.GitDir()
193+
if err != nil {
194+
return UnreachableStats{Count: 0, Size: 0}, fmt.Errorf("failed to retrieve Git directory: %w", err)
195+
}
196+
cmd := exec.Command(repo.gitBin, "-C", gitDir, "fsck", "--unreachable", "--no-reflogs", "--full")
193197
cmd.Env = os.Environ()
194198
output, err := cmd.CombinedOutput()
195199
if err != nil {

0 commit comments

Comments
 (0)