summaryrefslogtreecommitdiff
path: root/builtin/cat-file.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-04-02 13:13:39 +0200
committerJunio C Hamano <gitster@pobox.com>2025-04-07 14:43:50 -0700
commit3794e9bf982cde754a48b569a639bd2e180e754c (patch)
tree8e034bbe0ba3ba151c467082441b5b6421f63f58 /builtin/cat-file.c
parenteb83e4c64b5a3458569593c2ab0c29365f10a82f (diff)
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>
Diffstat (limited to 'builtin/cat-file.c')
-rw-r--r--builtin/cat-file.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 0e2176c449..bcceb646f8 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -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));