diff options
author | Paulo Gomes <pjbgf@linux.com> | 2023-05-29 14:48:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-29 14:48:32 +0100 |
commit | 044ba2fc8e8de0f00a6a0729b369b9e93d87e712 (patch) | |
tree | ddfd9961730d98f29172331cd785f49d3c354b60 | |
parent | 44feb6c8221525c1cf10c51a82551a754b5d7031 (diff) | |
parent | 2dfdcb9985bf55f523c01fb2dac087a4391e915a (diff) | |
download | go-git-044ba2fc8e8de0f00a6a0729b369b9e93d87e712.tar.gz |
Merge pull request #763 from AriehSchneier/dont-add-want-if-have
git: don't add to wants if exists, shallow and depth 1
-rw-r--r-- | remote.go | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -457,7 +457,7 @@ func (r *Remote) fetch(ctx context.Context, o *FetchOptions) (sto storer.Referen } } - req.Wants, err = getWants(r.s, refs) + req.Wants, err = getWants(r.s, refs, o.Depth) if len(req.Wants) > 0 { req.Haves, err = getHaves(localRefs, remoteRefs, r.s, o.Depth) if err != nil { @@ -1011,10 +1011,14 @@ func doCalculateRefs( return refList, ret } -func getWants(localStorer storage.Storer, refs memory.ReferenceStorage) ([]plumbing.Hash, error) { +func getWants(localStorer storage.Storer, refs memory.ReferenceStorage, depth int) ([]plumbing.Hash, error) { + // If depth is anything other than 1 and the repo has shallow commits then just because we have the commit + // at the reference doesn't mean that we don't still need to fetch the parents shallow := false - if s, _ := localStorer.Shallow(); len(s) > 0 { - shallow = true + if depth != 1 { + if s, _ := localStorer.Shallow(); len(s) > 0 { + shallow = true + } } wants := map[plumbing.Hash]bool{} |