Skip to content

Commit

Permalink
git: don't add to wants if exists, shallow and depth 1
Browse files Browse the repository at this point in the history
Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com>
  • Loading branch information
AriehSchneier committed May 8, 2023
1 parent 1dbd729 commit acb0c1a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
if err != nil {
Expand Down Expand Up @@ -987,7 +987,7 @@ func doCalculateRefs(
return err
}

func getWants(localStorer storage.Storer, refs memory.ReferenceStorage) ([]plumbing.Hash, error) {
func getWants(localStorer storage.Storer, refs memory.ReferenceStorage, depth int) ([]plumbing.Hash, error) {
shallow := false
if s, _ := localStorer.Shallow(); len(s) > 0 {
shallow = true
Expand All @@ -1001,7 +1001,7 @@ func getWants(localStorer storage.Storer, refs memory.ReferenceStorage) ([]plumb
return nil, err
}

if !exists || shallow {
if !exists || (shallow && depth != 1) {
wants[hash] = true
}
}
Expand Down

0 comments on commit acb0c1a

Please sign in to comment.