aboutsummaryrefslogtreecommitdiffstats
path: root/formats/packfile/delta.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2015-10-25 20:30:36 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2015-10-25 20:30:36 +0100
commit9a44cd8ccff143a112436c38bfe5581e74b68f07 (patch)
treef4d2f38cc61647bf159a7c870913e6f6b60828b2 /formats/packfile/delta.go
parentbe69a505926451bf10450ac68d40265a6f43e150 (diff)
downloadgo-git-9a44cd8ccff143a112436c38bfe5581e74b68f07.tar.gz
formats/packfile: new reader API
Diffstat (limited to 'formats/packfile/delta.go')
-rw-r--r--formats/packfile/delta.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/formats/packfile/delta.go b/formats/packfile/delta.go
index 30703eb..571ccf8 100644
--- a/formats/packfile/delta.go
+++ b/formats/packfile/delta.go
@@ -2,7 +2,7 @@ package packfile
import "io"
-const delta_size_min = 4
+const deltaSizeMin = 4
func deltaHeaderSize(b []byte) (uint, []byte) {
var size, j uint
@@ -18,8 +18,8 @@ func deltaHeaderSize(b []byte) (uint, []byte) {
return size, b[j:]
}
-func PatchDelta(src, delta []byte) []byte {
- if len(delta) < delta_size_min {
+func patchDelta(src, delta []byte) []byte {
+ if len(delta) < deltaSizeMin {
return nil
}
size, delta := deltaHeaderSize(delta)
@@ -94,12 +94,13 @@ func PatchDelta(src, delta []byte) []byte {
return dest
}
-func decodeOffset(src io.ByteReader, steps int) (int, error) {
+func decodeOffset(src io.ByteReader, steps int64) (int64, error) {
b, err := src.ReadByte()
if err != nil {
return 0, err
}
- var offset = int(b & 0x7f)
+
+ var offset = int64(b & 0x7f)
for (b & 0x80) != 0 {
offset++ // WHY?
b, err = src.ReadByte()
@@ -107,7 +108,7 @@ func decodeOffset(src io.ByteReader, steps int) (int, error) {
return 0, err
}
- offset = (offset << 7) + int(b&0x7f)
+ offset = (offset << 7) + int64(b&0x7f)
}
// offset needs to be aware of the bytes we read for `o.typ` and `o.size`