aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2017-06-09 12:13:53 +0200
committerSantiago M. Mola <santi@mola.io>2017-06-13 14:57:36 +0200
commit7908196d194b4536b60ccf13914f5722ab97cda4 (patch)
tree86a1f83f0ef8f786653f6cb912079ff65363166a
parent2a00316b65585be2bf68e1ea9c0e42c6af4f5679 (diff)
downloadgo-git-7908196d194b4536b60ccf13914f5722ab97cda4.tar.gz
ensure receive-pack session is closed on push.
* at low level, ReceivePack must close its stream to the server to signal it has finished. * remote.go: Close() must be called on session.
-rw-r--r--plumbing/transport/internal/common/common.go6
-rw-r--r--remote.go2
2 files changed, 7 insertions, 1 deletions
diff --git a/plumbing/transport/internal/common/common.go b/plumbing/transport/internal/common/common.go
index f67ae29..7001d05 100644
--- a/plumbing/transport/internal/common/common.go
+++ b/plumbing/transport/internal/common/common.go
@@ -263,6 +263,10 @@ func (s *session) ReceivePack(req *packp.ReferenceUpdateRequest) (*packp.ReportS
return nil, err
}
+ if err := s.Stdin.Close(); err != nil {
+ return nil, err
+ }
+
if !req.Capabilities.Supports(capability.ReportStatus) {
// If we have neither report-status or sideband, we can only
// check return value error.
@@ -302,7 +306,7 @@ func (s *session) finish() error {
func (s *session) Close() error {
if err := s.finish(); err != nil {
_ = s.Command.Close()
- return nil
+ return err
}
return s.Command.Close()
diff --git a/remote.go b/remote.go
index 592f7b6..bcc844c 100644
--- a/remote.go
+++ b/remote.go
@@ -76,6 +76,8 @@ func (r *Remote) Push(o *PushOptions) (err error) {
return err
}
+ defer ioutil.CheckClose(s, &err)
+
ar, err := s.AdvertisedReferences()
if err != nil {
return err