From 7999b2cf772956466baa8925491d6fb1b0963292 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Tue, 10 Nov 2015 02:22:27 +0000 Subject: Add several uses of get_object_hash. Convert most instances where the sha1 member of struct object is dereferenced to use get_object_hash. Most instances that are passed to functions that have versions taking struct object_id, such as get_sha1_hex/get_oid_hex, or instances that can be trivially converted to use struct object_id instead, are not converted. Signed-off-by: brian m. carlson Signed-off-by: Jeff King --- fsck.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'fsck.c') diff --git a/fsck.c b/fsck.c index e41e753d6..baa7f2989 100644 --- a/fsck.c +++ b/fsck.c @@ -276,7 +276,7 @@ static int report(struct fsck_options *options, struct object *object, return 0; if (options->skiplist && object && - sha1_array_lookup(options->skiplist, object->sha1) >= 0) + sha1_array_lookup(options->skiplist, get_object_hash(*object)) >= 0) return 0; if (msg_type == FSCK_FATAL) @@ -630,7 +630,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer, buffer += 41; parent_line_count++; } - graft = lookup_commit_graft(commit->object.sha1); + graft = lookup_commit_graft(get_object_hash(commit->object)); parent_count = commit_list_count(commit->parents); if (graft) { if (graft->nr_parent == -1 && !parent_count) @@ -696,7 +696,7 @@ static int fsck_tag_buffer(struct tag *tag, const char *data, enum object_type type; buffer = to_free = - read_sha1_file(tag->object.sha1, &type, &size); + read_sha1_file(get_object_hash(tag->object), &type, &size); if (!buffer) return report(options, &tag->object, FSCK_MSG_MISSING_TAG_OBJECT, -- cgit v1.2.1 From f2fd0760f62e79609fef7bfd7ecebb002e8e4ced Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Tue, 10 Nov 2015 02:22:28 +0000 Subject: Convert struct object to object_id struct object is one of the major data structures dealing with object IDs. Convert it to use struct object_id instead of an unsigned char array. Convert get_object_hash to refer to the new member as well. Signed-off-by: brian m. carlson Signed-off-by: Jeff King --- fsck.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'fsck.c') diff --git a/fsck.c b/fsck.c index baa7f2989..f7d65a2cf 100644 --- a/fsck.c +++ b/fsck.c @@ -316,7 +316,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op result = options->walk(&lookup_blob(entry.sha1)->object, OBJ_BLOB, data, options); else { result = error("in tree %s: entry %s has bad mode %.6o", - sha1_to_hex(tree->object.sha1), entry.path, entry.mode); + oid_to_hex(&tree->object.oid), entry.path, entry.mode); } if (result < 0) return result; @@ -373,7 +373,7 @@ int fsck_walk(struct object *obj, void *data, struct fsck_options *options) case OBJ_TAG: return fsck_walk_tag((struct tag *)obj, data, options); default: - error("Unknown object type for %s", sha1_to_hex(obj->sha1)); + error("Unknown object type for %s", oid_to_hex(&obj->oid)); return -1; } } @@ -809,9 +809,9 @@ int fsck_object(struct object *obj, void *data, unsigned long size, int fsck_error_function(struct object *obj, int msg_type, const char *message) { if (msg_type == FSCK_WARN) { - warning("object %s: %s", sha1_to_hex(obj->sha1), message); + warning("object %s: %s", oid_to_hex(&obj->oid), message); return 0; } - error("object %s: %s", sha1_to_hex(obj->sha1), message); + error("object %s: %s", oid_to_hex(&obj->oid), message); return 1; } -- cgit v1.2.1 From ed1c9977cb1b63e4270ad8bdf967a2d02580aa08 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Tue, 10 Nov 2015 02:22:29 +0000 Subject: Remove get_object_hash. Convert all instances of get_object_hash to use an appropriate reference to the hash member of the oid member of struct object. This provides no functional change, as it is essentially a macro substitution. Signed-off-by: brian m. carlson Signed-off-by: Jeff King --- fsck.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'fsck.c') diff --git a/fsck.c b/fsck.c index f7d65a2cf..e6b8c5652 100644 --- a/fsck.c +++ b/fsck.c @@ -276,7 +276,7 @@ static int report(struct fsck_options *options, struct object *object, return 0; if (options->skiplist && object && - sha1_array_lookup(options->skiplist, get_object_hash(*object)) >= 0) + sha1_array_lookup(options->skiplist, object->oid.hash) >= 0) return 0; if (msg_type == FSCK_FATAL) @@ -630,7 +630,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer, buffer += 41; parent_line_count++; } - graft = lookup_commit_graft(get_object_hash(commit->object)); + graft = lookup_commit_graft(commit->object.oid.hash); parent_count = commit_list_count(commit->parents); if (graft) { if (graft->nr_parent == -1 && !parent_count) @@ -696,7 +696,7 @@ static int fsck_tag_buffer(struct tag *tag, const char *data, enum object_type type; buffer = to_free = - read_sha1_file(get_object_hash(tag->object), &type, &size); + read_sha1_file(tag->object.oid.hash, &type, &size); if (!buffer) return report(options, &tag->object, FSCK_MSG_MISSING_TAG_OBJECT, -- cgit v1.2.1