From eab8bf292b9616772245717ce8069ec1a4354bd4 Mon Sep 17 00:00:00 2001 From: Patryk Obara Date: Sun, 20 Aug 2017 22:09:26 +0200 Subject: builtin/hash-object: convert to struct object_id Signed-off-by: Patryk Obara Signed-off-by: Junio C Hamano --- builtin/hash-object.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'builtin') diff --git a/builtin/hash-object.c b/builtin/hash-object.c index d04baf999a..1c0f0f3327 100644 --- 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. */ -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; @@ -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 - 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; } @@ -33,16 +33,16 @@ static void hash_fd(int fd, const char *type, const char *path, unsigned flags, int literally) { struct stat st; - unsigned char sha1[20]; + struct object_id oid; 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); - printf("%s\n", sha1_to_hex(sha1)); + printf("%s\n", oid_to_hex(&oid)); maybe_flush_or_die(stdout, "hash to stdout"); } -- cgit v1.2.3 From 98e019b067ac8a34e06f9c412f14a080c7c4dc0d Mon Sep 17 00:00:00 2001 From: Patryk Obara Date: Sun, 20 Aug 2017 22:09:28 +0200 Subject: sha1_file: convert index_path to struct object_id Convert all remaining callers as well. Signed-off-by: Patryk Obara Signed-off-by: Junio C Hamano --- builtin/update-index.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/update-index.c b/builtin/update-index.c index 56721cf03d..d562f2ec69 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -280,7 +280,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len fill_stat_cache_info(ce, st); ce->ce_mode = ce_mode_from_stat(old, st->st_mode); - if (index_path(ce->oid.hash, path, st, + if (index_path(&ce->oid, path, st, info_only ? 0 : HASH_WRITE_OBJECT)) { free(ce); return -1; -- cgit v1.2.3 From e3506559d476ccf94c923c30a15500b46204e146 Mon Sep 17 00:00:00 2001 From: Patryk Obara Date: Sun, 20 Aug 2017 22:09:29 +0200 Subject: sha1_file: convert index_fd to struct object_id Convert all remaining callers as well. Signed-off-by: Patryk Obara Signed-off-by: Junio C Hamano --- builtin/difftool.c | 2 +- builtin/hash-object.c | 2 +- builtin/replace.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'builtin') diff --git a/builtin/difftool.c b/builtin/difftool.c index 8864d846f8..b2d3ba7539 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -111,7 +111,7 @@ static int use_wt_file(const char *workdir, const char *name, int fd = open(buf.buf, O_RDONLY); if (fd >= 0 && - !index_fd(wt_oid.hash, fd, &st, OBJ_BLOB, name, 0)) { + !index_fd(&wt_oid, fd, &st, OBJ_BLOB, name, 0)) { if (is_null_oid(oid)) { oidcpy(oid, &wt_oid); use = 1; diff --git a/builtin/hash-object.c b/builtin/hash-object.c index 1c0f0f3327..8a58ce085a 100644 --- a/builtin/hash-object.c +++ b/builtin/hash-object.c @@ -38,7 +38,7 @@ static void hash_fd(int fd, const char *type, const char *path, unsigned flags, if (fstat(fd, &st) < 0 || (literally ? hash_literally(&oid, fd, type, flags) - : index_fd(oid.hash, fd, &st, type_from_string(type), path, flags))) + : index_fd(&oid, fd, &st, type_from_string(type), path, flags))) die((flags & HASH_WRITE_OBJECT) ? "Unable to add %s to database" : "Unable to hash %s", path); diff --git a/builtin/replace.c b/builtin/replace.c index f4a85a165b..3e71a77152 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -269,7 +269,7 @@ static void import_object(struct object_id *oid, enum object_type type, if (fstat(fd, &st) < 0) die_errno("unable to fstat %s", filename); - if (index_fd(oid->hash, fd, &st, type, NULL, flags) < 0) + if (index_fd(oid, fd, &st, type, NULL, flags) < 0) die("unable to write object to database"); /* index_fd close()s fd for us */ } -- cgit v1.2.3 From da77611d73f3173aa49d362bd7b12a608fb34b94 Mon Sep 17 00:00:00 2001 From: Patryk Obara Date: Sun, 20 Aug 2017 22:09:30 +0200 Subject: sha1_file: convert hash_sha1_file_literally to struct object_id Convert all remaining callers as well. Signed-off-by: Patryk Obara Signed-off-by: Junio C Hamano --- builtin/hash-object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/hash-object.c b/builtin/hash-object.c index 8a58ce085a..c532ff9320 100644 --- a/builtin/hash-object.c +++ b/builtin/hash-object.c @@ -24,7 +24,7 @@ static int hash_literally(struct object_id *oid, int fd, const char *type, unsig if (strbuf_read(&buf, fd, 4096) < 0) ret = -1; else - ret = hash_sha1_file_literally(buf.buf, buf.len, type, oid->hash, flags); + ret = hash_sha1_file_literally(buf.buf, buf.len, type, oid, flags); strbuf_release(&buf); return ret; } -- cgit v1.2.3