@@ -12,6 +12,8 @@ import (
1212 "path/filepath"
1313 "strconv"
1414 "strings"
15+
16+ "github.com/github/git-sizer/counts"
1517)
1618
1719// The type of an object ("blob", "tree", "commit", "tag", "missing").
@@ -97,7 +99,7 @@ func (repo *Repository) Close() error {
9799type Reference struct {
98100 Refname string
99101 ObjectType ObjectType
100- ObjectSize Count32
102+ ObjectSize counts. Count32
101103 Oid Oid
102104}
103105
@@ -162,7 +164,7 @@ func (iter *ReferenceIter) Next() (Reference, bool, error) {
162164 return Reference {
163165 Refname : refname ,
164166 ObjectType : objectType ,
165- ObjectSize : Count32 (objectSize ),
167+ ObjectSize : counts . Count32 (objectSize ),
166168 Oid : oid ,
167169 }, true , nil
168170}
@@ -215,7 +217,7 @@ func (repo *Repository) NewBatchObjectIter() (*BatchObjectIter, io.WriteCloser,
215217 }, in , nil
216218}
217219
218- func (iter * BatchObjectIter ) Next () (Oid , ObjectType , Count32 , []byte , error ) {
220+ func (iter * BatchObjectIter ) Next () (Oid , ObjectType , counts. Count32 , []byte , error ) {
219221 header , err := iter .f .ReadString ('\n' )
220222 if err != nil {
221223 return Oid {}, "" , 0 , nil , err
@@ -321,7 +323,7 @@ func NotFilter(filter ReferenceFilter) ReferenceFilter {
321323
322324// Parse a `cat-file --batch[-check]` output header line (including
323325// the trailing LF). `spec`, if not "", is used in error messages.
324- func parseBatchHeader (spec string , header string ) (Oid , ObjectType , Count32 , error ) {
326+ func parseBatchHeader (spec string , header string ) (Oid , ObjectType , counts. Count32 , error ) {
325327 header = header [:len (header )- 1 ]
326328 words := strings .Split (header , " " )
327329 if words [len (words )- 1 ] == "missing" {
@@ -340,7 +342,7 @@ func parseBatchHeader(spec string, header string) (Oid, ObjectType, Count32, err
340342 if err != nil {
341343 return Oid {}, "missing" , 0 , err
342344 }
343- return oid , ObjectType (words [1 ]), NewCount32 (size ), nil
345+ return oid , ObjectType (words [1 ]), counts . NewCount32 (size ), nil
344346}
345347
346348type ObjectIter struct {
@@ -443,7 +445,7 @@ func (repo *Repository) NewObjectIter(args ...string) (
443445}
444446
445447// Next returns the next object, or EOF when done.
446- func (l * ObjectIter ) Next () (Oid , ObjectType , Count32 , error ) {
448+ func (l * ObjectIter ) Next () (Oid , ObjectType , counts. Count32 , error ) {
447449 line , err := l .f .ReadString ('\n' )
448450 if err != nil {
449451 return Oid {}, "" , 0 , err
@@ -508,7 +510,7 @@ func (iter *ObjectHeaderIter) Next() (string, string, error) {
508510}
509511
510512type Commit struct {
511- Size Count32
513+ Size counts. Count32
512514 Parents []Oid
513515 Tree Oid
514516}
@@ -548,7 +550,7 @@ func ParseCommit(oid Oid, data []byte) (*Commit, error) {
548550 return nil , fmt .Errorf ("no tree found in commit %s" , oid )
549551 }
550552 return & Commit {
551- Size : NewCount32 (uint64 (len (data ))),
553+ Size : counts . NewCount32 (uint64 (len (data ))),
552554 Parents : parents ,
553555 Tree : tree ,
554556 }, nil
@@ -619,7 +621,7 @@ func (iter *TreeIter) NextEntry() (TreeEntry, bool, error) {
619621}
620622
621623type Tag struct {
622- Size Count32
624+ Size counts. Count32
623625 Referent Oid
624626 ReferentType ObjectType
625627}
@@ -663,7 +665,7 @@ func ParseTag(oid Oid, data []byte) (*Tag, error) {
663665 return nil , fmt .Errorf ("no type found in tag %s" , oid )
664666 }
665667 return & Tag {
666- Size : NewCount32 (uint64 (len (data ))),
668+ Size : counts . NewCount32 (uint64 (len (data ))),
667669 Referent : referent ,
668670 ReferentType : referentType ,
669671 }, nil
0 commit comments