]> git.ipfire.org Git - thirdparty/git.git/blobdiff - packfile.c
bitmap_position_packfile(): convert to new revindex API
[thirdparty/git.git] / packfile.c
index a72c2a261ffeb40015a20727da861ae94eeef7fb..86f5c8dbf6677195ffca0e03f3cf810e84c5f0df 100644 (file)
@@ -148,7 +148,7 @@ int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
                 *  - hash of the packfile
                 *  - file checksum
                 */
-               if (idx_size != 4 * 256 + (size_t)nr * (hashsz + 4) + hashsz + hashsz)
+               if (idx_size != st_add(4 * 256 + hashsz + hashsz, st_mult(nr, hashsz + 4)))
                        return error("wrong index v1 file size in %s", path);
        } else if (version == 2) {
                /*
@@ -164,10 +164,10 @@ int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
                 * variable sized table containing 8-byte entries
                 * for offsets larger than 2^31.
                 */
-               unsigned long min_size = 8 + 4*256 + (size_t)nr*(hashsz + 4 + 4) + hashsz + hashsz;
-               unsigned long max_size = min_size;
+               size_t min_size = st_add(8 + 4*256 + hashsz + hashsz, st_mult(nr, hashsz + 4 + 4));
+               size_t max_size = min_size;
                if (nr)
-                       max_size += ((size_t)nr - 1)*8;
+                       max_size = st_add(max_size, st_mult(nr - 1, 8));
                if (idx_size < min_size || idx_size > max_size)
                        return error("wrong index v2 file size in %s", path);
                if (idx_size != min_size &&
@@ -514,19 +514,8 @@ static int open_packed_git_1(struct packed_git *p)
        ssize_t read_result;
        const unsigned hashsz = the_hash_algo->rawsz;
 
-       if (!p->index_data) {
-               struct multi_pack_index *m;
-               const char *pack_name = pack_basename(p);
-
-               for (m = the_repository->objects->multi_pack_index;
-                    m; m = m->next) {
-                       if (midx_contains_pack(m, pack_name))
-                               break;
-               }
-
-               if (!m && open_pack_index(p))
-                       return error("packfile %s index unavailable", p->pack_name);
-       }
+       if (open_pack_index(p))
+               return error("packfile %s index unavailable", p->pack_name);
 
        if (!pack_max_fds) {
                unsigned int max_fds = get_max_fd_limit();
@@ -567,10 +556,6 @@ static int open_packed_git_1(struct packed_git *p)
                        " supported (try upgrading GIT to a newer version)",
                        p->pack_name, ntohl(hdr.hdr_version));
 
-       /* Skip index checking if in multi-pack-index */
-       if (!p->index_data)
-               return 0;
-
        /* Verify the pack matches its index. */
        if (p->num_objects != ntohl(hdr.hdr_entries))
                return error("packfile %s claims to have %"PRIu32" objects"