diff options
author | Taylor Blau <me@ttaylorr.com> | 2021-09-14 18:06:02 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-09-14 16:34:17 -0700 |
commit | a05f02b1d9a1253e11a327c95cd47cbd24317ba6 (patch) | |
tree | 26b061c1fb109237808f4fc04444b07947e906b8 /pack-bitmap.c | |
parent | 73cd7d9420bb7d75207e8149521db375c789a81c (diff) | |
download | git-a05f02b1d9a1253e11a327c95cd47cbd24317ba6.tar.gz |
t/helper/test-bitmap.c: add 'dump-hashes' mode
The pack-bitmap writer code is about to learn how to propagate values
from an existing hash-cache. To prepare, teach the test-bitmap helper to
dump the values from a bitmap's hash-cache extension in order to test
those changes.
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack-bitmap.c')
-rw-r--r-- | pack-bitmap.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/pack-bitmap.c b/pack-bitmap.c index 8504110a4d..04de387318 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -1742,6 +1742,33 @@ int test_bitmap_commits(struct repository *r) return 0; } +int test_bitmap_hashes(struct repository *r) +{ + struct bitmap_index *bitmap_git = prepare_bitmap_git(r); + struct object_id oid; + uint32_t i, index_pos; + + if (!bitmap_git->hashes) + goto cleanup; + + for (i = 0; i < bitmap_num_objects(bitmap_git); i++) { + if (bitmap_is_midx(bitmap_git)) + index_pos = pack_pos_to_midx(bitmap_git->midx, i); + else + index_pos = pack_pos_to_index(bitmap_git->pack, i); + + nth_bitmap_object_oid(bitmap_git, &oid, index_pos); + + printf("%s %"PRIu32"\n", + oid_to_hex(&oid), get_be32(bitmap_git->hashes + index_pos)); + } + +cleanup: + free_bitmap_index(bitmap_git); + + return 0; +} + int rebuild_bitmap(const uint32_t *reposition, struct ewah_bitmap *source, struct bitmap *dest) |