File tree Expand file tree Collapse file tree 3 files changed +34
-4
lines changed Expand file tree Collapse file tree 3 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,11 @@ OPTIONS
91
91
printed at all. The '<filter-spec>' may be one of the following:
92
92
+
93
93
The form '--filter=blob:none' omits all blobs.
94
+ +
95
+ The form '--filter=blob:limit=<n>[kmg]' omits blobs of size at least n
96
+ bytes or units. n may be zero. The suffixes k, m, and g can be used to name
97
+ units in KiB, MiB, or GiB. For example, 'blob:limit=1k' is the same as
98
+ 'blob:limit=1024' .
94
99
95
100
-- path=<path >::
96
101
For use with `--textconv` or `--filters` , to allow specifying an object
Original file line number Diff line number Diff line change @@ -483,8 +483,11 @@ static void batch_object_write(const char *obj_name,
483
483
int ret ;
484
484
485
485
if (use_mailmap ||
486
- opt -> objects_filter .choice == LOFC_BLOB_NONE )
486
+ opt -> objects_filter .choice == LOFC_BLOB_NONE ||
487
+ opt -> objects_filter .choice == LOFC_BLOB_LIMIT )
487
488
data -> info .typep = & data -> type ;
489
+ if (opt -> objects_filter .choice == LOFC_BLOB_LIMIT )
490
+ data -> info .sizep = & data -> size ;
488
491
489
492
if (pack )
490
493
ret = packed_object_info (the_repository , pack , offset ,
@@ -509,6 +512,15 @@ static void batch_object_write(const char *obj_name,
509
512
return ;
510
513
}
511
514
break ;
515
+ case LOFC_BLOB_LIMIT :
516
+ if (data -> type == OBJ_BLOB &&
517
+ data -> size >= opt -> objects_filter .blob_limit_value ) {
518
+ if (!opt -> all_objects )
519
+ report_object_status (opt , obj_name ,
520
+ & data -> oid , "excluded" );
521
+ return ;
522
+ }
523
+ break ;
512
524
default :
513
525
BUG ("unsupported objects filter" );
514
526
}
@@ -1049,6 +1061,7 @@ int cmd_cat_file(int argc,
1049
1061
case LOFC_DISABLED :
1050
1062
break ;
1051
1063
case LOFC_BLOB_NONE :
1064
+ case LOFC_BLOB_LIMIT :
1052
1065
if (!batch .enabled )
1053
1066
usage (_ ("objects filter only supported in batch mode" ));
1054
1067
break ;
Original file line number Diff line number Diff line change @@ -1356,19 +1356,27 @@ test_expect_success PERL '--batch-command info is unbuffered by default' '
1356
1356
test_expect_success ' setup for objects filter' '
1357
1357
git init repo &&
1358
1358
(
1359
- # Seed the repository with three different sets of objects:
1359
+ # Seed the repository with four different sets of objects:
1360
1360
#
1361
1361
# - The first set is fully packed and has a bitmap.
1362
1362
# - The second set is packed, but has no bitmap.
1363
1363
# - The third set is loose.
1364
+ # - The fourth set is loose and contains big objects.
1364
1365
#
1365
1366
# This ensures that we cover all these types as expected.
1366
1367
cd repo &&
1367
1368
test_commit first &&
1368
1369
git repack -Adb &&
1369
1370
test_commit second &&
1370
1371
git repack -d &&
1371
- test_commit third
1372
+ test_commit third &&
1373
+
1374
+ for n in 1000 10000
1375
+ do
1376
+ printf "%"$n"s" X >large.$n || return 1
1377
+ done &&
1378
+ git add large.* &&
1379
+ git commit -m fourth
1372
1380
)
1373
1381
'
1374
1382
@@ -1380,7 +1388,7 @@ test_expect_success 'objects filter with unknown option' '
1380
1388
test_cmp expect err
1381
1389
'
1382
1390
1383
- for option in blob:limit=1 object:type=tag sparse:oid=1234 tree:1 sparse:path=x
1391
+ for option in object:type=tag sparse:oid=1234 tree:1 sparse:path=x
1384
1392
do
1385
1393
test_expect_success " objects filter with unsupported option $option " '
1386
1394
case "$option" in
@@ -1435,5 +1443,9 @@ test_objects_filter () {
1435
1443
}
1436
1444
1437
1445
test_objects_filter " blob:none"
1446
+ test_objects_filter " blob:limit=1"
1447
+ test_objects_filter " blob:limit=500"
1448
+ test_objects_filter " blob:limit=1000"
1449
+ test_objects_filter " blob:limit=1k"
1438
1450
1439
1451
test_done
You can’t perform that action at this time.
0 commit comments