Source File
diff_delta.go
Belonging Package
github.com/go-git/go-git/v5/plumbing/format/packfile
package packfile
import (
)
s = 16
maxCopySize = 64 * 1024
)
func (, plumbing.EncodedObject) (plumbing.EncodedObject, error) {
return getDelta(new(deltaIndex), , )
}
func ( *deltaIndex, , plumbing.EncodedObject) ( plumbing.EncodedObject, error) {
, := .Reader()
if != nil {
return nil,
}
defer ioutil.CheckClose(, &)
, := .Reader()
if != nil {
return nil,
}
defer ioutil.CheckClose(, &)
:= bufPool.Get().(*bytes.Buffer)
defer bufPool.Put()
.Reset()
_, = .ReadFrom()
if != nil {
return nil,
}
:= bufPool.Get().(*bytes.Buffer)
defer bufPool.Put()
.Reset()
_, = .ReadFrom()
if != nil {
return nil,
}
:= diffDelta(, .Bytes(), .Bytes())
:= &plumbing.MemoryObject{}
_, = .Write()
if != nil {
return nil,
}
.SetSize(int64(len()))
.SetType(plumbing.OFSDeltaObject)
return , nil
}
func (, []byte) []byte {
return diffDelta(new(deltaIndex), , )
}
func ( *deltaIndex, []byte, []byte) []byte {
:= bufPool.Get().(*bytes.Buffer)
defer bufPool.Put()
.Reset()
.Write(deltaEncodeSize(len()))
.Write(deltaEncodeSize(len()))
if len(.entries) == 0 {
.init()
}
:= bufPool.Get().(*bytes.Buffer)
defer bufPool.Put()
.Reset()
for := 0; < len(); ++ {
, := .findMatch(, , )
.WriteByte([])
for := ; < +; ++ {
.WriteByte([])
}
+= - 1
} else {
encodeInsertOperation(, )
:=
:=
for > 0 {
if < maxCopySize {
.Write(encodeCopyOperation(, ))
break
}
.Write(encodeCopyOperation(, maxCopySize))
-= maxCopySize
+= maxCopySize
}
+= - 1
}
}
encodeInsertOperation(, )
return append([]byte{}, .Bytes()...)
}
func (, *bytes.Buffer) {
if .Len() == 0 {
return
}
:= .Bytes()
:= .Len()
:= 0
for {
if <= 127 {
break
}
.WriteByte(byte(127))
.Write([ : +127])
-= 127
+= 127
}
.WriteByte(byte())
.Write([ : +])
.Reset()
}
func ( int) []byte {
var []byte
:= & 0x7f
>>= 7
for {
if == 0 {
break
}
= append(, byte(|0x80))
= & 0x7f
>>= 7
}
= append(, byte())
return
}
func (, int) []byte {
:= 0x80
var []byte
var uint
for = 0; < 4; ++ {
:= 0xff << ( * 8)
if & != 0 {
= append(, byte(&>>(*8)))
|= 0x01 <<
}
}
for = 0; < 3; ++ {
:= 0xff << ( * 8)
if & != 0 {
= append(, byte(&>>(*8)))
|= 0x10 <<
}
}
return append([]byte{byte()}, ...)
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |