diff options
| author | 2026-03-04 08:26:56 +0800 | |
|---|---|---|
| committer | 2026-03-04 08:59:53 +0800 | |
| commit | ab7501be34032fb9e5c48726a68ae90a917af9eb (patch) | |
| tree | 20d005647569befea8133e953c3270e8fd2a2a5b /format/pack/pack.go | |
| parent | *: gofumpt (diff) | |
| signature | No signature | |
*: Lint
Diffstat (limited to 'format/pack/pack.go')
| -rw-r--r-- | format/pack/pack.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/format/pack/pack.go b/format/pack/pack.go index 45fe6a1c..e87e3360 100644 --- a/format/pack/pack.go +++ b/format/pack/pack.go @@ -33,16 +33,20 @@ func ParseOfsDeltaDistance(buf []byte) (uint64, int, error) { if len(buf) == 0 { return 0, 0, fmt.Errorf("format/pack: malformed ofs-delta distance") } + b := buf[0] dist := uint64(b & 0x7f) + consumed := 1 for b&0x80 != 0 { if consumed >= len(buf) { return 0, 0, fmt.Errorf("format/pack: malformed ofs-delta distance") } + b = buf[consumed] consumed++ dist = ((dist + 1) << 7) + uint64(b&0x7f) } + return dist, consumed, nil } |
