From: Lukas P <luk.puehrin...@gmail.com>

Adding --format to git tag -v mutes the default output of the GPG
verification and instead prints the formatted tag object.

This allows callers to cross-check the tagname from refs/tags with
the tagname from the tag object header upon GPG verification.

Signed-off-by: Lukas Puehringer <lukas.puehrin...@nyu.edu>
---
 builtin/tag.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/builtin/tag.c b/builtin/tag.c
index 94ed8a2..3dd1e65 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -24,7 +24,7 @@ static const char * const git_tag_usage[] = {
        N_("git tag -d <tagname>..."),
        N_("git tag -l [-n[<num>]] [--contains <commit>] [--points-at <object>]"
                "\n\t\t[--format=<format>] [--[no-]merged [<commit>]] 
[<pattern>...]"),
-       N_("git tag -v <tagname>..."),
+       N_("git tag -v [--format=<format>] <tagname>..."),
        NULL
 };
 
@@ -106,7 +106,13 @@ 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 verify_and_format_tag(sha1, name, NULL, GPG_VERIFY_VERBOSE);
+       int flags;
+       flags = GPG_VERIFY_VERBOSE;
+
+       if (fmt_pretty)
+               flags = GPG_VERIFY_QUIET;
+
+       return verify_and_format_tag(sha1, name, fmt_pretty, flags);
 }
 
 static int do_sign(struct strbuf *buffer)
@@ -425,8 +431,11 @@ int cmd_tag(int argc, const char **argv, const char 
*prefix)
                die(_("--merged and --no-merged option are only allowed with 
-l"));
        if (cmdmode == 'd')
                return for_each_tag_name(argv, delete_tag);
-       if (cmdmode == 'v')
+       if (cmdmode == 'v') {
+               if (fmt_pretty)
+                       verify_ref_format(fmt_pretty);
                return for_each_tag_name(argv, verify_tag);
+       }
 
        if (msg.given || msgfile) {
                if (msg.given && msgfile)
-- 
2.10.0

Reply via email to