示例#1
0
文件: encoder.go 项目: src-d/go-git
func (e *Encoder) encodeHeader(idx *Index) error {
	return binary.Write(e.w,
		indexSignature,
		idx.Version,
		uint32(len(idx.Entries)),
	)
}
示例#2
0
文件: encoder.go 项目: src-d/go-git
func (e *Encoder) head(numEntries int) error {
	return binary.Write(
		e.w,
		signature,
		int32(VersionSupported),
		int32(numEntries),
	)
}
示例#3
0
文件: encoder.go 项目: src-d/go-git
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))
}
示例#4
0
文件: encoder.go 项目: src-d/go-git
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
}
示例#5
0
文件: encoder.go 项目: src-d/go-git
func (e *Encoder) encodeFooter() error {
	return binary.Write(e.w, e.hash.Sum(nil))
}
示例#6
0
文件: encoder.go 项目: src-d/go-git
func (e *Encoder) footer() (plumbing.Hash, error) {
	h := e.hasher.Sum()
	return h, binary.Write(e.w, h)
}
示例#7
0
文件: encoder.go 项目: src-d/go-git
func (e *Encoder) writeRefDeltaHeader(base plumbing.Hash) error {
	return binary.Write(e.w, base)
}