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 <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
brian m. carlson 2018-03-12 02:27:42 +00:00 коммит произвёл Junio C Hamano
Родитель 83eb08020c
Коммит e816caa07b
4 изменённых файлов: 7 добавлений и 7 удалений

Просмотреть файл

@ -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));
}