builtin/mktag: convert to struct object_id
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
eedc994f18b608a805b31db0d40c13cce1b970fb
1 file changed
+9
-9
builtin/mktag.c
+9
-9
@@ -18,13 +18,13 @@
18
/*
19
* We refuse to tag something we can't verify. Just because.
20
*/
21
-static int verify_object(const unsigned char *sha1, const char *expected_type)
21
+static int verify_object(const struct object_id *oid, const char *expected_type)
22
{
23
int ret = -1;
24
enum object_type type;
25
unsigned long size;
26
- void *buffer = read_sha1_file(sha1, &type, &size);
27
- const unsigned char *repl = lookup_replace_object(sha1);
26
+ void *buffer = read_sha1_file(oid->hash, &type, &size);
27
+ const unsigned char *repl = lookup_replace_object(oid->hash);
28
29
if (buffer) {
30
if (type == type_from_string(expected_type))
@@ -38,8 +38,8 @@ static int verify_tag(char *buffer, unsigned long size)
38
{
39
int typelen;
40
char type[20];
41
- unsigned char sha1[20];
42
- const char *object, *type_line, *tag_line, *tagger_line, *lb, *rb;
41
+ struct object_id oid;
42
+ const char *object, *type_line, *tag_line, *tagger_line, *lb, *rb, *p;
43
size_t len;
44
45
if (size < 84)
@@ -52,11 +52,11 @@ static int verify_tag(char *buffer, unsigned long size)
52
if (memcmp(object, "object ", 7))
53
return error("char%d: does not start with \"object \"", 0);
54
55
- if (get_sha1_hex(object + 7, sha1))
55
+ if (parse_oid_hex(object + 7, &oid, &p))
56
return error("char%d: could not get SHA1 hash", 7);
57
58
/* Verify type line */
59
- type_line = object + 48;
59
+ type_line = p + 1;
60
if (memcmp(type_line - 1, "\ntype ", 6))
61
return error("char%d: could not find \"\\ntype \"", 47);
62
@@ -80,8 +80,8 @@ static int verify_tag(char *buffer, unsigned long size)
80
type[typelen] = 0;
81
82
/* Verify that the object matches */
83
- if (verify_object(sha1, type))
84
- return error("char%d: could not verify object %s", 7, sha1_to_hex(sha1));
83
+ if (verify_object(&oid, type))
84
+ return error("char%d: could not verify object %s", 7, oid_to_hex(&oid));
85
86
/* Verify the tag-name: we don't allow control characters or spaces in it */
87
tag_line += 4;