builtin/cat-file: support "blob:none" objects filter
Implement support for the "blob:none" filter in git-cat-file(1), which causes us to omit all blobs. Note that this new filter requires us to read the object type via `oid_object_info_extended()` in `batch_object_write()`. But as we try to optimize away reading objects from the database the `data->info.typep` pointer may not be set. We thus have to adapt the logic to conditionally set the pointer in cases where the filter is given. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
eb83e4c64b
commit
3794e9bf98
@@ -482,7 +482,8 @@ static void batch_object_write(const char *obj_name,
|
||||
if (!data->skip_object_info) {
|
||||
int ret;
|
||||
|
||||
if (use_mailmap)
|
||||
if (use_mailmap ||
|
||||
opt->objects_filter.choice == LOFC_BLOB_NONE)
|
||||
data->info.typep = &data->type;
|
||||
|
||||
if (pack)
|
||||
@@ -500,6 +501,14 @@ static void batch_object_write(const char *obj_name,
|
||||
switch (opt->objects_filter.choice) {
|
||||
case LOFC_DISABLED:
|
||||
break;
|
||||
case LOFC_BLOB_NONE:
|
||||
if (data->type == OBJ_BLOB) {
|
||||
if (!opt->all_objects)
|
||||
report_object_status(opt, obj_name,
|
||||
&data->oid, "excluded");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BUG("unsupported objects filter");
|
||||
}
|
||||
@@ -1039,6 +1048,10 @@ int cmd_cat_file(int argc,
|
||||
switch (batch.objects_filter.choice) {
|
||||
case LOFC_DISABLED:
|
||||
break;
|
||||
case LOFC_BLOB_NONE:
|
||||
if (!batch.enabled)
|
||||
usage(_("objects filter only supported in batch mode"));
|
||||
break;
|
||||
default:
|
||||
usagef(_("objects filter not supported: '%s'"),
|
||||
list_object_filter_config_name(batch.objects_filter.choice));
|
||||
|
||||
Reference in New Issue
Block a user