diff options
| author | Jiang Xin <worldhello.net@gmail.com> | 2021-08-03 17:03:35 +0800 |
|---|---|---|
| committer | Jiang Xin <worldhello.net@gmail.com> | 2021-08-03 17:03:35 +0800 |
| commit | 972c9cf6aed660f3b4189a8f2adda505e67110ff (patch) | |
| tree | 350bb2a29eb3360cdf36a30d8c8e7c76c3e61851 /pack-bitmap.c | |
| parent | ae4e099e7cd2fcb7abdcce1b4fe02b40d5e4a61b (diff) | |
| parent | 66262451ec94d30ac4b80eb3123549cf7a788afd (diff) | |
| download | git-972c9cf6aed660f3b4189a8f2adda505e67110ff.tar.gz | |
Merge branch 'master' of github.com:git/git
* 'master' of github.com:git/git: (397 commits)
Git 2.33-rc0
The seventh batch
ci/install-dependencies: handle "sparse" job package installs
ci: run "apt-get update" before "apt-get install"
cache-tree: prefetch in partial clone read-tree
unpack-trees: refactor prefetching code
pack-bitmap: check pack validity when opening bitmap
bundle tests: use test_cmp instead of grep
bundle tests: use ">file" not ": >file"
The sixth batch
doc: pull: fix rebase=false documentation
pack-bitmap: clarify comment in filter_bitmap_exclude_type()
doc: clarify description of 'submodule.recurse'
doc/git-config: simplify "override" advice for FILES section
doc/git-config: clarify GIT_CONFIG environment variable
doc/git-config: explain --file instead of referring to GIT_CONFIG
t0000: fix test if run with TEST_OUTPUT_DIRECTORY
multi-pack-index: fix potential segfault without sub-command
refs/debug: quote prefix
t0000: clear GIT_SKIP_TESTS before running sub-tests
...
Diffstat (limited to 'pack-bitmap.c')
| -rw-r--r-- | pack-bitmap.c | 34 |
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; |
