aboutsummaryrefslogtreecommitdiffstats
path: root/remote.go
diff options
context:
space:
mode:
authorArieh Schneier <15041913+AriehSchneier@users.noreply.github.com>2023-05-25 09:18:07 +1000
committerArieh Schneier <15041913+AriehSchneier@users.noreply.github.com>2023-05-25 09:18:07 +1000
commit2dfdcb9985bf55f523c01fb2dac087a4391e915a (patch)
tree03f6704c4ffc35df0bfbb2fd54e07c9be75a49ba /remote.go
parentb98b813a17d32f4fa29a3ef2e9f4c38c5a97b440 (diff)
downloadgo-git-2dfdcb9985bf55f523c01fb2dac087a4391e915a.tar.gz
git: don't add to wants if exists, shallow and depth 1
Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com>
Diffstat (limited to 'remote.go')
-rw-r--r--remote.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/remote.go b/remote.go
index 0e72aad..70d4df8 100644
--- a/remote.go
+++ b/remote.go
@@ -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 {
@@ -997,10 +997,14 @@ 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) {
+ // 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{}