diff options
| author | 2026-01-29 17:43:02 +0100 | |
|---|---|---|
| committer | 2026-01-29 17:43:55 +0100 | |
| commit | 26ae77e8f63111bba3dd4e92ffcaccaa76570927 (patch) | |
| tree | 3f45775d29d57acb9f8d68893932aa25539b3ef1 /packed_write_pack.go | |
| parent | packed: Write packs with deltas (diff) | |
| signature | No signature | |
packed: Use random delta seed
Diffstat (limited to 'packed_write_pack.go')
| -rw-r--r-- | packed_write_pack.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/packed_write_pack.go b/packed_write_pack.go index 0bcaf9ca..42c8793d 100644 --- a/packed_write_pack.go +++ b/packed_write_pack.go @@ -1,6 +1,7 @@ package furgit import ( + "crypto/rand" "crypto/sha1" "crypto/sha256" "encoding/binary" @@ -318,10 +319,15 @@ func (repo *Repository) packWrite(w io.Writer, objects []Hash, opts packWriteOpt } var dctx deltaContext + var deltaSeed uint32 if opts.EnableDeltas { dctx.window = defaultDeltaWindow + var seedBytes [4]byte + if _, err := rand.Read(seedBytes[:]); err != nil { + return Hash{}, err + } + deltaSeed = binary.LittleEndian.Uint32(seedBytes[:]) } - deltaSeed := uint32(0) for _, id := range objects { ty, body, err := repo.ReadObjectTypeRaw(id) |
