func (e *Encoder) encodeHeader(idx *Index) error { return binary.Write(e.w, indexSignature, idx.Version, uint32(len(idx.Entries)), ) }
func (e *Encoder) head(numEntries int) error { return binary.Write( e.w, signature, int32(VersionSupported), int32(numEntries), ) }
func (e *Encoder) encodeEntry(entry *Entry) error { if entry.IntentToAdd || entry.SkipWorktree { return ErrUnsupportedVersion } sec, nsec, err := e.timeToUint32(&entry.CreatedAt) if err != nil { return err } msec, mnsec, err := e.timeToUint32(&entry.ModifiedAt) if err != nil { return err } flags := uint16(entry.Stage&0x3) << 12 if l := len(entry.Name); l < nameMask { flags |= uint16(l) } else { flags |= nameMask } flow := []interface{}{ sec, nsec, msec, mnsec, entry.Dev, entry.Inode, entry.Mode, entry.UID, entry.GID, entry.Size, entry.Hash[:], flags, } if err := binary.Write(e.w, flow...); err != nil { return err } return binary.Write(e.w, []byte(entry.Name)) }
func (e *Encoder) encodeCRC32(idx *Idxfile) (int, error) { sz := 0 for _, ent := range idx.Entries { err := binary.Write(e, ent.CRC32) sz += 4 if err != nil { return sz, err } } return sz, nil }
func (e *Encoder) encodeFooter() error { return binary.Write(e.w, e.hash.Sum(nil)) }
func (e *Encoder) footer() (plumbing.Hash, error) { h := e.hasher.Sum() return h, binary.Write(e.w, h) }
func (e *Encoder) writeRefDeltaHeader(base plumbing.Hash) error { return binary.Write(e.w, base) }