From: Junio C Hamano Date: Wed, 18 Jul 2018 19:20:30 +0000 (-0700) Subject: Merge branch 'jt/remove-pack-bitmap-global' X-Git-Tag: v2.19.0-rc0~159 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/ad7b8a7c5af3d47b746c9347baca8d4521c9633d?hp=-c Merge branch 'jt/remove-pack-bitmap-global' The effort to move globals to per-repository in-core structure continues. * jt/remove-pack-bitmap-global: pack-bitmap: add free function pack-bitmap: remove bitmap_git global variable --- ad7b8a7c5af3d47b746c9347baca8d4521c9633d diff --combined builtin/pack-objects.c index 69d3d7b82a,896e413007..ebc8cefb53 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@@ -2929,11 -2929,13 +2929,13 @@@ static int pack_options_allow_reuse(voi static int get_object_list_from_bitmap(struct rev_info *revs) { - if (prepare_bitmap_walk(revs) < 0) + struct bitmap_index *bitmap_git; + if (!(bitmap_git = prepare_bitmap_walk(revs))) return -1; if (pack_options_allow_reuse() && !reuse_partial_packfile_from_bitmap( + bitmap_git, &reuse_packfile, &reuse_packfile_objects, &reuse_packfile_offset)) { @@@ -2942,7 -2944,8 +2944,8 @@@ display_progress(progress_state, nr_result); } - traverse_bitmap_commit_list(&add_object_entry_from_bitmap); + traverse_bitmap_commit_list(bitmap_git, &add_object_entry_from_bitmap); + free_bitmap_index(bitmap_git); return 0; } @@@ -2969,7 -2972,7 +2972,7 @@@ static void get_object_list(int ac, con setup_revisions(ac, av, &revs, NULL); /* make sure shallows are read */ - is_repository_shallow(); + is_repository_shallow(the_repository); while (fgets(line, sizeof(line), stdin) != NULL) { int len = strlen(line); @@@ -2987,7 -2990,7 +2990,7 @@@ struct object_id oid; if (get_oid_hex(line + 10, &oid)) die("not an SHA-1 '%s'", line + 10); - register_shallow(&oid); + register_shallow(the_repository, &oid); use_bitmap_index = 0; continue; } @@@ -3299,7 -3302,7 +3302,7 @@@ int cmd_pack_objects(int argc, const ch use_bitmap_index = use_bitmap_index_default; /* "hard" reasons not to use bitmaps; these just won't work at all */ - if (!use_internal_rev_list || (!pack_to_stdout && write_bitmap_index) || is_repository_shallow()) + if (!use_internal_rev_list || (!pack_to_stdout && write_bitmap_index) || is_repository_shallow(the_repository)) use_bitmap_index = 0; if (pack_to_stdout || !rev_list_all) diff --combined builtin/rev-list.c index e9bd4e378a,62776721f3..6fcb0ff6d5 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@@ -6,7 -6,6 +6,7 @@@ #include "list-objects.h" #include "list-objects-filter.h" #include "list-objects-filter-options.h" +#include "object-store.h" #include "pack.h" #include "pack-bitmap.h" #include "builtin.h" @@@ -17,6 -16,7 +17,7 @@@ #include "reflog-walk.h" #include "oidset.h" #include "packfile.h" + #include "object-store.h" static const char rev_list_usage[] = "git rev-list [OPTION] ... [ -- paths... ]\n" @@@ -515,17 -515,21 +516,21 @@@ int cmd_rev_list(int argc, const char * if (revs.count && !revs.left_right && !revs.cherry_mark) { uint32_t commit_count; int max_count = revs.max_count; - if (!prepare_bitmap_walk(&revs)) { - count_bitmap_commit_list(&commit_count, NULL, NULL, NULL); + struct bitmap_index *bitmap_git; + if ((bitmap_git = prepare_bitmap_walk(&revs))) { + count_bitmap_commit_list(bitmap_git, &commit_count, NULL, NULL, NULL); if (max_count >= 0 && max_count < commit_count) commit_count = max_count; printf("%d\n", commit_count); + free_bitmap_index(bitmap_git); return 0; } } else if (revs.max_count < 0 && revs.tag_objects && revs.tree_objects && revs.blob_objects) { - if (!prepare_bitmap_walk(&revs)) { - traverse_bitmap_commit_list(&show_object_fast); + struct bitmap_index *bitmap_git; + if ((bitmap_git = prepare_bitmap_walk(&revs))) { + traverse_bitmap_commit_list(bitmap_git, &show_object_fast); + free_bitmap_index(bitmap_git); return 0; } } diff --combined pack-bitmap-write.c index 953c5dd84d,7896fedd36..d977e9bacb --- a/pack-bitmap-write.c +++ b/pack-bitmap-write.c @@@ -1,5 -1,4 +1,5 @@@ #include "cache.h" +#include "object-store.h" #include "commit.h" #include "tag.h" #include "diff.h" @@@ -361,11 -360,17 +361,17 @@@ static int date_compare(const void *_a void bitmap_writer_reuse_bitmaps(struct packing_data *to_pack) { - if (prepare_bitmap_git() < 0) + struct bitmap_index *bitmap_git; + if (!(bitmap_git = prepare_bitmap_git())) return; writer.reused = kh_init_sha1(); - rebuild_existing_bitmaps(to_pack, writer.reused, writer.show_progress); + rebuild_existing_bitmaps(bitmap_git, to_pack, writer.reused, + writer.show_progress); + /* + * NEEDSWORK: rebuild_existing_bitmaps() makes writer.reused reference + * some bitmaps in bitmap_git, so we can't free the latter. + */ } static struct ewah_bitmap *find_reused_bitmap(const unsigned char *sha1)