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>
brian m. carlson committed
Mar 12, 2018 at 02:27 UTC
e816caa07b8acb5c8ed2d467666ca819fb80bc58
4 files changed
+7
-7
builtin/commit-tree.c
+1
-1
@@ -58,7 +58,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
58
usage(commit_tree_usage);
59
if (get_oid_commit(argv[i], &oid))
60
die("Not a valid object name %s", argv[i]);
61
- assert_sha1_type(oid.hash, OBJ_COMMIT);
61
+ assert_oid_type(&oid, OBJ_COMMIT);
62
new_parent(lookup_commit(&oid), &parents);
63
continue;
64
}
cache.h
+1
-1
@@ -1275,7 +1275,7 @@ extern int has_object_file_with_flags(const struct object_id *oid, int flags);
1275
*/
1276
extern int has_loose_object_nonlocal(const unsigned char *sha1);
1277
1278
-extern void assert_sha1_type(const unsigned char *sha1, enum object_type expect);
1278
+extern void assert_oid_type(const struct object_id *oid, enum object_type expect);
1279
1280
/* Helper to check and "touch" a file */
1281
extern int check_and_freshen_file(const char *fn, int freshen);
commit.c
+1
-1
@@ -1517,7 +1517,7 @@ int commit_tree_extended(const char *msg, size_t msg_len,
1517
int encoding_is_utf8;
1518
struct strbuf buffer;
1519
1520
- assert_sha1_type(tree->hash, OBJ_TREE);
1520
+ assert_oid_type(tree, OBJ_TREE);
1521
1522
if (memchr(msg, '\0', msg_len))
1523
return error("a NUL byte in commit log message not allowed.");
sha1_file.c
+4
-4
@@ -1966,13 +1966,13 @@ int read_pack_header(int fd, struct pack_header *header)
1966
return 0;
1967
}
1968
1969
-void assert_sha1_type(const unsigned char *sha1, enum object_type expect)
1969
+void assert_oid_type(const struct object_id *oid, enum object_type expect)
1970
{
1971
- enum object_type type = sha1_object_info(sha1, NULL);
1971
+ enum object_type type = sha1_object_info(oid->hash, NULL);
1972
if (type < 0)
1973
- die("%s is not a valid object", sha1_to_hex(sha1));
1973
+ die("%s is not a valid object", oid_to_hex(oid));
1974
if (type != expect)
1975
- die("%s is not a valid '%s' object", sha1_to_hex(sha1),
1975
+ die("%s is not a valid '%s' object", oid_to_hex(oid),
1976
type_name(expect));
1977
}
1978