aboutsummaryrefslogtreecommitdiffstats
path: root/remote.go
diff options
context:
space:
mode:
authorJavi Fontan <jfontan@gmail.com>2018-04-16 19:01:49 +0200
committerJavi Fontan <jfontan@gmail.com>2018-04-16 19:01:49 +0200
commit75da83739f25f528bf242341d62e01b773329470 (patch)
treec3fbaf323e0e1a46364f39c97a7721b8f53a7635 /remote.go
parent0db54e829f81a28f71c22d54c03daba5ec144c8d (diff)
downloadgo-git-75da83739f25f528bf242341d62e01b773329470.tar.gz
git: remote, Add shallow commits instead of substituting. Fixes #412
updateShallow substituted the previous shallow list with the one returned by the UploadPackResponse. If the repository had previous shallow commits these are deleted from the list. This change adds the new shallow hashes to the old ones. Signed-off-by: Javi Fontan <jfontan@gmail.com>
Diffstat (limited to 'remote.go')
-rw-r--r--remote.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/remote.go b/remote.go
index 666c9f5..4b86955 100644
--- a/remote.go
+++ b/remote.go
@@ -976,9 +976,24 @@ func pushHashes(
}
func (r *Remote) updateShallow(o *FetchOptions, resp *packp.UploadPackResponse) error {
- if o.Depth == 0 {
+ if o.Depth == 0 || len(resp.Shallows) == 0 {
return nil
}
- return r.s.SetShallow(resp.Shallows)
+ shallows, err := r.s.Shallow()
+ if err != nil {
+ return err
+ }
+
+outer:
+ for _, s := range resp.Shallows {
+ for _, oldS := range shallows {
+ if s == oldS {
+ continue outer
+ }
+ }
+ shallows = append(shallows, s)
+ }
+
+ return r.s.SetShallow(shallows)
}