From 950676c36030a8796c0a69a8aae606ff1f448b03 Mon Sep 17 00:00:00 2001 From: Antonio Navarro Perez Date: Fri, 16 Dec 2016 19:30:36 +0100 Subject: packfile: delta selection logic (#182) * packfile: delta selection logic - Implemented logic to assign deltas to objects * Requested changes * Improved tests and fix errors --- plumbing/format/packfile/diff_delta.go | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'plumbing/format/packfile/diff_delta.go') 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 } -- cgit