int in_same_island(const struct object_id *trg_oid, const struct object_id *src_oid) { khiter_t trg_pos, src_pos; /* If we aren't using islands, assume everything goes together. */ if (!island_marks) return 1; /* * If we don't have a bitmap for the target, we can delta it * against anything -- it's not an important object */ trg_pos = kh_get_sha1(island_marks, trg_oid->hash); if (trg_pos >= kh_end(island_marks)) return 1; /* * if the source (our delta base) doesn't have a bitmap, * we don't want to base any deltas on it! */ src_pos = kh_get_sha1(island_marks, src_oid->hash); if (src_pos >= kh_end(island_marks)) return 0; return island_bitmap_is_subset(kh_value(island_marks, trg_pos), kh_value(island_marks, src_pos)); }
int island_delta_cmp(const struct object_id *a, const struct object_id *b) { khiter_t a_pos, b_pos; struct island_bitmap *a_bitmap = NULL, *b_bitmap = NULL; if (!island_marks) return 0; a_pos = kh_get_sha1(island_marks, a->hash); if (a_pos < kh_end(island_marks)) a_bitmap = kh_value(island_marks, a_pos); b_pos = kh_get_sha1(island_marks, b->hash); if (b_pos < kh_end(island_marks)) b_bitmap = kh_value(island_marks, b_pos); if (a_bitmap) { if (!b_bitmap || !island_bitmap_is_subset(a_bitmap, b_bitmap)) return -1; } if (b_bitmap) { if (!a_bitmap || !island_bitmap_is_subset(b_bitmap, a_bitmap)) return 1; } return 0; }
static struct ewah_bitmap *find_reused_bitmap(const unsigned char *sha1) { khiter_t hash_pos; if (!writer.reused) return NULL; hash_pos = kh_get_sha1(writer.reused, sha1); if (hash_pos >= kh_end(writer.reused)) return NULL; return kh_value(writer.reused, hash_pos); }
static int add_to_include_set(struct bitmap *base, struct commit *commit) { khiter_t hash_pos; uint32_t bitmap_pos = find_object_pos(commit->object.sha1); if (bitmap_get(base, bitmap_pos)) return 0; hash_pos = kh_get_sha1(writer.bitmaps, commit->object.sha1); if (hash_pos < kh_end(writer.bitmaps)) { struct bitmapped_commit *bc = kh_value(writer.bitmaps, hash_pos); bitmap_or_ewah(base, bc->bitmap); return 0; } bitmap_set(base, bitmap_pos); return 1; }
void resolve_tree_islands(struct repository *r, int progress, struct packing_data *to_pack) { struct progress *progress_state = NULL; struct tree_islands_todo *todo; int nr = 0; int i; if (!island_marks) return; /* * We process only trees, as commits and tags have already been handled * (and passed their marks on to root trees, as well. We must make sure * to process them in descending tree-depth order so that marks * propagate down the tree properly, even if a sub-tree is found in * multiple parent trees. */ ALLOC_ARRAY(todo, to_pack->nr_objects); for (i = 0; i < to_pack->nr_objects; i++) { if (oe_type(&to_pack->objects[i]) == OBJ_TREE) { todo[nr].entry = &to_pack->objects[i]; todo[nr].depth = oe_tree_depth(to_pack, &to_pack->objects[i]); nr++; } } QSORT(todo, nr, tree_depth_compare); if (progress) progress_state = start_progress(_("Propagating island marks"), nr); for (i = 0; i < nr; i++) { struct object_entry *ent = todo[i].entry; struct island_bitmap *root_marks; struct tree *tree; struct tree_desc desc; struct name_entry entry; khiter_t pos; pos = kh_get_sha1(island_marks, ent->idx.oid.hash); if (pos >= kh_end(island_marks)) continue; root_marks = kh_value(island_marks, pos); tree = lookup_tree(r, &ent->idx.oid); if (!tree || parse_tree(tree) < 0) die(_("bad tree object %s"), oid_to_hex(&ent->idx.oid)); init_tree_desc(&desc, tree->buffer, tree->size); while (tree_entry(&desc, &entry)) { struct object *obj; if (S_ISGITLINK(entry.mode)) continue; obj = lookup_object(r, entry.oid->hash); if (!obj) continue; set_island_marks(obj, root_marks); } free_tree_buffer(tree); display_progress(progress_state, i+1); } stop_progress(&progress_state); free(todo); }