summaryrefslogtreecommitdiff
path: root/pack-bitmap.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2021-04-19 11:46:58 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-04-19 21:09:11 (GMT)
commit7ab6aafa582b9c537885d4a6ef2c837323c5014d (patch)
tree774cd7e249f65aabefd29a5b25e8bdcd0e7598cc /pack-bitmap.c
parentb0c42a53c9d36ea69f4d2650001f05e98eb347cb (diff)
downloadgit-7ab6aafa582b9c537885d4a6ef2c837323c5014d.zip
git-7ab6aafa582b9c537885d4a6ef2c837323c5014d.tar.gz
git-7ab6aafa582b9c537885d4a6ef2c837323c5014d.tar.bz2
pack-bitmap: implement object type filter
The preceding commit has added a new object filter for git-rev-list(1) which allows to filter objects by type. Implement the equivalent filter for packfile bitmaps so that we can answer these queries fast. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack-bitmap.c')
-rw-r--r--pack-bitmap.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/pack-bitmap.c b/pack-bitmap.c
index b4513f8..cd3f5c4 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -779,9 +779,6 @@ static void filter_bitmap_exclude_type(struct bitmap_index *bitmap_git,
eword_t mask;
uint32_t i;
- if (type != OBJ_BLOB && type != OBJ_TREE)
- BUG("filter_bitmap_exclude_type: unsupported type '%d'", type);
-
/*
* The non-bitmap version of this filter never removes
* objects which the other side specifically asked for,
@@ -911,6 +908,24 @@ static void filter_bitmap_tree_depth(struct bitmap_index *bitmap_git,
OBJ_BLOB);
}
+static void filter_bitmap_object_type(struct bitmap_index *bitmap_git,
+ struct object_list *tip_objects,
+ struct bitmap *to_filter,
+ enum object_type object_type)
+{
+ if (object_type < OBJ_COMMIT || object_type > OBJ_TAG)
+ BUG("filter_bitmap_object_type given invalid object");
+
+ if (object_type != OBJ_TAG)
+ filter_bitmap_exclude_type(bitmap_git, tip_objects, to_filter, OBJ_TAG);
+ if (object_type != OBJ_COMMIT)
+ filter_bitmap_exclude_type(bitmap_git, tip_objects, to_filter, OBJ_COMMIT);
+ if (object_type != OBJ_TREE)
+ filter_bitmap_exclude_type(bitmap_git, tip_objects, to_filter, OBJ_TREE);
+ if (object_type != OBJ_BLOB)
+ filter_bitmap_exclude_type(bitmap_git, tip_objects, to_filter, OBJ_BLOB);
+}
+
static int filter_bitmap(struct bitmap_index *bitmap_git,
struct object_list *tip_objects,
struct bitmap *to_filter,
@@ -943,6 +958,14 @@ static int filter_bitmap(struct bitmap_index *bitmap_git,
return 0;
}
+ if (filter->choice == LOFC_OBJECT_TYPE) {
+ if (bitmap_git)
+ filter_bitmap_object_type(bitmap_git, tip_objects,
+ to_filter,
+ filter->object_type);
+ return 0;
+ }
+
/* filter choice not handled */
return -1;
}