aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport/internal/common
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2017-06-13 14:23:15 +0200
committerSantiago M. Mola <santi@mola.io>2017-06-13 15:39:49 +0200
commitcbbd2a9ad8ee990c79bd847b0df2823e2449ea4e (patch)
tree25905da2442b2363d0d45bba07485543e5665deb /plumbing/transport/internal/common
parent4b2d9b42bf18556bc51434e7221927c681bce746 (diff)
downloadgo-git-cbbd2a9ad8ee990c79bd847b0df2823e2449ea4e.tar.gz
transport/internal: remove Wait function, use Close directly
Diffstat (limited to 'plumbing/transport/internal/common')
-rw-r--r--plumbing/transport/internal/common/common.go26
1 files changed, 5 insertions, 21 deletions
diff --git a/plumbing/transport/internal/common/common.go b/plumbing/transport/internal/common/common.go
index d947d28..c1e1518 100644
--- a/plumbing/transport/internal/common/common.go
+++ b/plumbing/transport/internal/common/common.go
@@ -59,14 +59,8 @@ type Command interface {
// Start starts the specified command. It does not wait for it to
// complete.
Start() error
- // Wait waits for the command to exit. It must have been started by
- // Start. The returned error is nil if the command runs, has no
- // problems copying stdin, stdout, and stderr, and exits with a zero
- // exit status.
- Wait() error
// Close closes the command and releases any resources used by it. It
- // can be called to forcibly finish the command without calling to Wait
- // or to release resources after calling Wait.
+ // will block until the command exits.
Close() error
}
@@ -178,6 +172,7 @@ func (s *session) handleAdvRefDecodeError(err error) error {
// If repository is not found, we get empty stdout and server writes an
// error to stderr.
if err == packp.ErrEmptyInput {
+ s.finished = true
if err := s.checkNotFoundError(); err != nil {
return err
}
@@ -246,9 +241,7 @@ func (s *session) UploadPack(req *packp.UploadPackRequest) (*packp.UploadPackRes
return nil, err
}
- wc := &waitCloser{s.Command}
- rc := ioutil.NewReadCloser(r, wc)
-
+ rc := ioutil.NewReadCloser(r, s.Command)
return DecodeUploadPackResponse(rc, req)
}
@@ -270,7 +263,7 @@ func (s *session) ReceivePack(req *packp.ReferenceUpdateRequest) (*packp.ReportS
if !req.Capabilities.Supports(capability.ReportStatus) {
// If we have neither report-status or sideband, we can only
// check return value error.
- return nil, s.Command.Wait()
+ return nil, s.Command.Close()
}
report := packp.NewReportStatus()
@@ -282,7 +275,7 @@ func (s *session) ReceivePack(req *packp.ReferenceUpdateRequest) (*packp.ReportS
return report, err
}
- return report, s.Command.Wait()
+ return report, s.Command.Close()
}
func (s *session) finish() error {
@@ -417,12 +410,3 @@ func DecodeUploadPackResponse(r io.ReadCloser, req *packp.UploadPackRequest) (
return res, nil
}
-
-type waitCloser struct {
- Command Command
-}
-
-// Close waits until the command exits and returns error, if any.
-func (c *waitCloser) Close() error {
- return c.Command.Wait()
-}