Commit e816caa0 authored by brian m. carlson's avatar brian m. carlson Committed by Junio C Hamano

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's avatarbrian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
parent 83eb0802
......@@ -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;
}
......
......@@ -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);
......
......@@ -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.");
......
......@@ -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));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment