git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 6/6] builtin/tag: add --format argument for tag -v

From
santiago@nyu.edu <santiago@nyu.edu>
Date
Sep 22, 2016, 18:53 UTC
Message-ID
<20160922185317.349-7-santiago@nyu.edu>
In-Reply-To
<20160922185317.349-1-santiago@nyu.edu>
From: Lukas P <luk.puehringer@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.puehringer@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
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 19 in “Add --format to tag verification”
  1. 0/6 Add --format to tag verificationsantiago@nyu.edu, Sep 22, 2016
  2. 3/6 ref-filter: Expose wrappers for ref_item functionssantiago@nyu.edu, Sep 22, 2016
  3. Junio C HamanoSep 22, 2016
  4. 6/6 builtin/tag: add --format argument for tag -vsantiago@nyu.edu, Sep 22, 2016
  5. Junio C HamanoSep 22, 2016
  6. Santiago TorresSep 23, 2016
  7. 2/6 gpg-interface: add GPG_VERIFY_QUIET flagsantiago@nyu.edu, Sep 22, 2016
  8. Junio C HamanoSep 22, 2016
  9. Junio C HamanoSep 22, 2016
  10. 4/6 tag: add format specifier to gpg_verify_tagsantiago@nyu.edu, Sep 22, 2016
  11. Junio C HamanoSep 22, 2016
  12. Santiago TorresSep 23, 2016
  13. 1/6 builtin/tag: move format specifier to global varsantiago@nyu.edu, Sep 22, 2016
  14. Junio C HamanoSep 22, 2016
  15. 5/6 builtin/verify-tag: Add --format to verify-tagsantiago@nyu.edu, Sep 22, 2016
  16. Junio C HamanoSep 22, 2016
  17. Santiago TorresSep 23, 2016
  18. Stefan BellerSep 22, 2016
  19. Jakub NarębskiSep 24, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.