MCPcopy Create free account
hub / github.com/git/git / clear_midx_files

Function clear_midx_files

midx-write.c:1110–1145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1108}
1109
1110static void clear_midx_files(struct odb_source *source,
1111 const struct strvec *hashes, unsigned incremental)
1112{
1113 /*
1114 * if incremental:
1115 * - remove all non-incremental MIDX files
1116 * - remove any incremental MIDX files not in the current one
1117 *
1118 * if non-incremental:
1119 * - remove all incremental MIDX files
1120 * - remove any non-incremental MIDX files not matching the current
1121 * hash
1122 */
1123 struct strbuf buf = STRBUF_INIT;
1124 const char *exts[] = { MIDX_EXT_BITMAP, MIDX_EXT_REV, MIDX_EXT_MIDX };
1125 uint32_t i;
1126
1127 for (i = 0; i < ARRAY_SIZE(exts); i++) {
1128 clear_incremental_midx_files_ext(source, exts[i], hashes);
1129 if (hashes) {
1130 for (size_t j = 0; j < hashes->nr; j++)
1131 clear_midx_files_ext(source, exts[i],
1132 hashes->v[j]);
1133 }
1134 }
1135
1136 if (incremental)
1137 get_midx_filename(source, &buf);
1138 else
1139 get_midx_chain_filename(source, &buf);
1140
1141 if (unlink(buf.buf) && errno != ENOENT)
1142 die_errno(_("failed to clear multi-pack-index at %s"), buf.buf);
1143
1144 strbuf_release(&buf);
1145}
1146
1147static bool midx_needs_update(struct multi_pack_index *midx, struct write_midx_context *ctx)
1148{

Callers 1

write_midx_internalFunction · 0.85

Calls 6

clear_midx_files_extFunction · 0.85
get_midx_filenameFunction · 0.85
get_midx_chain_filenameFunction · 0.85
die_errnoFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected