From: Lukas Puehringer <luk.puehringer@xxxxxxxxx> Calling functions for gpg_verify_tag() may desire to print relevant information about the header for further verification. Add an optional format argument to print any desired information after GPG verification. Signed-off-by: Lukas Puehringer <luk.puehringer@xxxxxxxxx> --- builtin/tag.c | 2 +- builtin/verify-tag.c | 2 +- tag.c | 17 +++++++++++------ tag.h | 4 ++-- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/builtin/tag.c b/builtin/tag.c index 73df72811..880677df5 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -105,7 +105,7 @@ static int delete_tag(const char *name, const char *ref, static int verify_tag(const char *name, const char *ref, const unsigned char *sha1) { - return gpg_verify_tag(sha1, name, GPG_VERIFY_VERBOSE); + return verify_and_format_tag(sha1, name, NULL, GPG_VERIFY_VERBOSE); } static int do_sign(struct strbuf *buffer) diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c index 99f8148cf..de10198c4 100644 --- a/builtin/verify-tag.c +++ b/builtin/verify-tag.c @@ -51,7 +51,7 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix) const char *name = argv[i++]; if (get_sha1(name, sha1)) had_error = !!error("tag '%s' not found.", name); - else if (gpg_verify_tag(sha1, name, flags)) + else if (verify_and_format_tag(sha1, name, NULL, flags)) had_error = 1; } return had_error; diff --git a/tag.c b/tag.c index 291073f6e..d5a7cfb20 100644 --- a/tag.c +++ b/tag.c @@ -4,6 +4,7 @@ #include "tree.h" #include "blob.h" #include "gpg-interface.h" +#include "ref-filter.h" const char *tag_type = "tag"; @@ -33,8 +34,8 @@ static int run_gpg_verify(const char *buf, unsigned long size, unsigned flags) return ret; } -int gpg_verify_tag(const unsigned char *sha1, const char *name_to_report, - unsigned flags) +int verify_and_format_tag(const unsigned char *sha1, const char *name, + const char *fmt_pretty, unsigned flags) { enum object_type type; char *buf; @@ -44,21 +45,25 @@ int gpg_verify_tag(const unsigned char *sha1, const char *name_to_report, type = sha1_object_info(sha1, NULL); if (type != OBJ_TAG) return error("%s: cannot verify a non-tag object of type %s.", - name_to_report ? - name_to_report : + name ? + name : find_unique_abbrev(sha1, DEFAULT_ABBREV), typename(type)); buf = read_sha1_file(sha1, &type, &size); if (!buf) return error("%s: unable to read file.", - name_to_report ? - name_to_report : + name ? + name : find_unique_abbrev(sha1, DEFAULT_ABBREV)); ret = run_gpg_verify(buf, size, flags); free(buf); + + if (fmt_pretty) + pretty_print_ref(name, sha1, fmt_pretty); + return ret; } diff --git a/tag.h b/tag.h index a5721b673..896b9c2dc 100644 --- a/tag.h +++ b/tag.h @@ -17,7 +17,7 @@ extern int parse_tag_buffer(struct tag *item, const void *data, unsigned long si extern int parse_tag(struct tag *item); extern struct object *deref_tag(struct object *, const char *, int); extern struct object *deref_tag_noverify(struct object *); -extern int gpg_verify_tag(const unsigned char *sha1, - const char *name_to_report, unsigned flags); +extern int verify_and_format_tag(const unsigned char *sha1, const char *name, + const char *fmt_pretty, unsigned flags); #endif /* TAG_H */ -- 2.11.0