aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/idxfile/encoder.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-07-27 09:35:19 +0200
committerGitHub <noreply@github.com>2017-07-27 09:35:19 +0200
commit854ffa16f650706200a6ebb5505bb448b5c64035 (patch)
tree61892f335f61c6fbb2bf65f7daf51829276a8e28 /plumbing/format/idxfile/encoder.go
parentc2561364e33763d3356a23c5850424a334de30e9 (diff)
parent48900a1c810dd2dac9cb44511e6a2412d3064da6 (diff)
downloadgo-git-854ffa16f650706200a6ebb5505bb448b5c64035.tar.gz
Merge pull request #512 from mcuadros/idx-64bits
format: idxfile, support for >2Gb packfiles
Diffstat (limited to 'plumbing/format/idxfile/encoder.go')
-rw-r--r--plumbing/format/idxfile/encoder.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/plumbing/format/idxfile/encoder.go b/plumbing/format/idxfile/encoder.go
index d8f4d94..40abfb8 100644
--- a/plumbing/format/idxfile/encoder.go
+++ b/plumbing/format/idxfile/encoder.go
@@ -98,13 +98,28 @@ func (e *Encoder) encodeCRC32(idx *Idxfile) (int, error) {
func (e *Encoder) encodeOffsets(idx *Idxfile) (int, error) {
sz := 0
+
+ var o64bits []uint64
for _, ent := range idx.Entries {
- if err := binary.WriteUint32(e, uint32(ent.Offset)); err != nil {
+ o := ent.Offset
+ if o > offsetLimit {
+ o64bits = append(o64bits, o)
+ o = offsetLimit + uint64(len(o64bits))
+ }
+
+ if err := binary.WriteUint32(e, uint32(o)); err != nil {
return sz, err
}
sz += 4
+ }
+
+ for _, o := range o64bits {
+ if err := binary.WriteUint64(e, o); err != nil {
+ return sz, err
+ }
+ sz += 8
}
return sz, nil