diff options
author | Dan Hoizner <dan.hoizner@gmail.com> | 2023-11-22 12:51:45 -0500 |
---|---|---|
committer | Dan Hoizner <dan.hoizner@gmail.com> | 2023-11-27 11:06:59 -0500 |
commit | 861009f70a5b68d1ee134fea7bc1d893088388bb (patch) | |
tree | daaa23be15280c8ae4b36e19e8492c02ab994874 /worktree.go | |
parent | fecea417bfc18648757a1bde30ca384548b55197 (diff) | |
download | go-git-861009f70a5b68d1ee134fea7bc1d893088388bb.tar.gz |
git: stop iterating at oldest shallow when pulling. Fixes #305
Diffstat (limited to 'worktree.go')
-rw-r--r-- | worktree.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/worktree.go b/worktree.go index f8b854d..974d233 100644 --- a/worktree.go +++ b/worktree.go @@ -95,7 +95,15 @@ func (w *Worktree) PullContext(ctx context.Context, o *PullOptions) error { head, err := w.r.Head() if err == nil { - headAheadOfRef, err := isFastForward(w.r.Storer, ref.Hash(), head.Hash()) + // if we don't have a shallows list, just ignore it + shallowList, _ := w.r.Storer.Shallow() + + var earliestShallow *plumbing.Hash + if len(shallowList) > 0 { + earliestShallow = &shallowList[0] + } + + headAheadOfRef, err := isFastForward(w.r.Storer, ref.Hash(), head.Hash(), earliestShallow) if err != nil { return err } @@ -104,7 +112,7 @@ func (w *Worktree) PullContext(ctx context.Context, o *PullOptions) error { return NoErrAlreadyUpToDate } - ff, err := isFastForward(w.r.Storer, head.Hash(), ref.Hash()) + ff, err := isFastForward(w.r.Storer, head.Hash(), ref.Hash(), earliestShallow) if err != nil { return err } @@ -188,6 +196,7 @@ func (w *Worktree) Checkout(opts *CheckoutOptions) error { return w.Reset(ro) } + func (w *Worktree) createBranch(opts *CheckoutOptions) error { _, err := w.r.Storer.Reference(opts.Branch) if err == nil { |