diff options
author | Javi Fontan <jfontan@gmail.com> | 2018-04-16 19:01:49 +0200 |
---|---|---|
committer | Javi Fontan <jfontan@gmail.com> | 2018-04-16 19:01:49 +0200 |
commit | 75da83739f25f528bf242341d62e01b773329470 (patch) | |
tree | c3fbaf323e0e1a46364f39c97a7721b8f53a7635 /remote.go | |
parent | 0db54e829f81a28f71c22d54c03daba5ec144c8d (diff) | |
download | go-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.go | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -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) } |