tag: convert gpg_verify_tag to use struct object_id

Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed Jul 12, 2017 at 17:44 UTC 84571760ca96d244e4fff06819fab119947d792e
4 files changed +12 -11
builtin/tag.c
+1 -1
@@ -111,7 +111,7 @@ static int verify_tag(const char *name, const char *ref,
111 if (fmt_pretty)
112 flags = GPG_VERIFY_OMIT_STATUS;
113
114 - if (gpg_verify_tag(oid->hash, name, flags))
114 + if (gpg_verify_tag(oid, name, flags))
115 return -1;
116
117 if (fmt_pretty)
builtin/verify-tag.c
+5 -4
@@ -56,20 +56,21 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix)
56 }
57
58 while (i < argc) {
59 - unsigned char sha1[20];
59 + struct object_id oid;
60 const char *name = argv[i++];
61 - if (get_sha1(name, sha1)) {
61 +
62 + if (get_oid(name, &oid)) {
63 had_error = !!error("tag '%s' not found.", name);
64 continue;
65 }
66
66 - if (gpg_verify_tag(sha1, name, flags)) {
67 + if (gpg_verify_tag(&oid, name, flags)) {
68 had_error = 1;
69 continue;
70 }
71
72 if (fmt_pretty)
72 - pretty_print_ref(name, sha1, fmt_pretty);
73 + pretty_print_ref(name, oid.hash, fmt_pretty);
74 }
75 return had_error;
76 }
tag.c
+5 -5
@@ -33,7 +33,7 @@ static int run_gpg_verify(const char *buf, unsigned long size, unsigned flags)
33 return ret;
34 }
35
36 -int gpg_verify_tag(const unsigned char *sha1, const char *name_to_report,
36 +int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
37 unsigned flags)
38 {
39 enum object_type type;
@@ -41,20 +41,20 @@ int gpg_verify_tag(const unsigned char *sha1, const char *name_to_report,
41 unsigned long size;
42 int ret;
43
44 - type = sha1_object_info(sha1, NULL);
44 + type = sha1_object_info(oid->hash, NULL);
45 if (type != OBJ_TAG)
46 return error("%s: cannot verify a non-tag object of type %s.",
47 name_to_report ?
48 name_to_report :
49 - find_unique_abbrev(sha1, DEFAULT_ABBREV),
49 + find_unique_abbrev(oid->hash, DEFAULT_ABBREV),
50 typename(type));
51
52 - buf = read_sha1_file(sha1, &type, &size);
52 + buf = read_sha1_file(oid->hash, &type, &size);
53 if (!buf)
54 return error("%s: unable to read file.",
55 name_to_report ?
56 name_to_report :
57 - find_unique_abbrev(sha1, DEFAULT_ABBREV));
57 + find_unique_abbrev(oid->hash, DEFAULT_ABBREV));
58
59 ret = run_gpg_verify(buf, size, flags);
60
tag.h
+1 -1
@@ -17,7 +17,7 @@ extern int parse_tag_buffer(struct tag *item, const void *data, unsigned long si
17 extern int parse_tag(struct tag *item);
18 extern struct object *deref_tag(struct object *, const char *, int);
19 extern struct object *deref_tag_noverify(struct object *);
20 -extern int gpg_verify_tag(const unsigned char *sha1,
20 +extern int gpg_verify_tag(const struct object_id *oid,
21 const char *name_to_report, unsigned flags);
22
23 #endif /* TAG_H */