Merge branch 'po/doc-status-markup'
[gitweb.git] / builtin / unpack-objects.c
index 99cde45879401350355083f773a2ff2b78113d1a..855d94b90ba019ff19832ff49a76d6cc0077e956 100644 (file)
@@ -164,10 +164,10 @@ static unsigned nr_objects;
  * Called only from check_object() after it verified this object
  * is Ok.
  */
-static void write_cached_object(struct object *obj)
+static void write_cached_object(struct object *obj, struct obj_buffer *obj_buf)
 {
        unsigned char sha1[20];
-       struct obj_buffer *obj_buf = lookup_object_buffer(obj);
+
        if (write_sha1_file(obj_buf->buffer, obj_buf->size, typename(obj->type), sha1) < 0)
                die("failed to write object %s", sha1_to_hex(obj->sha1));
        obj->flags |= FLAG_WRITTEN;
@@ -180,6 +180,8 @@ static void write_cached_object(struct object *obj)
  */
 static int check_object(struct object *obj, int type, void *data)
 {
+       struct obj_buffer *obj_buf;
+
        if (!obj)
                return 1;
 
@@ -198,11 +200,15 @@ static int check_object(struct object *obj, int type, void *data)
                return 0;
        }
 
-       if (fsck_object(obj, 1, fsck_error_function))
+       obj_buf = lookup_object_buffer(obj);
+       if (!obj_buf)
+               die("Whoops! Cannot find object '%s'", sha1_to_hex(obj->sha1));
+       if (fsck_object(obj, obj_buf->buffer, obj_buf->size, 1,
+                       fsck_error_function))
                die("Error in object");
        if (fsck_walk(obj, check_object, NULL))
                die("Error on reachable objects of %s", sha1_to_hex(obj->sha1));
-       write_cached_object(obj);
+       write_cached_object(obj, obj_buf);
        return 0;
 }