Skip to content

Commit eab8bf2

Browse files
dreamergitster
authored andcommitted
builtin/hash-object: convert to struct object_id
Signed-off-by: Patryk Obara <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b3622a4 commit eab8bf2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

builtin/hash-object.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
* needs to bypass the data conversion performed by, and the type
1717
* limitation imposed by, index_fd() and its callees.
1818
*/
19-
static int hash_literally(unsigned char *sha1, int fd, const char *type, unsigned flags)
19+
static int hash_literally(struct object_id *oid, int fd, const char *type, unsigned flags)
2020
{
2121
struct strbuf buf = STRBUF_INIT;
2222
int ret;
2323

2424
if (strbuf_read(&buf, fd, 4096) < 0)
2525
ret = -1;
2626
else
27-
ret = hash_sha1_file_literally(buf.buf, buf.len, type, sha1, flags);
27+
ret = hash_sha1_file_literally(buf.buf, buf.len, type, oid->hash, flags);
2828
strbuf_release(&buf);
2929
return ret;
3030
}
@@ -33,16 +33,16 @@ static void hash_fd(int fd, const char *type, const char *path, unsigned flags,
3333
int literally)
3434
{
3535
struct stat st;
36-
unsigned char sha1[20];
36+
struct object_id oid;
3737

3838
if (fstat(fd, &st) < 0 ||
3939
(literally
40-
? hash_literally(sha1, fd, type, flags)
41-
: index_fd(sha1, fd, &st, type_from_string(type), path, flags)))
40+
? hash_literally(&oid, fd, type, flags)
41+
: index_fd(oid.hash, fd, &st, type_from_string(type), path, flags)))
4242
die((flags & HASH_WRITE_OBJECT)
4343
? "Unable to add %s to database"
4444
: "Unable to hash %s", path);
45-
printf("%s\n", sha1_to_hex(sha1));
45+
printf("%s\n", oid_to_hex(&oid));
4646
maybe_flush_or_die(stdout, "hash to stdout");
4747
}
4848

0 commit comments

Comments
 (0)