@@ -9,11 +9,12 @@ import (
99 "time"
1010
1111 "github.com/github/git-sizer/counts"
12+ "github.com/github/git-sizer/git"
1213 "github.com/github/git-sizer/meter"
1314)
1415
1516func ScanRepositoryUsingGraph (
16- repo * Repository , filter ReferenceFilter , nameStyle NameStyle , progress bool ,
17+ repo * git. Repository , filter git. ReferenceFilter , nameStyle NameStyle , progress bool ,
1718) (HistorySize , error ) {
1819 graph := NewGraph (nameStyle )
1920 var progressMeter meter.Progress
@@ -44,7 +45,7 @@ func ScanRepositoryUsingGraph(
4445 }()
4546
4647 errChan := make (chan error , 1 )
47- var refs []Reference
48+ var refs []git. Reference
4849 // Feed the references that we want into the stdin of the object
4950 // iterator:
5051 go func () {
@@ -82,13 +83,13 @@ func ScanRepositoryUsingGraph(
8283 }()
8384
8485 type ObjectHeader struct {
85- oid Oid
86+ oid git. Oid
8687 objectSize counts.Count32
8788 }
8889
8990 type CommitHeader struct {
9091 ObjectHeader
91- tree Oid
92+ tree git. Oid
9293 }
9394
9495 // We process the blobs right away, but record these other types
@@ -151,7 +152,7 @@ func ScanRepositoryUsingGraph(
151152 case "tree" :
152153 trees = append (trees , ObjectHeader {oid , objectSize })
153154 case "commit" :
154- commits = append (commits , CommitHeader {ObjectHeader {oid , objectSize }, NullOid })
155+ commits = append (commits , CommitHeader {ObjectHeader {oid , objectSize }, git . NullOid })
155156 case "tag" :
156157 tags = append (tags , ObjectHeader {oid , objectSize })
157158 default :
@@ -242,7 +243,7 @@ func ScanRepositoryUsingGraph(
242243 return HistorySize {}, fmt .Errorf ("expected tree; read %#v" , objectType )
243244 }
244245 progressMeter .Inc ()
245- tree , err := ParseTree (oid , data )
246+ tree , err := git . ParseTree (oid , data )
246247 if err != nil {
247248 return HistorySize {}, err
248249 }
@@ -268,7 +269,7 @@ func ScanRepositoryUsingGraph(
268269 if objectType != "commit" {
269270 return HistorySize {}, fmt .Errorf ("expected commit; read %#v" , objectType )
270271 }
271- commit , err := ParseCommit (oid , data )
272+ commit , err := git . ParseCommit (oid , data )
272273 if err != nil {
273274 return HistorySize {}, err
274275 }
@@ -304,7 +305,7 @@ func ScanRepositoryUsingGraph(
304305 if objectType != "tag" {
305306 return HistorySize {}, fmt .Errorf ("expected tag; read %#v" , objectType )
306307 }
307- tag , err := ParseTag (oid , data )
308+ tag , err := git . ParseTag (oid , data )
308309 if err != nil {
309310 return HistorySize {}, err
310311 }
@@ -336,21 +337,21 @@ func ScanRepositoryUsingGraph(
336337
337338// An object graph that is being built up.
338339type Graph struct {
339- repo * Repository
340+ repo * git. Repository
340341
341342 blobLock sync.Mutex
342- blobSizes map [Oid ]BlobSize
343+ blobSizes map [git. Oid ]BlobSize
343344
344345 treeLock sync.Mutex
345- treeRecords map [Oid ]* treeRecord
346- treeSizes map [Oid ]TreeSize
346+ treeRecords map [git. Oid ]* treeRecord
347+ treeSizes map [git. Oid ]TreeSize
347348
348349 commitLock sync.Mutex
349- commitSizes map [Oid ]CommitSize
350+ commitSizes map [git. Oid ]CommitSize
350351
351352 tagLock sync.Mutex
352- tagRecords map [Oid ]* tagRecord
353- tagSizes map [Oid ]TagSize
353+ tagRecords map [git. Oid ]* tagRecord
354+ tagSizes map [git. Oid ]TagSize
354355
355356 // Statistics about the overall history size:
356357 historyLock sync.Mutex
@@ -361,21 +362,21 @@ type Graph struct {
361362
362363func NewGraph (nameStyle NameStyle ) * Graph {
363364 return & Graph {
364- blobSizes : make (map [Oid ]BlobSize ),
365+ blobSizes : make (map [git. Oid ]BlobSize ),
365366
366- treeRecords : make (map [Oid ]* treeRecord ),
367- treeSizes : make (map [Oid ]TreeSize ),
367+ treeRecords : make (map [git. Oid ]* treeRecord ),
368+ treeSizes : make (map [git. Oid ]TreeSize ),
368369
369- commitSizes : make (map [Oid ]CommitSize ),
370+ commitSizes : make (map [git. Oid ]CommitSize ),
370371
371- tagRecords : make (map [Oid ]* tagRecord ),
372- tagSizes : make (map [Oid ]TagSize ),
372+ tagRecords : make (map [git. Oid ]* tagRecord ),
373+ tagSizes : make (map [git. Oid ]TagSize ),
373374
374375 pathResolver : NewPathResolver (nameStyle ),
375376 }
376377}
377378
378- func (g * Graph ) RegisterReference (ref Reference ) {
379+ func (g * Graph ) RegisterReference (ref git. Reference ) {
379380 g .historyLock .Lock ()
380381 g .historySize .recordReference (g , ref )
381382 g .historyLock .Unlock ()
@@ -400,7 +401,7 @@ func (g *Graph) HistorySize() HistorySize {
400401}
401402
402403// Record that the specified `oid` is a blob with the specified size.
403- func (g * Graph ) RegisterBlob (oid Oid , objectSize counts.Count32 ) {
404+ func (g * Graph ) RegisterBlob (oid git. Oid , objectSize counts.Count32 ) {
404405 size := BlobSize {Size : objectSize }
405406 // There are no listeners. Since this is a blob, we know all that
406407 // we need to know about it. So skip the record and just fill in
@@ -423,7 +424,7 @@ func (g *Graph) RegisterBlob(oid Oid, objectSize counts.Count32) {
423424// listener to be informed some time in the future when the size is
424425// known. In this case, return false as the second value.
425426
426- func (g * Graph ) GetBlobSize (oid Oid ) BlobSize {
427+ func (g * Graph ) GetBlobSize (oid git. Oid ) BlobSize {
427428 // See if we already know the size:
428429 size , ok := g .blobSizes [oid ]
429430 if ! ok {
@@ -432,7 +433,7 @@ func (g *Graph) GetBlobSize(oid Oid) BlobSize {
432433 return size
433434}
434435
435- func (g * Graph ) RequireTreeSize (oid Oid , listener func (TreeSize )) (TreeSize , bool ) {
436+ func (g * Graph ) RequireTreeSize (oid git. Oid , listener func (TreeSize )) (TreeSize , bool ) {
436437 g .treeLock .Lock ()
437438
438439 size , ok := g .treeSizes [oid ]
@@ -454,7 +455,7 @@ func (g *Graph) RequireTreeSize(oid Oid, listener func(TreeSize)) (TreeSize, boo
454455 return TreeSize {}, false
455456}
456457
457- func (g * Graph ) GetTreeSize (oid Oid ) TreeSize {
458+ func (g * Graph ) GetTreeSize (oid git. Oid ) TreeSize {
458459 g .treeLock .Lock ()
459460
460461 size , ok := g .treeSizes [oid ]
@@ -466,7 +467,7 @@ func (g *Graph) GetTreeSize(oid Oid) TreeSize {
466467}
467468
468469// Record that the specified `oid` is the specified `tree`.
469- func (g * Graph ) RegisterTree (oid Oid , tree * Tree ) error {
470+ func (g * Graph ) RegisterTree (oid git. Oid , tree * git. Tree ) error {
470471 g .treeLock .Lock ()
471472
472473 if _ , ok := g .treeSizes [oid ]; ok {
@@ -487,7 +488,7 @@ func (g *Graph) RegisterTree(oid Oid, tree *Tree) error {
487488}
488489
489490func (g * Graph ) finalizeTreeSize (
490- oid Oid , size TreeSize , objectSize counts.Count32 , treeEntries counts.Count32 ,
491+ oid git. Oid , size TreeSize , objectSize counts.Count32 , treeEntries counts.Count32 ,
491492) {
492493 g .treeLock .Lock ()
493494 g .treeSizes [oid ] = size
@@ -500,7 +501,7 @@ func (g *Graph) finalizeTreeSize(
500501}
501502
502503type treeRecord struct {
503- oid Oid
504+ oid git. Oid
504505
505506 // Limit to only one mutator at a time.
506507 lock sync.Mutex
@@ -527,7 +528,7 @@ type treeRecord struct {
527528 listeners []func (TreeSize )
528529}
529530
530- func newTreeRecord (oid Oid ) * treeRecord {
531+ func newTreeRecord (oid git. Oid ) * treeRecord {
531532 return & treeRecord {
532533 oid : oid ,
533534 size : TreeSize {ExpandedTreeCount : 1 },
@@ -536,11 +537,11 @@ func newTreeRecord(oid Oid) *treeRecord {
536537}
537538
538539// Initialize `r` (which is empty) based on `tree`.
539- func (r * treeRecord ) initialize (g * Graph , oid Oid , tree * Tree ) error {
540+ func (r * treeRecord ) initialize (g * Graph , oid git. Oid , tree * git. Tree ) error {
540541 r .lock .Lock ()
541542 defer r .lock .Unlock ()
542543
543- r .objectSize = counts . NewCount32 ( uint64 ( len ( tree .data )) )
544+ r .objectSize = tree .Size ( )
544545 r .pending = 0
545546
546547 iter := tree .Iter ()
@@ -624,7 +625,7 @@ func (r *treeRecord) addListener(listener func(TreeSize)) {
624625 r .listeners = append (r .listeners , listener )
625626}
626627
627- func (g * Graph ) GetCommitSize (oid Oid ) CommitSize {
628+ func (g * Graph ) GetCommitSize (oid git. Oid ) CommitSize {
628629 g .commitLock .Lock ()
629630
630631 size , ok := g .commitSizes [oid ]
@@ -637,7 +638,7 @@ func (g *Graph) GetCommitSize(oid Oid) CommitSize {
637638}
638639
639640// Record that the specified `oid` is the specified `commit`.
640- func (g * Graph ) RegisterCommit (oid Oid , commit * Commit ) {
641+ func (g * Graph ) RegisterCommit (oid git. Oid , commit * git. Commit ) {
641642 g .commitLock .Lock ()
642643 if _ , ok := g .commitSizes [oid ]; ok {
643644 panic (fmt .Sprintf ("commit %s registered twice!" , oid ))
@@ -671,7 +672,7 @@ func (g *Graph) RegisterCommit(oid Oid, commit *Commit) {
671672 g .historyLock .Unlock ()
672673}
673674
674- func (g * Graph ) RequireTagSize (oid Oid , listener func (TagSize )) (TagSize , bool ) {
675+ func (g * Graph ) RequireTagSize (oid git. Oid , listener func (TagSize )) (TagSize , bool ) {
675676 g .tagLock .Lock ()
676677
677678 size , ok := g .tagSizes [oid ]
@@ -694,7 +695,7 @@ func (g *Graph) RequireTagSize(oid Oid, listener func(TagSize)) (TagSize, bool)
694695}
695696
696697// Record that the specified `oid` is the specified `tag`.
697- func (g * Graph ) RegisterTag (oid Oid , tag * Tag ) {
698+ func (g * Graph ) RegisterTag (oid git. Oid , tag * git. Tag ) {
698699 g .tagLock .Lock ()
699700
700701 if _ , ok := g .tagSizes [oid ]; ok {
@@ -714,7 +715,7 @@ func (g *Graph) RegisterTag(oid Oid, tag *Tag) {
714715 record .initialize (g , oid , tag )
715716}
716717
717- func (g * Graph ) finalizeTagSize (oid Oid , size TagSize , objectSize counts.Count32 ) {
718+ func (g * Graph ) finalizeTagSize (oid git. Oid , size TagSize , objectSize counts.Count32 ) {
718719 g .tagLock .Lock ()
719720 g .tagSizes [oid ] = size
720721 delete (g .tagRecords , oid )
@@ -726,7 +727,7 @@ func (g *Graph) finalizeTagSize(oid Oid, size TagSize, objectSize counts.Count32
726727}
727728
728729type tagRecord struct {
729- oid Oid
730+ oid git. Oid
730731
731732 // Limit to only one mutator at a time.
732733 lock sync.Mutex
@@ -744,15 +745,15 @@ type tagRecord struct {
744745 listeners []func (TagSize )
745746}
746747
747- func newTagRecord (oid Oid ) * tagRecord {
748+ func newTagRecord (oid git. Oid ) * tagRecord {
748749 return & tagRecord {
749750 oid : oid ,
750751 pending : - 1 ,
751752 }
752753}
753754
754755// Initialize `r` (which is empty) based on `tag`.
755- func (r * tagRecord ) initialize (g * Graph , oid Oid , tag * Tag ) {
756+ func (r * tagRecord ) initialize (g * Graph , oid git. Oid , tag * git. Tag ) {
756757 r .lock .Lock ()
757758 defer r .lock .Unlock ()
758759
0 commit comments