5import (
6 "context"
7▶ "errors"
8 "fmt"
9 "io"
· · ·
125// collected --depth commits. iter.ForEach surfaces whatever the callback
126// returns, so we can compare it back at the call site directly.
127▶var errStopIter = errors.New("history: stop iteration")
128
129// Bucketing divides [From, To] into N equal time slices. Used by the timeline
· · ·
201// (newest first → oldest first), and feeds every commit's first-parent diff
202// to the observer.
203▶func runHistory(repoPath string, observer CommitObserver) (HistoryWindow, error) {
204 // Turn GC back on because we have no idea how much we are about to process
205 EnableGc()
· · ·
207 repo, err := git.PlainOpenWithOptions(repoPath, &git.PlainOpenOptions{DetectDotGit: true})
208 if err != nil {
209▶ return HistoryWindow{}, fmt.Errorf("open git repository: %w", err)
210 }
211
· · ·
212 head, err := repo.Head()
213 if err != nil {
214▶ if errors.Is(err, plumbing.ErrReferenceNotFound) {
215 observer.Finalise(HistoryWindow{}, emptySnapshot())
216 return HistoryWindow{}, nil
+ 12 more matches in this file