1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-06 14:36:18 +02:00

Merge branch 'jk/bitmap-tree-optim'

Avoid duplicated work while building reachability bitmaps.

* jk/bitmap-tree-optim:
  bitmaps: don't recurse into trees already in the bitmap
This commit is contained in:
Junio C Hamano 2021-07-08 13:15:00 -07:00
commit 1ef488eaaa
3 changed files with 22 additions and 0 deletions

View File

@ -164,6 +164,9 @@ static void process_tree(struct traversal_context *ctx,
die("bad tree object");
if (obj->flags & (UNINTERESTING | SEEN))
return;
if (revs->include_check_obj &&
!revs->include_check_obj(&tree->object, revs->include_check_data))
return;
failed_parse = parse_tree_gently(tree, 1);
if (failed_parse) {

View File

@ -525,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)
@ -620,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))
@ -633,6 +650,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;
}

View File

@ -262,6 +262,7 @@ struct rev_info {
int min_parents;
int max_parents;
int (*include_check)(struct commit *, void *);
int (*include_check_obj)(struct object *obj, void *);
void *include_check_data;
/* diff info for patches and for paths limiting */