]> git.ipfire.org Git - thirdparty/git.git/blobdiff - object.c
l10n: zh_CN v2.38.0 rounds 1 & 2
[thirdparty/git.git] / object.c
index 588b8156f1d634a5cb9c25038961ca9a0d28d255..2e4589bae50105da847ad5b861d1752fb26dec77 100644 (file)
--- a/object.c
+++ b/object.c
@@ -263,8 +263,11 @@ struct object *parse_object_or_die(const struct object_id *oid,
        die(_("unable to parse object: %s"), name ? name : oid_to_hex(oid));
 }
 
-struct object *parse_object(struct repository *r, const struct object_id *oid)
+struct object *parse_object_with_flags(struct repository *r,
+                                      const struct object_id *oid,
+                                      enum parse_object_flags flags)
 {
+       int skip_hash = !!(flags & PARSE_OBJECT_SKIP_HASH_CHECK);
        unsigned long size;
        enum object_type type;
        int eaten;
@@ -276,10 +279,16 @@ struct object *parse_object(struct repository *r, const struct object_id *oid)
        if (obj && obj->parsed)
                return obj;
 
+       if (skip_hash) {
+               struct commit *commit = lookup_commit_in_graph(r, repl);
+               if (commit)
+                       return &commit->object;
+       }
+
        if ((obj && obj->type == OBJ_BLOB && repo_has_object_file(r, oid)) ||
            (!obj && repo_has_object_file(r, oid) &&
             oid_object_info(r, oid, NULL) == OBJ_BLOB)) {
-               if (stream_object_signature(r, repl) < 0) {
+               if (!skip_hash && stream_object_signature(r, repl) < 0) {
                        error(_("hash mismatch %s"), oid_to_hex(oid));
                        return NULL;
                }
@@ -289,7 +298,8 @@ struct object *parse_object(struct repository *r, const struct object_id *oid)
 
        buffer = repo_read_object_file(r, oid, &type, &size);
        if (buffer) {
-               if (check_object_signature(r, repl, buffer, size, type) < 0) {
+               if (!skip_hash &&
+                   check_object_signature(r, repl, buffer, size, type) < 0) {
                        free(buffer);
                        error(_("hash mismatch %s"), oid_to_hex(repl));
                        return NULL;
@@ -304,6 +314,11 @@ struct object *parse_object(struct repository *r, const struct object_id *oid)
        return NULL;
 }
 
+struct object *parse_object(struct repository *r, const struct object_id *oid)
+{
+       return parse_object_with_flags(r, oid, 0);
+}
+
 struct object_list *object_list_insert(struct object *item,
                                       struct object_list **list_p)
 {