Skip to content

Commit ad7b8a7

Browse files
committed
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
2 parents a4d4427 + f3c23db commit ad7b8a7

File tree

5 files changed

+234
-160
lines changed

5 files changed

+234
-160
lines changed

builtin/pack-objects.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2929,11 +2929,13 @@ static int pack_options_allow_reuse(void)
29292929

29302930
static int get_object_list_from_bitmap(struct rev_info *revs)
29312931
{
2932-
if (prepare_bitmap_walk(revs) < 0)
2932+
struct bitmap_index *bitmap_git;
2933+
if (!(bitmap_git = prepare_bitmap_walk(revs)))
29332934
return -1;
29342935

29352936
if (pack_options_allow_reuse() &&
29362937
!reuse_partial_packfile_from_bitmap(
2938+
bitmap_git,
29372939
&reuse_packfile,
29382940
&reuse_packfile_objects,
29392941
&reuse_packfile_offset)) {
@@ -2942,7 +2944,8 @@ static int get_object_list_from_bitmap(struct rev_info *revs)
29422944
display_progress(progress_state, nr_result);
29432945
}
29442946

2945-
traverse_bitmap_commit_list(&add_object_entry_from_bitmap);
2947+
traverse_bitmap_commit_list(bitmap_git, &add_object_entry_from_bitmap);
2948+
free_bitmap_index(bitmap_git);
29462949
return 0;
29472950
}
29482951

builtin/rev-list.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "reflog-walk.h"
1818
#include "oidset.h"
1919
#include "packfile.h"
20+
#include "object-store.h"
2021

2122
static const char rev_list_usage[] =
2223
"git rev-list [OPTION] <commit-id>... [ -- paths... ]\n"
@@ -515,17 +516,21 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
515516
if (revs.count && !revs.left_right && !revs.cherry_mark) {
516517
uint32_t commit_count;
517518
int max_count = revs.max_count;
518-
if (!prepare_bitmap_walk(&revs)) {
519-
count_bitmap_commit_list(&commit_count, NULL, NULL, NULL);
519+
struct bitmap_index *bitmap_git;
520+
if ((bitmap_git = prepare_bitmap_walk(&revs))) {
521+
count_bitmap_commit_list(bitmap_git, &commit_count, NULL, NULL, NULL);
520522
if (max_count >= 0 && max_count < commit_count)
521523
commit_count = max_count;
522524
printf("%d\n", commit_count);
525+
free_bitmap_index(bitmap_git);
523526
return 0;
524527
}
525528
} else if (revs.max_count < 0 &&
526529
revs.tag_objects && revs.tree_objects && revs.blob_objects) {
527-
if (!prepare_bitmap_walk(&revs)) {
528-
traverse_bitmap_commit_list(&show_object_fast);
530+
struct bitmap_index *bitmap_git;
531+
if ((bitmap_git = prepare_bitmap_walk(&revs))) {
532+
traverse_bitmap_commit_list(bitmap_git, &show_object_fast);
533+
free_bitmap_index(bitmap_git);
529534
return 0;
530535
}
531536
}

pack-bitmap-write.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,17 @@ static int date_compare(const void *_a, const void *_b)
361361

362362
void bitmap_writer_reuse_bitmaps(struct packing_data *to_pack)
363363
{
364-
if (prepare_bitmap_git() < 0)
364+
struct bitmap_index *bitmap_git;
365+
if (!(bitmap_git = prepare_bitmap_git()))
365366
return;
366367

367368
writer.reused = kh_init_sha1();
368-
rebuild_existing_bitmaps(to_pack, writer.reused, writer.show_progress);
369+
rebuild_existing_bitmaps(bitmap_git, to_pack, writer.reused,
370+
writer.show_progress);
371+
/*
372+
* NEEDSWORK: rebuild_existing_bitmaps() makes writer.reused reference
373+
* some bitmaps in bitmap_git, so we can't free the latter.
374+
*/
369375
}
370376

371377
static struct ewah_bitmap *find_reused_bitmap(const unsigned char *sha1)

0 commit comments

Comments
 (0)