100
struct string_list *to_include;
101
};
102
103
+static int should_include_pack(const struct write_midx_context *ctx,
104
+ const char *file_name)
105
+{
106
+ /*
107
+ * Note that at most one of ctx->m and ctx->to_include are set,
108
+ * so we are testing midx_contains_pack() and
109
+ * string_list_has_string() independently (guarded by the
110
+ * appropriate NULL checks).
111
+ *
112
+ * We could support passing to_include while reusing an existing
113
+ * MIDX, but don't currently since the reuse process drags
114
+ * forward all packs from an existing MIDX (without checking
115
+ * whether or not they appear in the to_include list).
116
+ *
117
+ * If we added support for that, these next two conditional
118
+ * should be performed independently (likely checking
119
+ * to_include before the existing MIDX).
120
+ */
121
+ if (ctx->m && midx_contains_pack(ctx->m, file_name))
122
+ return 0;
123
+ else if (ctx->to_include &&
124
+ !string_list_has_string(ctx->to_include, file_name))
125
+ return 0;
126
+ return 1;
127
+}
128
+
129
static void add_pack_to_midx(const char *full_path, size_t full_path_len,
130
const char *file_name, void *data)
131
{
134
135
if (ends_with(file_name, ".idx")) {
136
display_progress(ctx->progress, ++ctx->pack_paths_checked);
111
- /*
112
- * Note that at most one of ctx->m and ctx->to_include are set,
113
- * so we are testing midx_contains_pack() and
114
- * string_list_has_string() independently (guarded by the
115
- * appropriate NULL checks).
116
- *
117
- * We could support passing to_include while reusing an existing
118
- * MIDX, but don't currently since the reuse process drags
119
- * forward all packs from an existing MIDX (without checking
120
- * whether or not they appear in the to_include list).
121
- *
122
- * If we added support for that, these next two conditional
123
- * should be performed independently (likely checking
124
- * to_include before the existing MIDX).
125
- */
126
- if (ctx->m && midx_contains_pack(ctx->m, file_name))
127
- return;
128
- else if (ctx->to_include &&
129
- !string_list_has_string(ctx->to_include, file_name))
137
+
138
+ if (!should_include_pack(ctx, file_name))
139
return;
140
141
ALLOC_GROW(ctx->info, ctx->nr + 1, ctx->alloc);
133
-
142
p = add_packed_git(full_path, full_path_len, 0);
143
if (!p) {
144
warning(_("failed to add packfile '%s'"),