summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2021-07-08 13:15:00 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-07-08 13:15:00 -0700
commit1ef488eaaaeba214dd2e03a256e976bd7740fe0a (patch)
tree519b185bd1ceaafdb97518a85ccf38f466110f6b
parentMerge branch 'ah/graph-typofix' (diff)
parentbitmaps: don't recurse into trees already in the bitmap (diff)
downloadtgif-1ef488eaaaeba214dd2e03a256e976bd7740fe0a.tar.xz
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
-rw-r--r--list-objects.c3
-rw-r--r--pack-bitmap.c18
-rw-r--r--revision.h1
3 files changed, 22 insertions, 0 deletions
diff --git a/list-objects.c b/list-objects.c
index 7f404677d5..473a332416 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -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) {
diff --git a/pack-bitmap.c b/pack-bitmap.c
index d90e1d9d8c..bfc10148f5 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -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;
}
diff --git a/revision.h b/revision.h
index 17698cb51a..5c5510d422 100644
--- a/revision.h
+++ b/revision.h
@@ -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 */