summaryrefslogtreecommitdiff
path: root/pack-bitmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'pack-bitmap.c')
-rw-r--r--pack-bitmap.c91
1 files changed, 86 insertions, 5 deletions
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 1ebe0c8162..bfc10148f5 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -13,6 +13,7 @@
#include "repository.h"
#include "object-store.h"
#include "list-objects-filter-options.h"
+#include "config.h"
/*
* An entry on the bitmap index, representing the bitmap for a given
@@ -524,6 +525,22 @@ static int should_include(struct commit *commit, void *_data)
return 1;
}
+static int should_include_obj(struct object *obj, void *_data)
+{
+ struct include_data *data = _data;
+ int bitmap_pos;
+
+ bitmap_pos = bitmap_position(data->bitmap_git, &obj->oid);
+ if (bitmap_pos < 0)
+ return 1;
+ if ((data->seen && bitmap_get(data->seen, bitmap_pos)) ||
+ bitmap_get(data->base, bitmap_pos)) {
+ obj->flags |= SEEN;
+ return 0;
+ }
+ return 1;
+}
+
static int add_commit_to_bitmap(struct bitmap_index *bitmap_git,
struct bitmap **base,
struct commit *commit)
@@ -619,6 +636,7 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
incdata.seen = seen;
revs->include_check = should_include;
+ revs->include_check_obj = should_include_obj;
revs->include_check_data = &incdata;
if (prepare_revision_walk(revs))
@@ -630,6 +648,10 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
traverse_commit_list_filtered(filter, revs,
show_commit, show_object,
&show_data, NULL);
+
+ revs->include_check = NULL;
+ revs->include_check_obj = NULL;
+ revs->include_check_data = NULL;
}
return base;
@@ -779,9 +801,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 +930,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 +980,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;
}
@@ -953,7 +1008,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;
@@ -997,6 +1053,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
object_list_insert(object, &wants);
object = parse_object_or_die(get_tagged_oid(tag), NULL);
+ object->flags |= (tag->object.flags & UNINTERESTING);
}
if (object->flags & UNINTERESTING)
@@ -1047,7 +1104,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;
@@ -1350,6 +1408,24 @@ void test_bitmap_walk(struct rev_info *revs)
free_bitmap_index(bitmap_git);
}
+int test_bitmap_commits(struct repository *r)
+{
+ struct bitmap_index *bitmap_git = prepare_bitmap_git(r);
+ struct object_id oid;
+ MAYBE_UNUSED void *value;
+
+ if (!bitmap_git)
+ die("failed to load bitmap indexes");
+
+ kh_foreach(bitmap_git->bitmaps, oid, value, {
+ printf("%s\n", oid_to_hex(&oid));
+ });
+
+ free_bitmap_index(bitmap_git);
+
+ return 0;
+}
+
int rebuild_bitmap(const uint32_t *reposition,
struct ewah_bitmap *source,
struct bitmap *dest)
@@ -1511,3 +1587,8 @@ off_t get_disk_usage_from_bitmap(struct bitmap_index *bitmap_git,
return total;
}
+
+const struct string_list *bitmap_preferred_tips(struct repository *r)
+{
+ return repo_config_get_value_multi(r, "pack.preferbitmaptips");
+}