sha1_file: convert assert_sha1_type to object_id
authorbrian m. carlson <sandals@crustytoothpaste.net>
Mon, 12 Mar 2018 02:27:42 +0000 (02:27 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Mar 2018 16:23:49 +0000 (09:23 -0700)
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>
builtin/commit-tree.c
cache.h
commit.c
sha1_file.c
index e5bdf57b1e14cf54916c7eef077e63edddb28901..ecf42191da10cd2e87360f001d5493e792b9682e 100644 (file)
@@ -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 27b5fd8a397f5622b32ea6fce6c8e635b2b7d75b..67a04fcd122ffb55e061a41376d85fd0d7cd835b 100644 (file)
--- 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);
index 00c99c7272badc2d5a8f16c29db7d4040f5eb4d3..6d77787af98cfa1011553d19ebda94d29cb4fca7 100644 (file)
--- 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.");
index cdcba4483b136cb7904c9a566affec00b181b741..a307037e88066d73b1e05e6bcad2527a5396125a 100644 (file)
@@ -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));
 }