示例#1
0
文件: object.go 项目: src-d/go-git
func (i index) Decode(r io.Reader) error {
	idx := &idxfile.Idxfile{}

	d := idxfile.NewDecoder(r)
	if err := d.Decode(idx); err != nil {
		return err
	}

	for _, e := range idx.Entries {
		i[e.Hash] = int64(e.Offset)
	}

	return nil
}
示例#2
0
func getOffsetsFromIdx(r io.Reader) map[plumbing.Hash]int64 {
	idx := &idxfile.Idxfile{}
	err := idxfile.NewDecoder(r).Decode(idx)
	if err != nil {
		panic(err)
	}

	offsets := make(map[plumbing.Hash]int64)
	for _, e := range idx.Entries {
		offsets[e.Hash] = int64(e.Offset)
	}

	return offsets
}