aboutsummaryrefslogtreecommitdiffstats
path: root/remote.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-07-19 14:15:34 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2017-07-19 14:15:34 +0200
commitd851b90f5e832fa1edeb0d408bd56ed6c1fd5e7a (patch)
treeab25942ff243173a27979bc357d6bc516dda65d1 /remote.go
parent95bfc7e1c1b7101f2cd605cda58c1fb43d501d35 (diff)
downloadgo-git-d851b90f5e832fa1edeb0d408bd56ed6c1fd5e7a.tar.gz
repository: allow push from shallow repositories
Diffstat (limited to 'remote.go')
-rw-r--r--remote.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/remote.go b/remote.go
index 8f1da2f..fa984cf 100644
--- a/remote.go
+++ b/remote.go
@@ -104,6 +104,7 @@ func (r *Remote) Push(o *PushOptions) (err error) {
req := packp.NewReferenceUpdateRequestFromCapabilities(ar.Capabilities)
if err := r.addReferencesToUpdate(o.RefSpecs, remoteRefs, req); err != nil {
+
return err
}
@@ -121,6 +122,15 @@ func (r *Remote) Push(o *PushOptions) (err error) {
return err
}
+ stop, err := r.s.Shallow()
+ if err != nil {
+ return err
+ }
+
+ // if we have shallow we should include this as part of the objects that
+ // we are aware.
+ haves = append(haves, stop...)
+
hashesToPush, err := revlist.Objects(r.s, objects, haves)
if err != nil {
return err
@@ -486,7 +496,7 @@ func isFastForward(s storer.EncodedObjectStorer, old, new plumbing.Hash) (bool,
}
found := false
- iter := object.NewCommitPreorderIter(c)
+ iter := object.NewCommitPreorderIter(c, nil)
return found, iter.ForEach(func(c *object.Commit) error {
if c.Hash != old {
return nil