Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
builtin/hash-object: convert to struct object_id
author
Patryk Obara
<patryk.obara@gmail.com>
Sun, 20 Aug 2017 20:09:26 +0000
(22:09 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 21 Aug 2017 04:50:23 +0000
(21:50 -0700)
Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/hash-object.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
b3622a4
)
diff --git
a/builtin/hash-object.c
b/builtin/hash-object.c
index d04baf999a94cfa6a07e74861876d6a9f1c88a6d..1c0f0f332796f00bbd2705c0eb67aeab2be3809b 100644
(file)
--- a/
builtin/hash-object.c
+++ b/
builtin/hash-object.c
@@
-16,7
+16,7
@@
* needs to bypass the data conversion performed by, and the type
* limitation imposed by, index_fd() and its callees.
*/
* needs to bypass the data conversion performed by, and the type
* limitation imposed by, index_fd() and its callees.
*/
-static int hash_literally(
unsigned char *sha1
, int fd, const char *type, unsigned flags)
+static int hash_literally(
struct object_id *oid
, int fd, const char *type, unsigned flags)
{
struct strbuf buf = STRBUF_INIT;
int ret;
{
struct strbuf buf = STRBUF_INIT;
int ret;
@@
-24,7
+24,7
@@
static int hash_literally(unsigned char *sha1, int fd, const char *type, unsigne
if (strbuf_read(&buf, fd, 4096) < 0)
ret = -1;
else
if (strbuf_read(&buf, fd, 4096) < 0)
ret = -1;
else
- ret = hash_sha1_file_literally(buf.buf, buf.len, type,
sha1
, flags);
+ ret = hash_sha1_file_literally(buf.buf, buf.len, type,
oid->hash
, flags);
strbuf_release(&buf);
return ret;
}
strbuf_release(&buf);
return ret;
}
@@
-33,16
+33,16
@@
static void hash_fd(int fd, const char *type, const char *path, unsigned flags,
int literally)
{
struct stat st;
int literally)
{
struct stat st;
-
unsigned char sha1[20]
;
+
struct object_id oid
;
if (fstat(fd, &st) < 0 ||
(literally
if (fstat(fd, &st) < 0 ||
(literally
- ? hash_literally(
sha1
, fd, type, flags)
- : index_fd(
sha1
, fd, &st, type_from_string(type), path, flags)))
+ ? hash_literally(
&oid
, fd, type, flags)
+ : index_fd(
oid.hash
, fd, &st, type_from_string(type), path, flags)))
die((flags & HASH_WRITE_OBJECT)
? "Unable to add %s to database"
: "Unable to hash %s", path);
die((flags & HASH_WRITE_OBJECT)
? "Unable to add %s to database"
: "Unable to hash %s", path);
- printf("%s\n",
sha1_to_hex(sha1
));
+ printf("%s\n",
oid_to_hex(&oid
));
maybe_flush_or_die(stdout, "hash to stdout");
}
maybe_flush_or_die(stdout, "hash to stdout");
}