aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/packfile/patch_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/patch_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/patch_delta.go')
-rw-r--r--plumbing/format/packfile/patch_delta.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/plumbing/format/packfile/patch_delta.go b/plumbing/format/packfile/patch_delta.go
index 57c9da7..1dc8b8b 100644
--- a/plumbing/format/packfile/patch_delta.go
+++ b/plumbing/format/packfile/patch_delta.go
@@ -6,6 +6,7 @@ import (
"io"
"github.com/go-git/go-git/v5/plumbing"
+ "github.com/go-git/go-git/v5/utils/ioutil"
)
// See https://github.com/git/git/blob/49fa3dc76179e04b0833542fa52d0f287a4955ac/delta.h
@@ -16,17 +17,21 @@ import (
const deltaSizeMin = 4
// ApplyDelta writes to target the result of applying the modification deltas in delta to base.
-func ApplyDelta(target, base plumbing.EncodedObject, delta []byte) error {
+func ApplyDelta(target, base plumbing.EncodedObject, delta []byte) (err error) {
r, err := base.Reader()
if err != nil {
return err
}
+ defer ioutil.CheckClose(r, &err)
+
w, err := target.Writer()
if err != nil {
return err
}
+ defer ioutil.CheckClose(w, &err)
+
buf := bufPool.Get().(*bytes.Buffer)
defer bufPool.Put(buf)
buf.Reset()