diff options
author | Antonio Navarro Perez <antnavper@gmail.com> | 2016-12-16 19:30:36 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-12-16 19:30:36 +0100 |
commit | 950676c36030a8796c0a69a8aae606ff1f448b03 (patch) | |
tree | 8edfd1baa31e83a396d263c2d0fed1a4d09a83dc /plumbing/format/packfile/diff_delta.go | |
parent | c49d8e374443180ff68404c904ccad5d87f9073e (diff) | |
download | go-git-950676c36030a8796c0a69a8aae606ff1f448b03.tar.gz |
packfile: delta selection logic (#182)
* packfile: delta selection logic
- Implemented logic to assign deltas to objects
* Requested changes
* Improved tests and fix errors
Diffstat (limited to 'plumbing/format/packfile/diff_delta.go')
-rw-r--r-- | plumbing/format/packfile/diff_delta.go | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/plumbing/format/packfile/diff_delta.go b/plumbing/format/packfile/diff_delta.go index bc4fafa..e3607bf 100644 --- a/plumbing/format/packfile/diff_delta.go +++ b/plumbing/format/packfile/diff_delta.go @@ -1,7 +1,6 @@ package packfile import ( - "fmt" "io/ioutil" "gopkg.in/src-d/go-git.v4/plumbing" @@ -15,23 +14,9 @@ const ( maxCopyLen = 0xffff ) -// GetOFSDelta returns an offset delta that knows the way of how to transform +// GetDelta returns an offset delta that knows the way of how to transform // base object to target object -func GetOFSDelta(base, target plumbing.EncodedObject) (plumbing.EncodedObject, error) { - return getDelta(base, target, plumbing.OFSDeltaObject) -} - -// GetRefDelta returns a reference delta that knows the way of how to transform -// base object to target object -func GetRefDelta(base, target plumbing.EncodedObject) (plumbing.EncodedObject, error) { - return getDelta(base, target, plumbing.REFDeltaObject) -} - -func getDelta(base, target plumbing.EncodedObject, t plumbing.ObjectType) (plumbing.EncodedObject, error) { - if t != plumbing.OFSDeltaObject && t != plumbing.REFDeltaObject { - return nil, fmt.Errorf("Type not supported: %v", t) - } - +func GetDelta(base, target plumbing.EncodedObject) (plumbing.EncodedObject, error) { br, err := base.Reader() if err != nil { return nil, err @@ -59,7 +44,7 @@ func getDelta(base, target plumbing.EncodedObject, t plumbing.ObjectType) (plumb } delta.SetSize(int64(len(db))) - delta.SetType(t) + delta.SetType(plumbing.OFSDeltaObject) return delta, nil } |