diff options
author | Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com> | 2024-07-29 11:56:26 +1000 |
---|---|---|
committer | Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com> | 2024-07-29 11:56:26 +1000 |
commit | 6b797242d6ddd149d3e6a8d8496c6e442541b7ae (patch) | |
tree | 16727c06b89404fac71884e0bbdb6e5fdec0ce52 /remote.go | |
parent | 0361e45d1ad6b209277a5af0a3dabba2675012eb (diff) | |
download | go-git-6b797242d6ddd149d3e6a8d8496c6e442541b7ae.tar.gz |
git: Fix fetching missing commits
Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com>
Diffstat (limited to 'remote.go')
-rw-r--r-- | remote.go | 27 |
1 files changed, 17 insertions, 10 deletions
@@ -9,6 +9,7 @@ import ( "time" "github.com/go-git/go-billy/v5/osfs" + "github.com/go-git/go-git/v5/config" "github.com/go-git/go-git/v5/internal/url" "github.com/go-git/go-git/v5/plumbing" @@ -491,7 +492,18 @@ func (r *Remote) fetch(ctx context.Context, o *FetchOptions) (sto storer.Referen } if !updated && !updatedPrune { - return remoteRefs, NoErrAlreadyUpToDate + // No references updated, but may have fetched new objects, check if we now have any of our wants + for _, hash := range req.Wants { + exists, _ := objectExists(r.s, hash) + if exists { + updated = true + break + } + } + + if !updated { + return remoteRefs, NoErrAlreadyUpToDate + } } return remoteRefs, nil @@ -878,17 +890,12 @@ func getHavesFromRef( return nil } - // No need to load the commit if we know the remote already - // has this hash. - if remoteRefs[h] { - haves[h] = true - return nil - } - commit, err := object.GetCommit(s, h) if err != nil { - // Ignore the error if this isn't a commit. - haves[ref.Hash()] = true + if !errors.Is(err, plumbing.ErrObjectNotFound) { + // Ignore the error if this isn't a commit. + haves[ref.Hash()] = true + } return nil } |