From e816caa07b8acb5c8ed2d467666ca819fb80bc58 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Mon, 12 Mar 2018 02:27:42 +0000 Subject: [PATCH] sha1_file: convert assert_sha1_type to object_id Convert this function to take a pointer to struct object_id and rename it to assert_oid_type. Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- builtin/commit-tree.c | 2 +- cache.h | 2 +- commit.c | 2 +- sha1_file.c | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c index e5bdf57b1e..ecf42191da 100644 --- a/builtin/commit-tree.c +++ b/builtin/commit-tree.c @@ -58,7 +58,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) usage(commit_tree_usage); if (get_oid_commit(argv[i], &oid)) die("Not a valid object name %s", argv[i]); - assert_sha1_type(oid.hash, OBJ_COMMIT); + assert_oid_type(&oid, OBJ_COMMIT); new_parent(lookup_commit(&oid), &parents); continue; } diff --git a/cache.h b/cache.h index 27b5fd8a39..67a04fcd12 100644 --- a/cache.h +++ b/cache.h @@ -1275,7 +1275,7 @@ extern int has_object_file_with_flags(const struct object_id *oid, int flags); */ extern int has_loose_object_nonlocal(const unsigned char *sha1); -extern void assert_sha1_type(const unsigned char *sha1, enum object_type expect); +extern void assert_oid_type(const struct object_id *oid, enum object_type expect); /* Helper to check and "touch" a file */ extern int check_and_freshen_file(const char *fn, int freshen); diff --git a/commit.c b/commit.c index 00c99c7272..6d77787af9 100644 --- a/commit.c +++ b/commit.c @@ -1517,7 +1517,7 @@ int commit_tree_extended(const char *msg, size_t msg_len, int encoding_is_utf8; struct strbuf buffer; - assert_sha1_type(tree->hash, OBJ_TREE); + assert_oid_type(tree, OBJ_TREE); if (memchr(msg, '\0', msg_len)) return error("a NUL byte in commit log message not allowed."); diff --git a/sha1_file.c b/sha1_file.c index cdcba4483b..a307037e88 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1966,13 +1966,13 @@ int read_pack_header(int fd, struct pack_header *header) return 0; } -void assert_sha1_type(const unsigned char *sha1, enum object_type expect) +void assert_oid_type(const struct object_id *oid, enum object_type expect) { - enum object_type type = sha1_object_info(sha1, NULL); + enum object_type type = sha1_object_info(oid->hash, NULL); if (type < 0) - die("%s is not a valid object", sha1_to_hex(sha1)); + die("%s is not a valid object", oid_to_hex(oid)); if (type != expect) - die("%s is not a valid '%s' object", sha1_to_hex(sha1), + die("%s is not a valid '%s' object", oid_to_hex(oid), type_name(expect)); } -- 2.43.2