aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/packfile/diff_delta.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2020-05-24 19:25:08 +0200
committerGitHub <noreply@github.com>2020-05-24 19:25:08 +0200
commit8019144b6534ff58ad234a355e5b143f1c99b45e (patch)
tree5a67682c34bb20a826ebf430f11181d6892fc0e7 /plumbing/format/packfile/diff_delta.go
parente7f544844d6d736acfd9d75ee0d4a9d37f450103 (diff)
parent10199949b9e5a71f72241c4bb23f3d733287065c (diff)
downloadgo-git-8019144b6534ff58ad234a355e5b143f1c99b45e.tar.gz
Merge pull request #73 from WKBae/close_objectv5.1.0
Close Reader & Writer of EncodedObject after use
Diffstat (limited to 'plumbing/format/packfile/diff_delta.go')
-rw-r--r--plumbing/format/packfile/diff_delta.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/plumbing/format/packfile/diff_delta.go b/plumbing/format/packfile/diff_delta.go
index 1d4b384..1951b34 100644
--- a/plumbing/format/packfile/diff_delta.go
+++ b/plumbing/format/packfile/diff_delta.go
@@ -4,6 +4,7 @@ import (
"bytes"
"github.com/go-git/go-git/v5/plumbing"
+ "github.com/go-git/go-git/v5/utils/ioutil"
)
// See https://github.com/jelmer/dulwich/blob/master/dulwich/pack.py and
@@ -27,17 +28,20 @@ func GetDelta(base, target plumbing.EncodedObject) (plumbing.EncodedObject, erro
return getDelta(new(deltaIndex), base, target)
}
-func getDelta(index *deltaIndex, base, target plumbing.EncodedObject) (plumbing.EncodedObject, error) {
+func getDelta(index *deltaIndex, base, target plumbing.EncodedObject) (o plumbing.EncodedObject, err error) {
br, err := base.Reader()
if err != nil {
return nil, err
}
- defer br.Close()
+
+ defer ioutil.CheckClose(br, &err)
+
tr, err := target.Reader()
if err != nil {
return nil, err
}
- defer tr.Close()
+
+ defer ioutil.CheckClose(tr, &err)
bb := bufPool.Get().(*bytes.Buffer)
defer bufPool.Put(bb)