# Propagate collectCommitHashes errors

`dd85566`→[main](/content/gh/entireio/git-sync/commits/main/index.html)·Soph·2mo ago·1 file·+8 added/-5

A commit-graph iteration failure on trunk silently produced a nil ancestors set, leaving the trunk-first optimization disabled for the rest of the run with no diagnostic. The current planBatches gate prevents misalignment, but a refactor toward cross-branch accumulation would re-introduce a hard-to-diagnose "object not found" downstream. Surface the error at the source instead so the run fails loudly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

## Changes

1

- internal/strategy/bootstrap

- Mbootstrap.go+8/-5

```
580 unmodified lines

581
582
583
584
584
585
586
587
588
589
590
18 unmodified lines

609
610
611
609
612
613
614
612
615
616
617
618
1 unmodified line

620
621
622
620
623
624
622
625
626
627
628

580 unmodified lines

// Collect all commit hashes in the fetched graph so callers can extend
	// their stop set. We only need the keys — ~8 bytes per commit, so the
	// linux ancestry set is ~11 MB vs the store's ~4.6 GB.
	ancestors := collectCommitHashes(graphStore)
	ancestors, err := collectCommitHashes(graphStore)
	if err != nil {
		return nil, nil, nil, fmt.Errorf("collect commit hashes for %s: %w", ref.TargetRef, err)
	}
	// graphStore is unused beyond this point; runtime.GC reclaims its
	// transient allocations before we move on to the next branch.
	runtime.GC()
18 unmodified lines

// collectCommitHashes returns the set of commit hashes in store. Used to build
// the trunk reachability set for subsequent branches' stop-at walks.
func collectCommitHashes(store *memory.Storage) map[plumbing.Hash]struct{} {
func collectCommitHashes(store *memory.Storage) (map[plumbing.Hash]struct{}, error) {
	iter, err := store.IterEncodedObjects(plumbing.CommitObject)
	if err != nil {
		return nil
		return nil, fmt.Errorf("iterate commit objects: %w", err)
	}
	defer iter.Close()
	out := map[plumbing.Hash]struct{}{}
1 unmodified line

out[obj.Hash()] = struct{}{}
		return nil
	}); err != nil {
		return nil
		return nil, fmt.Errorf("walk commit objects: %w", err)
	}
	return out
	return out, nil
}

func estimateBatchCount(chainLen int64, batchMaxPack int64) int {
```

Minternal/strategy/bootstrap/bootstrap.go+8/-5
