aboutsummaryrefslogtreecommitdiffstats
path: root/formats/packfile/delta.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-14 12:30:19 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-14 12:30:19 +0200
commit91bf16b2336e6f80f0742be729582fe5fbbada83 (patch)
tree935a95f72e824543970c8254c39cf0afa22b3410 /formats/packfile/delta.go
parentf826cf9d42cc34e2ae5aaf6ede892ecab9d2f198 (diff)
downloadgo-git-91bf16b2336e6f80f0742be729582fe5fbbada83.tar.gz
core: removing Object.Content, the Reader should be used always
Diffstat (limited to 'formats/packfile/delta.go')
-rw-r--r--formats/packfile/delta.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/formats/packfile/delta.go b/formats/packfile/delta.go
index 95c13d5..d08f969 100644
--- a/formats/packfile/delta.go
+++ b/formats/packfile/delta.go
@@ -1,6 +1,10 @@
package packfile
-import "gopkg.in/src-d/go-git.v4/core"
+import (
+ "io/ioutil"
+
+ "gopkg.in/src-d/go-git.v4/core"
+)
// See https://github.com/git/git/blob/49fa3dc76179e04b0833542fa52d0f287a4955ac/delta.h
// https://github.com/git/git/blob/c2c5f6b1e479f2c38e0e01345350620944e3527f/patch-delta.c,
@@ -11,12 +15,21 @@ const deltaSizeMin = 4
// ApplyDelta writes to taget the result of applying the modification deltas in delta to base.
func ApplyDelta(target, base core.Object, delta []byte) error {
- src := base.Content()
+ r, err := base.Reader()
+ if err != nil {
+ return err
+ }
+
w, err := target.Writer()
if err != nil {
return err
}
+ src, err := ioutil.ReadAll(r)
+ if err != nil {
+ return err
+ }
+
dst := PatchDelta(src, delta)
target.SetSize(int64(len(dst)))