aboutsummaryrefslogtreecommitdiffstats
path: root/worktree.go
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2023-12-01 09:42:24 +0000
committerGitHub <noreply@github.com>2023-12-01 09:42:24 +0000
commitae552ce0bf32cddb689727c4c9fa6bf4d3bd6499 (patch)
treec223855c84a1b15db67762f4b53c4093c216e734 /worktree.go
parentcc1895b905ebadb09504d88444ff05932fa6e928 (diff)
parent861009f70a5b68d1ee134fea7bc1d893088388bb (diff)
downloadgo-git-ae552ce0bf32cddb689727c4c9fa6bf4d3bd6499.tar.gz
Merge pull request #939 from dhoizner/fix-pull-after-shallow
git: stop iterating at oldest shallow when pulling. Fixes #305
Diffstat (limited to 'worktree.go')
-rw-r--r--worktree.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/worktree.go b/worktree.go
index 51795e6..66cb3d2 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 {
if err := opts.Branch.Validate(); err != nil {
return err