16
16
* needs to bypass the data conversion performed by, and the type
17
17
* limitation imposed by, index_fd() and its callees.
18
18
*/
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 )
20
20
{
21
21
struct strbuf buf = STRBUF_INIT ;
22
22
int ret ;
23
23
24
24
if (strbuf_read (& buf , fd , 4096 ) < 0 )
25
25
ret = -1 ;
26
26
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 );
28
28
strbuf_release (& buf );
29
29
return ret ;
30
30
}
@@ -33,16 +33,16 @@ static void hash_fd(int fd, const char *type, const char *path, unsigned flags,
33
33
int literally )
34
34
{
35
35
struct stat st ;
36
- unsigned char sha1 [ 20 ] ;
36
+ struct object_id oid ;
37
37
38
38
if (fstat (fd , & st ) < 0 ||
39
39
(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 )))
42
42
die ((flags & HASH_WRITE_OBJECT )
43
43
? "Unable to add %s to database"
44
44
: "Unable to hash %s" , path );
45
- printf ("%s\n" , sha1_to_hex ( sha1 ));
45
+ printf ("%s\n" , oid_to_hex ( & oid ));
46
46
maybe_flush_or_die (stdout , "hash to stdout" );
47
47
}
48
48
0 commit comments