pack-bitmap.c: extract `fill_in_bitmap()`
To prepare for the boundary-based bitmap walk to perform a fill-in traversal using the boundary of either side as the tips, extract routine used to perform fill-in traversal by `find_objects()` so that it can be used in both places. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
May 8, 2023 at 13:38 UTC
47ff853f02a0b4af6d01727b7e45046b61b0a9b4
1 file changed
+36
-29
pack-bitmap.c
+36
-29
@@ -1043,6 +1043,40 @@ static int add_commit_to_bitmap(struct bitmap_index *bitmap_git,
1043
return 1;
1044
}
1045
1046
+static struct bitmap *fill_in_bitmap(struct bitmap_index *bitmap_git,
1047
+ struct rev_info *revs,
1048
+ struct bitmap *base,
1049
+ struct bitmap *seen)
1050
+{
1051
+ struct include_data incdata;
1052
+ struct bitmap_show_data show_data;
1053
+
1054
+ if (!base)
1055
+ base = bitmap_new();
1056
+
1057
+ incdata.bitmap_git = bitmap_git;
1058
+ incdata.base = base;
1059
+ incdata.seen = seen;
1060
+
1061
+ revs->include_check = should_include;
1062
+ revs->include_check_obj = should_include_obj;
1063
+ revs->include_check_data = &incdata;
1064
+
1065
+ if (prepare_revision_walk(revs))
1066
+ die(_("revision walk setup failed"));
1067
+
1068
+ show_data.bitmap_git = bitmap_git;
1069
+ show_data.base = base;
1070
+
1071
+ traverse_commit_list(revs, show_commit, show_object, &show_data);
1072
+
1073
+ revs->include_check = NULL;
1074
+ revs->include_check_obj = NULL;
1075
+ revs->include_check_data = NULL;
1076
+
1077
+ return base;
1078
+}
1079
+
1080
static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
1081
struct rev_info *revs,
1082
struct object_list *roots,
@@ -1108,35 +1142,8 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
1142
}
1143
}
1144
1111
- if (needs_walk) {
1112
- struct include_data incdata;
1113
- struct bitmap_show_data show_data;
1114
-
1115
- if (!base)
1116
- base = bitmap_new();
1117
-
1118
- incdata.bitmap_git = bitmap_git;
1119
- incdata.base = base;
1120
- incdata.seen = seen;
1121
-
1122
- revs->include_check = should_include;
1123
- revs->include_check_obj = should_include_obj;
1124
- revs->include_check_data = &incdata;
1125
-
1126
- if (prepare_revision_walk(revs))
1127
- die(_("revision walk setup failed"));
1128
-
1129
- show_data.bitmap_git = bitmap_git;
1130
- show_data.base = base;
1131
-
1132
- traverse_commit_list(revs,
1133
- show_commit, show_object,
1134
- &show_data);
1135
-
1136
- revs->include_check = NULL;
1137
- revs->include_check_obj = NULL;
1138
- revs->include_check_data = NULL;
1139
- }
1145
+ if (needs_walk)
1146
+ base = fill_in_bitmap(bitmap_git, revs, base, seen);
1147
1148
return base;
1149
}