summaryrefslogtreecommitdiff
path: root/pack-bitmap.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-05-07 03:47:40 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-05-07 03:47:41 (GMT)
commit8585d6c04aa903526b4b3554e90d6381ec62390a (patch)
tree46b5e9bc6ee2b452f215febcf9ee0aedad730739 /pack-bitmap.c
parent826ef0e5e510ecf39a06e8c08ae6e221bdfd5db3 (diff)
parent9cf68b27d50c29a0370bd61581d350b0b0a18e85 (diff)
downloadgit-8585d6c04aa903526b4b3554e90d6381ec62390a.zip
git-8585d6c04aa903526b4b3554e90d6381ec62390a.tar.gz
git-8585d6c04aa903526b4b3554e90d6381ec62390a.tar.bz2
Merge branch 'ps/rev-list-object-type-filter'
"git rev-list" learns the "--filter=object:type=<type>" option, which can be used to exclude objects of the given kind from the packfile generated by pack-objects. * ps/rev-list-object-type-filter: rev-list: allow filtering of provided items pack-bitmap: implement combined filter pack-bitmap: implement object type filter list-objects: implement object type filter list-objects: support filtering by tag and commit list-objects: move tag processing into its own function revision: mark commit parents as NOT_USER_GIVEN uploadpack.txt: document implication of `uploadpackfilter.allow`
Diffstat (limited to 'pack-bitmap.c')
-rw-r--r--pack-bitmap.c45
1 files changed, 40 insertions, 5 deletions
diff --git a/pack-bitmap.c b/pack-bitmap.c
index f2b59fb..d90e1d9 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -783,9 +783,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,
@@ -915,6 +912,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,
@@ -947,6 +962,24 @@ 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;
+ }
+
+ if (filter->choice == LOFC_COMBINE) {
+ int i;
+ for (i = 0; i < filter->sub_nr; i++) {
+ if (filter_bitmap(bitmap_git, tip_objects, to_filter,
+ &filter->sub[i]) < 0)
+ return -1;
+ }
+ return 0;
+ }
+
/* filter choice not handled */
return -1;
}
@@ -957,7 +990,8 @@ static int can_filter_bitmap(struct list_objects_filter_options *filter)
}
struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
- struct list_objects_filter_options *filter)
+ struct list_objects_filter_options *filter,
+ int filter_provided_objects)
{
unsigned int i;
@@ -1052,7 +1086,8 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
if (haves_bitmap)
bitmap_and_not(wants_bitmap, haves_bitmap);
- filter_bitmap(bitmap_git, wants, wants_bitmap, filter);
+ filter_bitmap(bitmap_git, (filter && filter_provided_objects) ? NULL : wants,
+ wants_bitmap, filter);
bitmap_git->result = wants_bitmap;
bitmap_git->haves = haves_bitmap;