aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/index/decoder.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-11-19 23:23:42 +0100
committerGitHub <noreply@github.com>2018-11-19 23:23:42 +0100
commitf62cd8e3495579a8323455fa0c4e6c44bb0d5e09 (patch)
tree22c4649f1e93076d96a263cdd876cb8a7e16694c /plumbing/format/index/decoder.go
parent2431109797aa48f33c0be2066c58f0cad0578ecc (diff)
parentb99653a9d3d231a9e1e4a1ddca41a08b3b733ae9 (diff)
downloadgo-git-f62cd8e3495579a8323455fa0c4e6c44bb0d5e09.tar.gz
Merge pull request #1025 from mcuadros/eoiev4.8.0
plumbing: format/index: support for EOIE extension
Diffstat (limited to 'plumbing/format/index/decoder.go')
-rw-r--r--plumbing/format/index/decoder.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/plumbing/format/index/decoder.go b/plumbing/format/index/decoder.go
index df25530..ac57d08 100644
--- a/plumbing/format/index/decoder.go
+++ b/plumbing/format/index/decoder.go
@@ -261,6 +261,17 @@ func (d *Decoder) readExtension(idx *Index, header []byte) error {
if err := d.Decode(idx.ResolveUndo); err != nil {
return err
}
+ case bytes.Equal(header, endOfIndexEntryExtSignature):
+ r, err := d.getExtensionReader()
+ if err != nil {
+ return err
+ }
+
+ idx.EndOfIndexEntry = &EndOfIndexEntry{}
+ d := &endOfIndexEntryDecoder{r}
+ if err := d.Decode(idx.EndOfIndexEntry); err != nil {
+ return err
+ }
default:
return errUnknownExtension
}
@@ -449,3 +460,17 @@ func (d *resolveUndoDecoder) readStage(e *ResolveUndoEntry, s Stage) error {
return nil
}
+
+type endOfIndexEntryDecoder struct {
+ r io.Reader
+}
+
+func (d *endOfIndexEntryDecoder) Decode(e *EndOfIndexEntry) error {
+ var err error
+ e.Offset, err = binary.ReadUint32(d.r)
+ if err != nil {
+ return err
+ }
+
+ return binary.Read(d.r, &e.Hash)
+}