summaryrefslogtreecommitdiff
path: root/pack-bitmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'pack-bitmap.c')
-rw-r--r--pack-bitmap.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/pack-bitmap.c b/pack-bitmap.c
index d90e1d9d8c..d999616c9e 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -298,6 +298,11 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
return -1;
}
+ if (!is_pack_valid(packfile)) {
+ close(fd);
+ return -1;
+ }
+
bitmap_git->pack = packfile;
bitmap_git->map_size = xsize_t(st.st_size);
bitmap_git->map = xmmap(NULL, bitmap_git->map_size, PROT_READ, MAP_PRIVATE, fd, 0);
@@ -525,6 +530,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)
@@ -620,6 +641,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))
@@ -633,6 +655,7 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
&show_data, NULL);
revs->include_check = NULL;
+ revs->include_check_obj = NULL;
revs->include_check_data = NULL;
}
@@ -791,8 +814,9 @@ static void filter_bitmap_exclude_type(struct bitmap_index *bitmap_git,
tips = find_tip_objects(bitmap_git, tip_objects, type);
/*
- * We can use the blob type-bitmap to work in whole words
- * for the objects that are actually in the bitmapped packfile.
+ * We can use the type-level bitmap for 'type' to work in whole
+ * words for the objects that are actually in the bitmapped
+ * packfile.
*/
for (i = 0, init_type_iterator(&it, bitmap_git, type);
i < to_filter->word_alloc && ewah_iterator_next(&mask, &it);
@@ -803,9 +827,9 @@ static void filter_bitmap_exclude_type(struct bitmap_index *bitmap_git,
}
/*
- * Clear any blobs that weren't in the packfile (and so would not have
- * been caught by the loop above. We'll have to check them
- * individually.
+ * Clear any objects that weren't in the packfile (and so would
+ * not have been caught by the loop above. We'll have to check
+ * them individually.
*/
for (i = 0; i < eindex->count; i++) {
uint32_t pos = i + bitmap_git->pack->num_objects;