Skip to content

Commit d61d87b

Browse files
bk2204gitster
authored andcommitted
sha1_file: convert read_loose_object to use struct object_id
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent af8caf3 commit d61d87b

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

builtin/fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ static struct object *parse_loose_object(const struct object_id *oid,
513513
unsigned long size;
514514
int eaten;
515515

516-
if (read_loose_object(path, oid->hash, &type, &size, &contents) < 0)
516+
if (read_loose_object(path, oid, &type, &size, &contents) < 0)
517517
return NULL;
518518

519519
if (!contents && type != OBJ_BLOB)

cache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,14 +1241,14 @@ extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned l
12411241
extern int finalize_object_file(const char *tmpfile, const char *filename);
12421242

12431243
/*
1244-
* Open the loose object at path, check its sha1, and return the contents,
1244+
* Open the loose object at path, check its hash, and return the contents,
12451245
* type, and size. If the object is a blob, then "contents" may return NULL,
12461246
* to allow streaming of large blobs.
12471247
*
12481248
* Returns 0 on success, negative on error (details may be written to stderr).
12491249
*/
12501250
int read_loose_object(const char *path,
1251-
const unsigned char *expected_sha1,
1251+
const struct object_id *expected_oid,
12521252
enum object_type *type,
12531253
unsigned long *size,
12541254
void **contents);

sha1_file.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,7 +2176,7 @@ static int check_stream_sha1(git_zstream *stream,
21762176
}
21772177

21782178
int read_loose_object(const char *path,
2179-
const unsigned char *expected_sha1,
2179+
const struct object_id *expected_oid,
21802180
enum object_type *type,
21812181
unsigned long *size,
21822182
void **contents)
@@ -2208,19 +2208,19 @@ int read_loose_object(const char *path,
22082208
}
22092209

22102210
if (*type == OBJ_BLOB) {
2211-
if (check_stream_sha1(&stream, hdr, *size, path, expected_sha1) < 0)
2211+
if (check_stream_sha1(&stream, hdr, *size, path, expected_oid->hash) < 0)
22122212
goto out;
22132213
} else {
2214-
*contents = unpack_sha1_rest(&stream, hdr, *size, expected_sha1);
2214+
*contents = unpack_sha1_rest(&stream, hdr, *size, expected_oid->hash);
22152215
if (!*contents) {
22162216
error("unable to unpack contents of %s", path);
22172217
git_inflate_end(&stream);
22182218
goto out;
22192219
}
2220-
if (check_sha1_signature(expected_sha1, *contents,
2220+
if (check_sha1_signature(expected_oid->hash, *contents,
22212221
*size, type_name(*type))) {
22222222
error("sha1 mismatch for %s (expected %s)", path,
2223-
sha1_to_hex(expected_sha1));
2223+
oid_to_hex(expected_oid));
22242224
free(*contents);
22252225
goto out;
22262226
}

0 commit comments

Comments
 (0)