@@ -306,22 +306,27 @@ func mainImplementation(ctx context.Context, stdout, stderr io.Writer, args []st
306
306
progressMeter = meter .NewProgressMeter (stderr , 100 * time .Millisecond )
307
307
}
308
308
309
- refRoots , err := sizes .CollectReferences (ctx , repo , rg )
310
- if err != nil {
311
- return fmt .Errorf ("determining which reference to scan: %w" , err )
312
- }
313
-
314
- roots := make ([]sizes.Root , 0 , len (refRoots )+ len (flags .Args ()))
315
- for _ , refRoot := range refRoots {
316
- roots = append (roots , refRoot )
317
- }
318
-
319
- for _ , arg := range flags .Args () {
320
- oid , err := repo .ResolveObject (arg )
309
+ var roots []sizes.Root
310
+ // If arguments are provided, use them as explicit roots.
311
+ if len (flags .Args ()) > 0 {
312
+ roots = make ([]sizes.Root , 0 , len (flags .Args ()))
313
+ for _ , arg := range flags .Args () {
314
+ oid , err := repo .ResolveObject (arg )
315
+ if err != nil {
316
+ return fmt .Errorf ("resolving command-line argument %q: %w" , arg , err )
317
+ }
318
+ roots = append (roots , sizes .NewExplicitRoot (arg , oid ))
319
+ }
320
+ } else {
321
+ refs , err := sizes .CollectReferences (ctx , repo , rg )
321
322
if err != nil {
322
- return fmt .Errorf ("resolving command-line argument %q: %w" , arg , err )
323
+ return fmt .Errorf ("determining which reference to scan: %w" , err )
324
+ }
325
+
326
+ roots = make ([]sizes.Root , 0 , len (refs ))
327
+ for _ , ref := range refs {
328
+ roots = append (roots , ref )
323
329
}
324
- roots = append (roots , sizes .NewExplicitRoot (arg , oid ))
325
330
}
326
331
327
332
historySize , err := sizes .ScanRepositoryUsingGraph (
0 commit comments