]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/unpack-objects.c
Merge branch 'js/ghwf-setup-msbuild-update'
[thirdparty/git.git] / builtin / unpack-objects.c
index 6e81ca8ca28a67ce3d7bc0d62556fd41eda2ba52..dd4a75e030d219dfb3e5e0eeb59683c14f02fdf0 100644 (file)
@@ -1,6 +1,7 @@
 #include "builtin.h"
 #include "cache.h"
 #include "config.h"
+#include "object-store.h"
 #include "object.h"
 #include "delta.h"
 #include "pack.h"
@@ -23,6 +24,7 @@ static off_t consumed_bytes;
 static off_t max_input_size;
 static git_hash_ctx ctx;
 static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
+static struct progress *progress;
 
 /*
  * When running under --strict mode, objects whose reachability are
@@ -91,6 +93,7 @@ static void use(int bytes)
        consumed_bytes += bytes;
        if (max_input_size && consumed_bytes > max_input_size)
                die(_("pack exceeds maximum allowed size"));
+       display_throughput(progress, consumed_bytes);
 }
 
 static void *get_data(unsigned long size)
@@ -253,7 +256,7 @@ static void write_object(unsigned nr, enum object_type type,
                added_object(nr, type, buf, size);
                free(buf);
 
-               blob = lookup_blob(&obj_list[nr].oid);
+               blob = lookup_blob(the_repository, &obj_list[nr].oid);
                if (blob)
                        blob->object.flags |= FLAG_WRITTEN;
                else
@@ -262,9 +265,11 @@ static void write_object(unsigned nr, enum object_type type,
        } else {
                struct object *obj;
                int eaten;
-               hash_object_file(buf, size, type_name(type), &obj_list[nr].oid);
+               hash_object_file(the_hash_algo, buf, size, type_name(type),
+                                &obj_list[nr].oid);
                added_object(nr, type, buf, size);
-               obj = parse_object_buffer(&obj_list[nr].oid, type, size, buf,
+               obj = parse_object_buffer(the_repository, &obj_list[nr].oid,
+                                         type, size, buf,
                                          &eaten);
                if (!obj)
                        die("invalid %s", type_name(type));
@@ -301,7 +306,7 @@ static void added_object(unsigned nr, enum object_type type,
        struct delta_info *info;
 
        while ((info = *p) != NULL) {
-               if (!oidcmp(&info->base_oid, &obj_list[nr].oid) ||
+               if (oideq(&info->base_oid, &obj_list[nr].oid) ||
                    info->base_offset == obj_list[nr].offset) {
                        *p = info->next;
                        p = &delta_list;
@@ -330,7 +335,7 @@ static int resolve_against_held(unsigned nr, const struct object_id *base,
 {
        struct object *obj;
        struct obj_buffer *obj_buffer;
-       obj = lookup_object(base->hash);
+       obj = lookup_object(the_repository, base);
        if (!obj)
                return 0;
        obj_buffer = lookup_object_buffer(obj);
@@ -482,7 +487,6 @@ static void unpack_one(unsigned nr)
 static void unpack_all(void)
 {
        int i;
-       struct progress *progress = NULL;
        struct pack_header *hdr = fill(sizeof(struct pack_header));
 
        nr_objects = ntohl(hdr->hdr_entries);
@@ -512,7 +516,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
        int i;
        struct object_id oid;
 
-       check_replace_refs = 0;
+       read_replace_refs = 0;
 
        git_config(git_default_config, NULL);
 
@@ -577,7 +581,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
                if (fsck_finish(&fsck_options))
                        die(_("fsck error in pack objects"));
        }
-       if (hashcmp(fill(the_hash_algo->rawsz), oid.hash))
+       if (!hasheq(fill(the_hash_algo->rawsz), oid.hash))
                die("final sha1 did not match");
        use(the_hash_algo->rawsz);