Skip to content

Commit

Permalink
sha1_file: convert read_loose_object to use struct object_id
Browse files Browse the repository at this point in the history
Signed-off-by: brian m. carlson <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
bk2204 authored and gitster committed Mar 14, 2018
1 parent af8caf3 commit d61d87b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion builtin/fsck.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ static struct object *parse_loose_object(const struct object_id *oid,
unsigned long size;
int eaten;

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

if (!contents && type != OBJ_BLOB)
Expand Down
4 changes: 2 additions & 2 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -1241,14 +1241,14 @@ extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned l
extern int finalize_object_file(const char *tmpfile, const char *filename);

/*
* Open the loose object at path, check its sha1, and return the contents,
* Open the loose object at path, check its hash, and return the contents,
* type, and size. If the object is a blob, then "contents" may return NULL,
* to allow streaming of large blobs.
*
* Returns 0 on success, negative on error (details may be written to stderr).
*/
int read_loose_object(const char *path,
const unsigned char *expected_sha1,
const struct object_id *expected_oid,
enum object_type *type,
unsigned long *size,
void **contents);
Expand Down
10 changes: 5 additions & 5 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2176,7 +2176,7 @@ static int check_stream_sha1(git_zstream *stream,
}

int read_loose_object(const char *path,
const unsigned char *expected_sha1,
const struct object_id *expected_oid,
enum object_type *type,
unsigned long *size,
void **contents)
Expand Down Expand Up @@ -2208,19 +2208,19 @@ int read_loose_object(const char *path,
}

if (*type == OBJ_BLOB) {
if (check_stream_sha1(&stream, hdr, *size, path, expected_sha1) < 0)
if (check_stream_sha1(&stream, hdr, *size, path, expected_oid->hash) < 0)
goto out;
} else {
*contents = unpack_sha1_rest(&stream, hdr, *size, expected_sha1);
*contents = unpack_sha1_rest(&stream, hdr, *size, expected_oid->hash);
if (!*contents) {
error("unable to unpack contents of %s", path);
git_inflate_end(&stream);
goto out;
}
if (check_sha1_signature(expected_sha1, *contents,
if (check_sha1_signature(expected_oid->hash, *contents,
*size, type_name(*type))) {
error("sha1 mismatch for %s (expected %s)", path,
sha1_to_hex(expected_sha1));
oid_to_hex(expected_oid));
free(*contents);
goto out;
}
Expand Down

0 comments on commit d61d87b

Please sign in to comment.