aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/packfile
diff options
context:
space:
mode:
Diffstat (limited to 'plumbing/format/packfile')
-rw-r--r--plumbing/format/packfile/decoder.go7
-rw-r--r--plumbing/format/packfile/diff_delta.go6
-rw-r--r--plumbing/format/packfile/encoder.go3
3 files changed, 11 insertions, 5 deletions
diff --git a/plumbing/format/packfile/decoder.go b/plumbing/format/packfile/decoder.go
index 4e102c7..cd439b0 100644
--- a/plumbing/format/packfile/decoder.go
+++ b/plumbing/format/packfile/decoder.go
@@ -300,8 +300,11 @@ func (d *Decoder) newObject() plumbing.EncodedObject {
return d.o.NewEncodedObject()
}
-// DecodeObjectAt reads an object at the given location, if Decode wasn't called
-// previously objects offset should provided using the SetOffsets method
+// DecodeObjectAt reads an object at the given location. Every EncodedObject
+// returned is added into a internal index. This is intended to be able to regenerate
+// objects from deltas (offset deltas or reference deltas) without an package index
+// (.idx file). If Decode wasn't called previously objects offset should provided
+// using the SetOffsets method.
func (d *Decoder) DecodeObjectAt(offset int64) (plumbing.EncodedObject, error) {
if !d.s.IsSeekable {
return nil, ErrNonSeekable
diff --git a/plumbing/format/packfile/diff_delta.go b/plumbing/format/packfile/diff_delta.go
index 7b2e4ca..c25e194 100644
--- a/plumbing/format/packfile/diff_delta.go
+++ b/plumbing/format/packfile/diff_delta.go
@@ -14,8 +14,10 @@ const (
maxCopyLen = 0xffff
)
-// GetDelta returns an offset delta that knows the way of how to transform
-// base object to target object
+// GetDelta returns an EncodedObject of type OFSDeltaObject. Base and Target object,
+// will be loaded into memory to be able to create the delta object.
+// To generate target again, you will need the obtained object and "base" one.
+// Error will be returned if base or target object cannot be read.
func GetDelta(base, target plumbing.EncodedObject) (plumbing.EncodedObject, error) {
br, err := base.Reader()
if err != nil {
diff --git a/plumbing/format/packfile/encoder.go b/plumbing/format/packfile/encoder.go
index 96fe4b4..a0a13f8 100644
--- a/plumbing/format/packfile/encoder.go
+++ b/plumbing/format/packfile/encoder.go
@@ -23,7 +23,8 @@ type Encoder struct {
}
// NewEncoder creates a new packfile encoder using a specific Writer and
-// EncodedObjectStorer
+// EncodedObjectStorer. By default deltas used to generate the packfile will be
+// OFSDeltaObject. To use Reference deltas, set useRefDeltas to true.
func NewEncoder(w io.Writer, s storer.EncodedObjectStorer, useRefDeltas bool) *Encoder {
h := plumbing.Hasher{
Hash: sha1.New(),