dir.c: remove an implicit dependency on the_index in pathspec code
[gitweb.git] / builtin / index-pack.c
index b3a5abcf2b0a54853642723972599906843edc54..de311febe3034cb17cb26a57757c144842af8d9f 100644 (file)
@@ -832,7 +832,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
        if (strict || do_fsck_object) {
                read_lock();
                if (type == OBJ_BLOB) {
-                       struct blob *blob = lookup_blob(oid);
+                       struct blob *blob = lookup_blob(the_repository, oid);
                        if (blob)
                                blob->object.flags |= FLAG_CHECKED;
                        else
@@ -851,7 +851,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
                         * we do not need to free the memory here, as the
                         * buf is deleted by the caller.
                         */
-                       obj = parse_object_buffer(oid, type, size, buf,
+                       obj = parse_object_buffer(the_repository, oid, type,
+                                                 size, buf,
                                                  &eaten);
                        if (!obj)
                                die(_("invalid %s"), type_name(type));
@@ -1482,8 +1483,12 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
        } else
                chmod(final_index_name, 0444);
 
-       if (do_fsck_object)
-               add_packed_git(final_index_name, strlen(final_index_name), 0);
+       if (do_fsck_object) {
+               struct packed_git *p;
+               p = add_packed_git(final_index_name, strlen(final_index_name), 0);
+               if (p)
+                       install_packed_git(the_repository, p);
+       }
 
        if (!from_stdin) {
                printf("%s\n", sha1_to_hex(hash));
@@ -1549,12 +1554,13 @@ static void read_v2_anomalous_offsets(struct packed_git *p,
 {
        const uint32_t *idx1, *idx2;
        uint32_t i;
+       const uint32_t hashwords = the_hash_algo->rawsz / sizeof(uint32_t);
 
        /* The address of the 4-byte offset table */
        idx1 = (((const uint32_t *)p->index_data)
                + 2 /* 8-byte header */
                + 256 /* fan out */
-               + 5 * p->num_objects /* 20-byte SHA-1 table */
+               + hashwords * p->num_objects /* object ID table */
                + p->num_objects /* CRC32 table */
                );