mergetools: add support for guiffy
[gitweb.git] / builtin / index-pack.c
index 7e3e1a461c4469ea0272d9545d7173e984b1ebf4..bda84a92effe41adb1e50a06ff6accac0563d04a 100644 (file)
@@ -49,6 +49,7 @@ struct thread_local {
        int pack_fd;
 };
 
+/* Remember to update object flag allocation in object.h */
 #define FLAG_LINK (1u<<20)
 #define FLAG_CHECKED (1u<<21)
 
@@ -228,7 +229,7 @@ static unsigned check_object(struct object *obj)
                if (type != obj->type)
                        die(_("object %s: expected type %s, found %s"),
                            oid_to_hex(&obj->oid),
-                           typename(obj->type), typename(type));
+                           type_name(obj->type), type_name(type));
                obj->flags |= FLAG_CHECKED;
                return 1;
        }
@@ -448,7 +449,7 @@ static void *unpack_entry_data(off_t offset, unsigned long size,
        int hdrlen;
 
        if (!is_delta_type(type)) {
-               hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", typename(type), size) + 1;
+               hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), size) + 1;
                the_hash_algo->init_fn(&c);
                the_hash_algo->update_fn(&c, hdr, hdrlen);
        } else
@@ -827,7 +828,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
                free(has_data);
        }
 
-       if (strict) {
+       if (strict || do_fsck_object) {
                read_lock();
                if (type == OBJ_BLOB) {
                        struct blob *blob = lookup_blob(oid);
@@ -849,11 +850,11 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
                        obj = parse_object_buffer(oid, type, size, buf,
                                                  &eaten);
                        if (!obj)
-                               die(_("invalid %s"), typename(type));
+                               die(_("invalid %s"), type_name(type));
                        if (do_fsck_object &&
                            fsck_object(obj, buf, size, &fsck_options))
                                die(_("Error in object"));
-                       if (fsck_walk(obj, NULL, &fsck_options))
+                       if (strict && fsck_walk(obj, NULL, &fsck_options))
                                die(_("Not all child objects of %s are reachable"), oid_to_hex(&obj->oid));
 
                        if (obj->type == OBJ_TREE) {
@@ -959,7 +960,7 @@ static void resolve_delta(struct object_entry *delta_obj,
        if (!result->data)
                bad_object(delta_obj->idx.offset, _("failed to apply delta"));
        hash_object_file(result->data, result->size,
-                        typename(delta_obj->real_type), &delta_obj->idx.oid);
+                        type_name(delta_obj->real_type), &delta_obj->idx.oid);
        sha1_object(result->data, NULL, result->size, delta_obj->real_type,
                    &delta_obj->idx.oid);
        counter_lock();
@@ -1378,7 +1379,7 @@ static void fix_unresolved_deltas(struct hashfile *f)
                        continue;
 
                if (check_sha1_signature(d->sha1, base_obj->data,
-                               base_obj->size, typename(type)))
+                               base_obj->size, type_name(type)))
                        die(_("local object %s is corrupt"), sha1_to_hex(d->sha1));
                base_obj->obj = append_obj_to_pack(f, d->sha1,
                                        base_obj->data, base_obj->size, type);
@@ -1615,7 +1616,7 @@ static void show_pack_info(int stat_only)
                        continue;
                printf("%s %-6s %lu %lu %"PRIuMAX,
                       oid_to_hex(&obj->idx.oid),
-                      typename(obj->real_type), obj->size,
+                      type_name(obj->real_type), obj->size,
                       (unsigned long)(obj[1].idx.offset - obj->idx.offset),
                       (uintmax_t)obj->idx.offset);
                if (is_delta_type(obj->type)) {
@@ -1688,6 +1689,8 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
                        } else if (!strcmp(arg, "--check-self-contained-and-connected")) {
                                strict = 1;
                                check_self_contained_and_connected = 1;
+                       } else if (!strcmp(arg, "--fsck-objects")) {
+                               do_fsck_object = 1;
                        } else if (!strcmp(arg, "--verify")) {
                                verify = 1;
                        } else if (!strcmp(arg, "--verify-stat")) {