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

Function verify_midx_file

midx.c:921–1059  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

919 } while (0)
920
921int verify_midx_file(struct odb_source *source, unsigned flags)
922{
923 struct repository *r = source->odb->repo;
924 struct pair_pos_vs_id *pairs = NULL;
925 uint32_t i;
926 struct progress *progress = NULL;
927 struct multi_pack_index *m = load_multi_pack_index(source);
928 struct multi_pack_index *curr;
929 verify_midx_error = 0;
930
931 if (!m) {
932 int result = 0;
933 struct stat sb;
934 struct strbuf filename = STRBUF_INIT;
935
936 get_midx_filename(source, &filename);
937
938 if (!stat(filename.buf, &sb)) {
939 error(_("multi-pack-index file exists, but failed to parse"));
940 result = 1;
941 }
942 strbuf_release(&filename);
943 return result;
944 }
945
946 if (!midx_checksum_valid(m))
947 midx_report(_("incorrect checksum"));
948
949 if (flags & MIDX_PROGRESS)
950 progress = start_delayed_progress(r,
951 _("Looking for referenced packfiles"),
952 m->num_packs + m->num_packs_in_base);
953 for (i = 0; i < m->num_packs + m->num_packs_in_base; i++) {
954 if (prepare_midx_pack(m, i))
955 midx_report("failed to load pack in position %d", i);
956
957 display_progress(progress, i + 1);
958 }
959 stop_progress(&progress);
960
961 if (m->num_objects == 0) {
962 midx_report(_("the midx contains no oid"));
963 /*
964 * Remaining tests assume that we have objects, so we can
965 * return here.
966 */
967 goto cleanup;
968 }
969
970 if (flags & MIDX_PROGRESS)
971 progress = start_sparse_progress(r,
972 _("Verifying OID order in multi-pack-index"),
973 m->num_objects - 1);
974
975 for (curr = m; curr; curr = curr->base_midx) {
976 for (i = 0; i < m->num_objects - 1; i++) {
977 struct object_id oid1, oid2;
978

Callers 1

Calls 15

load_multi_pack_indexFunction · 0.85
get_midx_filenameFunction · 0.85
errorFunction · 0.85
strbuf_releaseFunction · 0.85
midx_checksum_validFunction · 0.85
midx_reportFunction · 0.85
start_delayed_progressFunction · 0.85
prepare_midx_packFunction · 0.85
display_progressFunction · 0.85
stop_progressFunction · 0.85
start_sparse_progressFunction · 0.85
nth_midxed_object_oidFunction · 0.85

Tested by

no test coverage detected