{"thread":{"id":"44903","subject":"[PATCH v6 6/6] t/t7004-tag: Add --format specifier tests","startedAt":"2017-01-17T23:39:03Z","lastAt":"2017-01-19T00:37:51Z","messageCount":20,"participants":["santiago@nyu.edu","Junio C Hamano","Jeff King","Santiago Torres","Eric Wong"],"isPatch":true,"patchVersion":6,"patchTotal":6},"messages":[{"id":"309580","messageId":"20170117233723.23897-7-santiago@nyu.edu","threadId":"44903","inReplyTo":"20170117233723.23897-1-santiago@nyu.edu","subject":"[PATCH v6 6/6] t/t7004-tag: Add --format specifier tests","fromName":"","fromEmail":"santiago@nyu.edu","sentAt":"2017-01-17T23:37:23Z","receivedAt":"2017-01-17T23:39:03Z","isPatch":true,"sender":{"key":"santiago@nyu.edu","avatar":"https://avatars.githubusercontent.com/u/3579933?v=4"},"body":"From: Santiago Torres <santiago@nyu.edu>\n\ntag -v now supports --format specifiers to inspect the contents of a tag\nupon verification. Add two tests to ensure this behavior is respected in\nfuture changes.\n\nSigned-off-by: Santiago Torres <santiago@nyu.edu>\n---\n t/t7004-tag.sh | 16 ++++++++++++++++\n 1 file changed, 16 insertions(+)\n\ndiff --git a/t/t7004-tag.sh b/t/t7004-tag.sh\nindex 07869b0c0..ba88b556b 100755\n--- a/t/t7004-tag.sh\n+++ b/t/t7004-tag.sh\n@@ -874,6 +874,22 @@ test_expect_success GPG 'verifying a forged tag should fail' '\n \ttest_must_fail git tag -v forged-tag\n '\n \n+test_expect_success 'verifying a proper tag with --format pass and format accordingly' '\n+\tcat >expect <<-\\EOF\n+\ttagname : signed-tag\n+\tEOF &&\n+\tgit tag -v --format=\"tagname : %(tag)\" \"signed-tag\" >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'verifying a forged tag with --format fail and format accordingly' '\n+\tcat >expect <<-\\EOF\n+\ttagname : forged-tag\n+\tEOF &&\n+\ttest_must_fail git tag -v --format=\"tagname : %(tag)\" \"forged-tag\" >actual &&\n+\ttest_cmp expect actual\n+'\n+\n # blank and empty messages for signed tags:\n \n get_tag_header empty-signed-tag $commit commit $time >expect\n-- \n2.11.0\n\n"},{"id":"309581","messageId":"20170117233723.23897-4-santiago@nyu.edu","threadId":"44903","inReplyTo":"20170117233723.23897-1-santiago@nyu.edu","subject":"[PATCH v6 3/6] builtin/verify-tag: add --format to verify-tag","fromName":"","fromEmail":"santiago@nyu.edu","sentAt":"2017-01-17T23:37:20Z","receivedAt":"2017-01-17T23:39:06Z","isPatch":true,"sender":{"key":"santiago@nyu.edu","avatar":"https://avatars.githubusercontent.com/u/3579933?v=4"},"body":"From: Santiago Torres <santiago@nyu.edu>\n\nCallers of verify-tag may want to cross-check the tagname from refs/tags\nwith the tagname from the tag object header upon GPG verification. This\nis to avoid tag refs that point to an incorrect object.\n\nAdd a --format parameter to git verify-tag to print the formatted tag\nobject header in addition to or instead of the --verbose or --raw GPG\nverification output.\n\nSigned-off-by: Santiago Torres <santiago@nyu.edu>\n---\n Documentation/git-verify-tag.txt |  2 +-\n builtin/verify-tag.c             | 23 ++++++++++++++++++++---\n 2 files changed, 21 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-verify-tag.txt b/Documentation/git-verify-tag.txt\nindex d590edceb..0b8075dad 100644\n--- a/Documentation/git-verify-tag.txt\n+++ b/Documentation/git-verify-tag.txt\n@@ -8,7 +8,7 @@ git-verify-tag - Check the GPG signature of tags\n SYNOPSIS\n --------\n [verse]\n-'git verify-tag' <tag>...\n+'git verify-tag' [--format=<format>] <tag>...\n \n DESCRIPTION\n -----------\ndiff --git a/builtin/verify-tag.c b/builtin/verify-tag.c\nindex 99f8148cf..18443bf9f 100644\n--- a/builtin/verify-tag.c\n+++ b/builtin/verify-tag.c\n@@ -12,12 +12,14 @@\n #include <signal.h>\n #include \"parse-options.h\"\n #include \"gpg-interface.h\"\n+#include \"ref-filter.h\"\n \n static const char * const verify_tag_usage[] = {\n-\t\tN_(\"git verify-tag [-v | --verbose] <tag>...\"),\n+\t\tN_(\"git verify-tag [-v | --verbose] [--format=<format>] <tag>...\"),\n \t\tNULL\n };\n \n+\n static int git_verify_tag_config(const char *var, const char *value, void *cb)\n {\n \tint status = git_gpg_config(var, value, cb);\n@@ -30,9 +32,11 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix)\n {\n \tint i = 1, verbose = 0, had_error = 0;\n \tunsigned flags = 0;\n+\tchar *fmt_pretty = NULL;\n \tconst struct option verify_tag_options[] = {\n \t\tOPT__VERBOSE(&verbose, N_(\"print tag contents\")),\n \t\tOPT_BIT(0, \"raw\", &flags, N_(\"print raw gpg status output\"), GPG_VERIFY_RAW),\n+\t\tOPT_STRING(  0 , \"format\", &fmt_pretty, N_(\"format\"), N_(\"format to use for the output\")),\n \t\tOPT_END()\n \t};\n \n@@ -46,13 +50,26 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix)\n \tif (verbose)\n \t\tflags |= GPG_VERIFY_VERBOSE;\n \n+\tif (fmt_pretty) {\n+\t\tverify_ref_format(fmt_pretty);\n+\t\tflags |= GPG_VERIFY_OMIT_STATUS;\n+\t}\n+\n \twhile (i < argc) {\n \t\tunsigned char sha1[20];\n \t\tconst char *name = argv[i++];\n-\t\tif (get_sha1(name, sha1))\n+\t\tif (get_sha1(name, sha1)) {\n \t\t\thad_error = !!error(\"tag '%s' not found.\", name);\n-\t\telse if (gpg_verify_tag(sha1, name, flags))\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tif (gpg_verify_tag(sha1, name, flags)) {\n \t\t\thad_error = 1;\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tif (fmt_pretty)\n+\t\t\tpretty_print_ref(name, sha1, fmt_pretty);\n \t}\n \treturn had_error;\n }\n-- \n2.11.0\n\n"},{"id":"309582","messageId":"20170117233723.23897-2-santiago@nyu.edu","threadId":"44903","inReplyTo":"20170117233723.23897-1-santiago@nyu.edu","subject":"[PATCH v6 1/6] gpg-interface,tag: add GPG_VERIFY_OMIT_STATUS flag","fromName":"","fromEmail":"santiago@nyu.edu","sentAt":"2017-01-17T23:37:18Z","receivedAt":"2017-01-17T23:39:09Z","isPatch":true,"sender":{"key":"santiago@nyu.edu","avatar":"https://avatars.githubusercontent.com/u/3579933?v=4"},"body":"From: Lukas Puehringer <luk.puehringer@gmail.com>\n\nFunctions that print git object information may require that the\ngpg-interface functions be silent. Add GPG_VERIFY_OMIT_STATUS flag and\nprevent print_signature_buffer from being called if flag is set.\n\nSigned-off-by: Lukas Puehringer <luk.puehringer@gmail.com>\n---\n gpg-interface.h | 5 +++--\n tag.c           | 5 ++++-\n 2 files changed, 7 insertions(+), 3 deletions(-)\n\ndiff --git a/gpg-interface.h b/gpg-interface.h\nindex ea68885ad..d2d4fd3a6 100644\n--- a/gpg-interface.h\n+++ b/gpg-interface.h\n@@ -1,8 +1,9 @@\n #ifndef GPG_INTERFACE_H\n #define GPG_INTERFACE_H\n \n-#define GPG_VERIFY_VERBOSE\t1\n-#define GPG_VERIFY_RAW\t\t2\n+#define GPG_VERIFY_VERBOSE\t\t1\n+#define GPG_VERIFY_RAW\t\t\t2\n+#define GPG_VERIFY_OMIT_STATUS\t4\n \n struct signature_check {\n \tchar *payload;\ndiff --git a/tag.c b/tag.c\nindex d1dcd18cd..243d1fdbb 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -3,6 +3,7 @@\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"blob.h\"\n+#include \"gpg-interface.h\"\n \n const char *tag_type = \"tag\";\n \n@@ -24,7 +25,9 @@ static int run_gpg_verify(const char *buf, unsigned long size, unsigned flags)\n \n \tret = check_signature(buf, payload_size, buf + payload_size,\n \t\t\t\tsize - payload_size, &sigc);\n-\tprint_signature_buffer(&sigc, flags);\n+\n+\tif (!(flags & GPG_VERIFY_OMIT_STATUS))\n+\t\tprint_signature_buffer(&sigc, flags);\n \n \tsignature_check_clear(&sigc);\n \treturn ret;\n-- \n2.11.0\n\n"},{"id":"309583","messageId":"20170117233723.23897-1-santiago@nyu.edu","threadId":"44903","inReplyTo":null,"subject":"[PATCH v6 0/6] Add --format to tag verification","fromName":"","fromEmail":"santiago@nyu.edu","sentAt":"2017-01-17T23:37:17Z","receivedAt":"2017-01-17T23:39:11Z","isPatch":true,"sender":{"key":"santiago@nyu.edu","avatar":"https://avatars.githubusercontent.com/u/3579933?v=4"},"body":"From: Santiago Torres <santiago@nyu.edu>\n\nThis is the sixth iteration of [1][2][3][4][5], and as a result of the\ndiscussion in [5]. The main goal of this patch series is to bring\n--format to git tag verification so that upper-layer tools can inspect\nthe content of a tag and make decisions based on it.\n\nIn this re-woll we:\n\n* Changed the call interface so printing is done outside of verification. \n\n* Fixed a couple of whitespace issues and whatnot. \n\nThanks,\n-Santiago\n\n[1] http://public-inbox.org/git/20170115184705.10376-1-santiago@nyu.edu/\n[2] http://public-inbox.org/git/20161007210721.20437-1-santiago@nyu.edu/\n[3] http://public-inbox.org/git/20160930221806.3398-1-santiago@nyu.edu/\n[4] http://public-inbox.org/git/20160922185317.349-1-santiago@nyu.edu/\n[5] http://public-inbox.org/git/20160926224233.32702-1-santiago@nyu.edu/\n[6] http://public-inbox.org/git/20160607195608.16643-1-santiago@nyu.edu/\n[7] http://public-inbox.org/git/20161019203546.dfqmi2czcxopgj6w@sigill.intra.peff.net/\n[8] http://public-inbox.org/git/20161019203943.epjxnfci7vcqg4xv@sigill.intra.peff.net/\n\nLukas Puehringer (3):\n  gpg-interface,tag: add GPG_VERIFY_OMIT_STATUS flag\n  ref-filter: add function to print single ref_array_item\n  builtin/tag: add --format argument for tag -v\n\nSantiago Torres (3):\n  builtin/verify-tag: add --format to verify-tag\n  t/t7030-verify-tag: Add --format specifier tests\n  t/t7004-tag: Add --format specifier tests\n\n Documentation/git-tag.txt        |  2 +-\n Documentation/git-verify-tag.txt |  2 +-\n builtin/tag.c                    | 38 ++++++++++++++++++++++++++++----------\n builtin/verify-tag.c             | 23 ++++++++++++++++++++---\n gpg-interface.h                  |  5 +++--\n ref-filter.c                     | 27 +++++++++++++++++++++------\n ref-filter.h                     |  7 +++++++\n t/t7004-tag.sh                   | 16 ++++++++++++++++\n t/t7030-verify-tag.sh            | 16 ++++++++++++++++\n tag.c                            |  5 ++++-\n 10 files changed, 117 insertions(+), 24 deletions(-)\n\n-- \n2.11.0\n\n"},{"id":"309584","messageId":"20170117233723.23897-3-santiago@nyu.edu","threadId":"44903","inReplyTo":"20170117233723.23897-1-santiago@nyu.edu","subject":"[PATCH v6 2/6] ref-filter: add function to print single ref_array_item","fromName":"","fromEmail":"santiago@nyu.edu","sentAt":"2017-01-17T23:37:19Z","receivedAt":"2017-01-17T23:39:14Z","isPatch":true,"sender":{"key":"santiago@nyu.edu","avatar":"https://avatars.githubusercontent.com/u/3579933?v=4"},"body":"From: Lukas Puehringer <luk.puehringer@gmail.com>\n\nref-filter functions are useful for printing git object information\nusing a format specifier. However, some other modules may not want to use\nthis functionality on a ref-array but only print a single item.\n\nExpose a pretty_print_ref function to create, pretty print and free\nindividual ref-items.\n\nSigned-off-by: Lukas Puehringer <luk.puehringer@gmail.com>\n---\n ref-filter.c | 27 +++++++++++++++++++++------\n ref-filter.h |  7 +++++++\n 2 files changed, 28 insertions(+), 6 deletions(-)\n\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 1a978405e..5f4b08792 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -1361,7 +1361,7 @@ static struct ref_array_item *new_ref_array_item(const char *refname,\n \treturn ref;\n }\n \n-static int filter_ref_kind(struct ref_filter *filter, const char *refname)\n+static int ref_kind_from_refname(const char *refname)\n {\n \tunsigned int i;\n \n@@ -1374,11 +1374,7 @@ static int filter_ref_kind(struct ref_filter *filter, const char *refname)\n \t\t{ \"refs/tags/\", FILTER_REFS_TAGS}\n \t};\n \n-\tif (filter->kind == FILTER_REFS_BRANCHES ||\n-\t    filter->kind == FILTER_REFS_REMOTES ||\n-\t    filter->kind == FILTER_REFS_TAGS)\n-\t\treturn filter->kind;\n-\telse if (!strcmp(refname, \"HEAD\"))\n+\tif (!strcmp(refname, \"HEAD\"))\n \t\treturn FILTER_REFS_DETACHED_HEAD;\n \n \tfor (i = 0; i < ARRAY_SIZE(ref_kind); i++) {\n@@ -1389,6 +1385,15 @@ static int filter_ref_kind(struct ref_filter *filter, const char *refname)\n \treturn FILTER_REFS_OTHERS;\n }\n \n+static int filter_ref_kind(struct ref_filter *filter, const char *refname)\n+{\n+\tif (filter->kind == FILTER_REFS_BRANCHES ||\n+\t    filter->kind == FILTER_REFS_REMOTES ||\n+\t    filter->kind == FILTER_REFS_TAGS)\n+\t\treturn filter->kind;\n+\treturn ref_kind_from_refname(refname);\n+}\n+\n /*\n  * A call-back given to for_each_ref().  Filter refs and keep them for\n  * later object processing.\n@@ -1671,6 +1676,16 @@ void show_ref_array_item(struct ref_array_item *info, const char *format, int qu\n \tputchar('\\n');\n }\n \n+void pretty_print_ref(const char *name, const unsigned char *sha1,\n+\t\tconst char *format)\n+{\n+\tstruct ref_array_item *ref_item;\n+\tref_item = new_ref_array_item(name, sha1, 0);\n+\tref_item->kind = ref_kind_from_refname(name);\n+\tshow_ref_array_item(ref_item, format, 0);\n+\tfree_array_item(ref_item);\n+}\n+\n /*  If no sorting option is given, use refname to sort as default */\n struct ref_sorting *ref_default_sorting(void)\n {\ndiff --git a/ref-filter.h b/ref-filter.h\nindex fc55fa357..7b05592ba 100644\n--- a/ref-filter.h\n+++ b/ref-filter.h\n@@ -109,4 +109,11 @@ struct ref_sorting *ref_default_sorting(void);\n /*  Function to parse --merged and --no-merged options */\n int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset);\n \n+/*\n+ * Print a single ref, outside of any ref-filter. Note that the\n+ * name must be a fully qualified refname.\n+ */\n+void pretty_print_ref(const char *name, const unsigned char *sha1,\n+\t\tconst char *format);\n+\n #endif /*  REF_FILTER_H  */\n-- \n2.11.0\n\n"},{"id":"309585","messageId":"20170117233723.23897-5-santiago@nyu.edu","threadId":"44903","inReplyTo":"20170117233723.23897-1-santiago@nyu.edu","subject":"[PATCH v6 4/6] builtin/tag: add --format argument for tag -v","fromName":"","fromEmail":"santiago@nyu.edu","sentAt":"2017-01-17T23:37:21Z","receivedAt":"2017-01-17T23:39:15Z","isPatch":true,"sender":{"key":"santiago@nyu.edu","avatar":"https://avatars.githubusercontent.com/u/3579933?v=4"},"body":"From: Lukas Puehringer <luk.puehringer@gmail.com>\n\nAdding --format to git tag -v mutes the default output of the GPG\nverification and instead prints the formatted tag object.\nThis allows callers to cross-check the tagname from refs/tags with\nthe tagname from the tag object header upon GPG verification.\n\nThe callback function for for_each_tag_name() didn't allow callers to\npass custom data to their callback functions. Add a new opaque pointer\nto each_tag_name_fn's parameter to allow this.\n\nSigned-off-by: Lukas Puehringer <luk.puehringer@gmail.com>\n---\n Documentation/git-tag.txt |  2 +-\n builtin/tag.c             | 38 ++++++++++++++++++++++++++++----------\n 2 files changed, 29 insertions(+), 11 deletions(-)\n\ndiff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\nindex 76cfe40d9..586aaa315 100644\n--- a/Documentation/git-tag.txt\n+++ b/Documentation/git-tag.txt\n@@ -15,7 +15,7 @@ SYNOPSIS\n 'git tag' [-n[<num>]] -l [--contains <commit>] [--points-at <object>]\n \t[--column[=<options>] | --no-column] [--create-reflog] [--sort=<key>]\n \t[--format=<format>] [--[no-]merged [<commit>]] [<pattern>...]\n-'git tag' -v <tagname>...\n+'git tag' -v [--format=<format>] <tagname>...\n \n DESCRIPTION\n -----------\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 73df72811..b9da72761 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -24,7 +24,7 @@ static const char * const git_tag_usage[] = {\n \tN_(\"git tag -d <tagname>...\"),\n \tN_(\"git tag -l [-n[<num>]] [--contains <commit>] [--points-at <object>]\"\n \t\t\"\\n\\t\\t[--format=<format>] [--[no-]merged [<commit>]] [<pattern>...]\"),\n-\tN_(\"git tag -v <tagname>...\"),\n+\tN_(\"git tag -v [--format=<format>] <tagname>...\"),\n \tNULL\n };\n \n@@ -66,15 +66,17 @@ static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting, con\n }\n \n typedef int (*each_tag_name_fn)(const char *name, const char *ref,\n-\t\t\t\tconst unsigned char *sha1);\n+\t\t\t\tconst unsigned char *sha1, void *cb_data);\n \n-static int for_each_tag_name(const char **argv, each_tag_name_fn fn)\n+static int for_each_tag_name(const char **argv, each_tag_name_fn fn,\n+\t\tvoid *cb_data)\n {\n \tconst char **p;\n \tchar ref[PATH_MAX];\n \tint had_error = 0;\n \tunsigned char sha1[20];\n \n+\n \tfor (p = argv; *p; p++) {\n \t\tif (snprintf(ref, sizeof(ref), \"refs/tags/%s\", *p)\n \t\t\t\t\t>= sizeof(ref)) {\n@@ -87,14 +89,14 @@ static int for_each_tag_name(const char **argv, each_tag_name_fn fn)\n \t\t\thad_error = 1;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (fn(*p, ref, sha1))\n+\t\tif (fn(*p, ref, sha1, cb_data))\n \t\t\thad_error = 1;\n \t}\n \treturn had_error;\n }\n \n static int delete_tag(const char *name, const char *ref,\n-\t\t\t\tconst unsigned char *sha1)\n+\t\t\t\tconst unsigned char *sha1, void *cb_data)\n {\n \tif (delete_ref(ref, sha1, 0))\n \t\treturn 1;\n@@ -103,9 +105,22 @@ static int delete_tag(const char *name, const char *ref,\n }\n \n static int verify_tag(const char *name, const char *ref,\n-\t\t\t\tconst unsigned char *sha1)\n+\t\t\t\tconst unsigned char *sha1, void *cb_data)\n {\n-\treturn gpg_verify_tag(sha1, name, GPG_VERIFY_VERBOSE);\n+\tint flags;\n+\tchar *fmt_pretty = cb_data;\n+\tflags = GPG_VERIFY_VERBOSE;\n+\n+\tif (fmt_pretty)\n+\t\tflags = GPG_VERIFY_OMIT_STATUS;\n+\n+\tif (gpg_verify_tag(sha1, name, flags))\n+\t\treturn -1;\n+\n+    if (fmt_pretty)\n+\t\tpretty_print_ref(name, sha1, fmt_pretty);\n+\n+\treturn 0;\n }\n \n static int do_sign(struct strbuf *buffer)\n@@ -428,9 +443,12 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \tif (filter.merge_commit)\n \t\tdie(_(\"--merged and --no-merged option are only allowed with -l\"));\n \tif (cmdmode == 'd')\n-\t\treturn for_each_tag_name(argv, delete_tag);\n-\tif (cmdmode == 'v')\n-\t\treturn for_each_tag_name(argv, verify_tag);\n+\t\treturn for_each_tag_name(argv, delete_tag, NULL);\n+\tif (cmdmode == 'v') {\n+\t\tif (format)\n+\t\t\tverify_ref_format(format);\n+\t\treturn for_each_tag_name(argv, verify_tag, format);\n+\t}\n \n \tif (msg.given || msgfile) {\n \t\tif (msg.given && msgfile)\n-- \n2.11.0\n\n"},{"id":"309586","messageId":"20170117233723.23897-6-santiago@nyu.edu","threadId":"44903","inReplyTo":"20170117233723.23897-1-santiago@nyu.edu","subject":"[PATCH v6 5/6] t/t7030-verify-tag: Add --format specifier tests","fromName":"","fromEmail":"santiago@nyu.edu","sentAt":"2017-01-17T23:37:22Z","receivedAt":"2017-01-17T23:39:18Z","isPatch":true,"sender":{"key":"santiago@nyu.edu","avatar":"https://avatars.githubusercontent.com/u/3579933?v=4"},"body":"From: Santiago Torres <santiago@nyu.edu>\n\nVerify-tag now provides --format specifiers to inspect and ensure the\ncontents of the tag are proper. We add two tests to ensure this\nfunctionality works as expected: the return value should indicate if\nverification passed, and the format specifiers must be respected.\n\nSigned-off-by: Santiago Torres <santiago@nyu.edu>\n---\n t/t7030-verify-tag.sh | 16 ++++++++++++++++\n 1 file changed, 16 insertions(+)\n\ndiff --git a/t/t7030-verify-tag.sh b/t/t7030-verify-tag.sh\nindex 07079a41c..d62ccbb98 100755\n--- a/t/t7030-verify-tag.sh\n+++ b/t/t7030-verify-tag.sh\n@@ -125,4 +125,20 @@ test_expect_success GPG 'verify multiple tags' '\n \ttest_cmp expect.stderr actual.stderr\n '\n \n+test_expect_success 'verifying tag with --format' '\n+\tcat >expect <<-\\EOF\n+\ttagname : fourth-signed\n+\tEOF &&\n+\tgit verify-tag --format=\"tagname : %(tag)\" \"fourth-signed\" >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'verifying a forged tag with --format fail and format accordingly' '\n+\tcat >expect <<-\\EOF\n+\ttagname : 7th forged-signed\n+\tEOF &&\n+\ttest_must_fail git verify-tag --format=\"tagname : %(tag)\" $(cat forged1.tag) >actual-forged &&\n+\ttest_cmp expect actual-forged\n+'\n+\n test_done\n-- \n2.11.0\n\n"},{"id":"309588","messageId":"xmqq4m0xck1b.fsf@gitster.mtv.corp.google.com","threadId":"44903","inReplyTo":"20170117233723.23897-5-santiago@nyu.edu","subject":"Re: [PATCH v6 4/6] builtin/tag: add --format argument for tag -v","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-01-18T00:02:24Z","receivedAt":"2017-01-18T00:02:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"santiago@nyu.edu writes:\n\n> +\tif (gpg_verify_tag(sha1, name, flags))\n> +\t\treturn -1;\n> +\n> +    if (fmt_pretty)\n> +\t\tpretty_print_ref(name, sha1, fmt_pretty);\n\nThat's a funny indentation.  I'll fix it up locally while queuing.\n\n> +\n> +\treturn 0;\n>  }\n\n"},{"id":"309591","messageId":"xmqqziipb5cj.fsf@gitster.mtv.corp.google.com","threadId":"44903","inReplyTo":"20170117233723.23897-5-santiago@nyu.edu","subject":"Re: [PATCH v6 4/6] builtin/tag: add --format argument for tag -v","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-01-18T00:05:00Z","receivedAt":"2017-01-18T00:05:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"santiago@nyu.edu writes:\n\n> -static int for_each_tag_name(const char **argv, each_tag_name_fn fn)\n> +static int for_each_tag_name(const char **argv, each_tag_name_fn fn,\n> +\t\tvoid *cb_data)\n>  {\n>  \tconst char **p;\n>  \tchar ref[PATH_MAX];\n>  \tint had_error = 0;\n>  \tunsigned char sha1[20];\n>  \n> +\n\nWhy?  I'll remove this while queuing.\n\n>  \tfor (p = argv; *p; p++) {\n>  \t\tif (snprintf(ref, sizeof(ref), \"refs/tags/%s\", *p)\n>  \t\t\t\t\t>= sizeof(ref)) {\n"},{"id":"309593","messageId":"xmqqvatdb586.fsf@gitster.mtv.corp.google.com","threadId":"44903","inReplyTo":"20170117233723.23897-1-santiago@nyu.edu","subject":"Re: [PATCH v6 0/6] Add --format to tag verification","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-01-18T00:07:37Z","receivedAt":"2017-01-18T00:07:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"santiago@nyu.edu writes:\n\n> From: Santiago Torres <santiago@nyu.edu>\n>\n> This is the sixth iteration of [1][2][3][4][5], and as a result of the\n> discussion in [5]. The main goal of this patch series is to bring\n> --format to git tag verification so that upper-layer tools can inspect\n> the content of a tag and make decisions based on it.\n>\n> In this re-woll we:\n>\n> * Changed the call interface so printing is done outside of verification. \n>\n> * Fixed a couple of whitespace issues and whatnot. \n\nWith the small code structure change Peff suggested the result looks\nmuch easier to read.  I didn't spot any more problems.\n\nWill replace what has been sitting in my tree.  Thanks.\n"},{"id":"309604","messageId":"xmqqmvepb4oj.fsf@gitster.mtv.corp.google.com","threadId":"44903","inReplyTo":"20170117233723.23897-5-santiago@nyu.edu","subject":"Re: [PATCH v6 4/6] builtin/tag: add --format argument for tag -v","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-01-18T00:19:24Z","receivedAt":"2017-01-18T00:19:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"santiago@nyu.edu writes:\n\n> @@ -428,9 +443,12 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n>  \tif (filter.merge_commit)\n>  \t\tdie(_(\"--merged and --no-merged option are only allowed with -l\"));\n>  \tif (cmdmode == 'd')\n> -\t\treturn for_each_tag_name(argv, delete_tag);\n> -\tif (cmdmode == 'v')\n> -\t\treturn for_each_tag_name(argv, verify_tag);\n> +\t\treturn for_each_tag_name(argv, delete_tag, NULL);\n> +\tif (cmdmode == 'v') {\n> +\t\tif (format)\n> +\t\t\tverify_ref_format(format);\n> +\t\treturn for_each_tag_name(argv, verify_tag, format);\n> +\t}\n\nThis triggers:\n\n    builtin/tag.c: In function 'cmd_tag':\n    builtin/tag.c:451:3: error: passing argument 3 of\n    'for_each_tag_name' discards 'const' qualifier from pointer target type [-Werror]\n       return for_each_tag_name(argv, verify_tag, format);\n\nEither for-each-tag-name's new parameter needs to be typed\ncorrectly, or the type of the \"format\" variable needs to be updated.\n"},{"id":"309633","messageId":"xmqqh94wb4y0.fsf@gitster.mtv.corp.google.com","threadId":"44903","inReplyTo":"xmqqmvepb4oj.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v6 4/6] builtin/tag: add --format argument for tag -v","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-01-18T18:25:59Z","receivedAt":"2017-01-18T18:26:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> santiago@nyu.edu writes:\n>\n>> @@ -428,9 +443,12 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n>>  \tif (filter.merge_commit)\n>>  \t\tdie(_(\"--merged and --no-merged option are only allowed with -l\"));\n>>  \tif (cmdmode == 'd')\n>> -\t\treturn for_each_tag_name(argv, delete_tag);\n>> -\tif (cmdmode == 'v')\n>> -\t\treturn for_each_tag_name(argv, verify_tag);\n>> +\t\treturn for_each_tag_name(argv, delete_tag, NULL);\n>> +\tif (cmdmode == 'v') {\n>> +\t\tif (format)\n>> +\t\t\tverify_ref_format(format);\n>> +\t\treturn for_each_tag_name(argv, verify_tag, format);\n>> +\t}\n>\n> This triggers:\n>\n>     builtin/tag.c: In function 'cmd_tag':\n>     builtin/tag.c:451:3: error: passing argument 3 of\n>     'for_each_tag_name' discards 'const' qualifier from pointer target type [-Werror]\n>        return for_each_tag_name(argv, verify_tag, format);\n>\n> Either for-each-tag-name's new parameter needs to be typed\n> correctly, or the type of the \"format\" variable needs to be updated.\n\nSquashing the following into this commit solves this issue with the\nformer approach.  The lines it touches are all from 4/6 and I view\nall of it as general improvement, including type correctness and\ncode formatting.\n\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex f81273a85a..fbb85ba3dc 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -66,10 +66,10 @@ static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting, con\n }\n \n typedef int (*each_tag_name_fn)(const char *name, const char *ref,\n-\t\t\t\tconst unsigned char *sha1, void *cb_data);\n+\t\t\t\tconst unsigned char *sha1, const void *cb_data);\n \n static int for_each_tag_name(const char **argv, each_tag_name_fn fn,\n-\t\tvoid *cb_data)\n+\t\t\t     const void *cb_data)\n {\n \tconst char **p;\n \tchar ref[PATH_MAX];\n@@ -95,7 +95,7 @@ static int for_each_tag_name(const char **argv, each_tag_name_fn fn,\n }\n \n static int delete_tag(const char *name, const char *ref,\n-\t\t\t\tconst unsigned char *sha1, void *cb_data)\n+\t\t      const unsigned char *sha1, const void *cb_data)\n {\n \tif (delete_ref(ref, sha1, 0))\n \t\treturn 1;\n@@ -104,10 +104,10 @@ static int delete_tag(const char *name, const char *ref,\n }\n \n static int verify_tag(const char *name, const char *ref,\n-\t\t\t\tconst unsigned char *sha1, void *cb_data)\n+\t\t      const unsigned char *sha1, const void *cb_data)\n {\n \tint flags;\n-\tchar *fmt_pretty = cb_data;\n+\tconst char *fmt_pretty = cb_data;\n \tflags = GPG_VERIFY_VERBOSE;\n \n \tif (fmt_pretty)\n"},{"id":"309634","messageId":"20170118182843.iyico5jpii6a3z7i@sigill.intra.peff.net","threadId":"44903","inReplyTo":"xmqqh94wb4y0.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v6 4/6] builtin/tag: add --format argument for tag -v","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-01-18T18:28:44Z","receivedAt":"2017-01-18T18:30:40Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Jan 18, 2017 at 10:25:59AM -0800, Junio C Hamano wrote:\n\n> > This triggers:\n> >\n> >     builtin/tag.c: In function 'cmd_tag':\n> >     builtin/tag.c:451:3: error: passing argument 3 of\n> >     'for_each_tag_name' discards 'const' qualifier from pointer target type [-Werror]\n> >        return for_each_tag_name(argv, verify_tag, format);\n> >\n> > Either for-each-tag-name's new parameter needs to be typed\n> > correctly, or the type of the \"format\" variable needs to be updated.\n> \n> Squashing the following into this commit solves this issue with the\n> former approach.  The lines it touches are all from 4/6 and I view\n> all of it as general improvement, including type correctness and\n> code formatting.\n> \n> diff --git a/builtin/tag.c b/builtin/tag.c\n> index f81273a85a..fbb85ba3dc 100644\n> --- a/builtin/tag.c\n> +++ b/builtin/tag.c\n> @@ -66,10 +66,10 @@ static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting, con\n>  }\n>  \n>  typedef int (*each_tag_name_fn)(const char *name, const char *ref,\n> -\t\t\t\tconst unsigned char *sha1, void *cb_data);\n> +\t\t\t\tconst unsigned char *sha1, const void *cb_data);\n\nThis would bite us later if one of the iterators really does need to\npass something mutable. But as this iteration interface is confined to\nbuiltin/tag.c, I think it's a nice simple fix.\n\nA more general fix would be to pass a non-const pointer to const pointer\n(preferably inside a struct for readability). But I don't see any need\nfor that complexity here.\n\n-Peff\n"},{"id":"309636","messageId":"20170118182831.pkhqu2np3bh2puei@LykOS.localdomain","threadId":"44903","inReplyTo":"xmqqh94wb4y0.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v6 4/6] builtin/tag: add --format argument for tag -v","fromName":"Santiago Torres","fromEmail":"santiago@nyu.edu","sentAt":"2017-01-18T18:28:32Z","receivedAt":"2017-01-18T18:37:52Z","isPatch":true,"sender":{"key":"santiago@nyu.edu","avatar":"https://avatars.githubusercontent.com/u/3579933?v=4"},"body":""},{"id":"309638","messageId":"xmqq4m0wb43w.fsf@gitster.mtv.corp.google.com","threadId":"44903","inReplyTo":"20170118182831.pkhqu2np3bh2puei@LykOS.localdomain","subject":"Re: [PATCH v6 4/6] builtin/tag: add --format argument for tag -v","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-01-18T18:44:03Z","receivedAt":"2017-01-18T18:48:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Santiago Torres <santiago@nyu.edu> writes:\n\n<<nothing>>???\n\nEric, I've noticed that this message\n\n  http://public-inbox.org/git/20170118182831.pkhqu2np3bh2puei@LykOS.localdomain/\n\nand all messages from Santiago appear empty when they come via\npublic-inbox.org; the reason I suspect we haven't heard much\ncomplaints is because nobody else around here sends multipart/signed\ndisposition inline other than Santiago.\n\n"},{"id":"309639","messageId":"xmqqziio9paj.fsf@gitster.mtv.corp.google.com","threadId":"44903","inReplyTo":"20170118182843.iyico5jpii6a3z7i@sigill.intra.peff.net","subject":"Re: [PATCH v6 4/6] builtin/tag: add --format argument for tag -v","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-01-18T18:49:24Z","receivedAt":"2017-01-18T18:50:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n>> diff --git a/builtin/tag.c b/builtin/tag.c\n>> index f81273a85a..fbb85ba3dc 100644\n>> --- a/builtin/tag.c\n>> +++ b/builtin/tag.c\n>> @@ -66,10 +66,10 @@ static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting, con\n>>  }\n>>  \n>>  typedef int (*each_tag_name_fn)(const char *name, const char *ref,\n>> -\t\t\t\tconst unsigned char *sha1, void *cb_data);\n>> +\t\t\t\tconst unsigned char *sha1, const void *cb_data);\n>\n> This would bite us later if one of the iterators really does need to\n> pass something mutable. But as this iteration interface is confined to\n> builtin/tag.c, I think it's a nice simple fix.\n>\n> A more general fix would be to pass a non-const pointer to const pointer\n> (preferably inside a struct for readability). But I don't see any need\n> for that complexity here.\n\nMy first trial was to loosen the constness of existing variable,\nwhich was OK, but made me feel dirty by turning what does not need\nto be mutable into mutable.  The iterator being local made me try\nthe other way and it turned out that currently there is no need for\nmutable callback data ;-)\n\nI agree that this may have to be updated, and if this were more\nglobal thing, we'd better off doing so from the get-go, but for a\ncalling convention that is limited within a single file, I am more\ncomfortable saying we'll cross the bridge when we need to.\n\nThanks.\n"},{"id":"309640","messageId":"20170118185015.3vq7wfvsfo3gjj4b@LykOS.localdomain","threadId":"44903","inReplyTo":"xmqq4m0wb43w.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v6 4/6] builtin/tag: add --format argument for tag -v","fromName":"Santiago Torres","fromEmail":"santiago@nyu.edu","sentAt":"2017-01-18T18:50:15Z","receivedAt":"2017-01-18T18:51:10Z","isPatch":true,"sender":{"key":"santiago@nyu.edu","avatar":"https://avatars.githubusercontent.com/u/3579933?v=4"},"body":"On Wed, Jan 18, 2017 at 10:44:03AM -0800, Junio C Hamano wrote:\n> Santiago Torres <santiago@nyu.edu> writes:\n> \nWas:\n\nThanks!\n\nWould you want me to re-roll really quick? or would you rather apply\nthis on your side?\n\nThanks,\n-Santiago.\n> \n> Eric, I've noticed that this message\n> \n>   http://public-inbox.org/git/20170118182831.pkhqu2np3bh2puei@LykOS.localdomain/\n> \n> and all messages from Santiago appear empty when they come via\n> public-inbox.org; the reason I suspect we haven't heard much\n> complaints is because nobody else around here sends multipart/signed\n> disposition inline other than Santiago.\n> \n\nInteresting, I thought I wasn't inlining the .asc. I guess I can disable\nsigning for this ML for the time being. \n\nThanks for letting me know.\n-Santiago.\n"},{"id":"309643","messageId":"xmqqo9z49p51.fsf@gitster.mtv.corp.google.com","threadId":"44903","inReplyTo":"20170118182831.pkhqu2np3bh2puei@LykOS.localdomain","subject":"Re: [PATCH v6 4/6] builtin/tag: add --format argument for tag -v","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-01-18T18:52:42Z","receivedAt":"2017-01-18T18:53:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Santiago Torres <santiago@nyu.edu> writes:\n\n>> Squashing the following into this commit solves this issue with the\n>> former approach.  The lines it touches are all from 4/6 and I view\n>> all of it as general improvement, including type correctness and\n>> code formatting.\n>\n> Thanks!\n>\n> Should I re-roll this really quick? Or would you rather apply this on\n> your tree directly? \n\nNah, local squashing should be sufficient in this case.  The squash\nonly touches a single patch from the original and it itself is easy\nto review (and was reviewed already from what I can tell in this\nthread).\n\n"},{"id":"309655","messageId":"20170118201644.GA13758@starla","threadId":"44903","inReplyTo":"xmqq4m0wb43w.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v6 4/6] builtin/tag: add --format argument for tag -v","fromName":"Eric Wong","fromEmail":"e@80x24.org","sentAt":"2017-01-18T20:16:44Z","receivedAt":"2017-01-18T20:16:53Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n> Santiago Torres <santiago@nyu.edu> writes:\n> \n> <<nothing>>???\n> \n> Eric, I've noticed that this message\n> \n>   http://public-inbox.org/git/20170118182831.pkhqu2np3bh2puei@LykOS.localdomain/\n> \n> and all messages from Santiago appear empty when they come via\n> public-inbox.org; the reason I suspect we haven't heard much\n> complaints is because nobody else around here sends multipart/signed\n> disposition inline other than Santiago.\n\nEeep!  This looks like a regression I introduced when working\naround Richard Hansen's S/MIME mails the other week on git@vger:\n\n  https://public-inbox.org/meta/20170110222235.GB27356@dcvr/T/#u\n\nWorse is they now corrupted on the way in into the git repo\nbecause of search indexing.  Will fix ASAP.  Thanks for the\nheads up.\n"},{"id":"309705","messageId":"20170119003709.GA25782@dcvr","threadId":"44903","inReplyTo":"20170118201644.GA13758@starla","subject":"Re: [PATCH v6 4/6] builtin/tag: add --format argument for tag -v","fromName":"Eric Wong","fromEmail":"e@80x24.org","sentAt":"2017-01-19T00:37:09Z","receivedAt":"2017-01-19T00:37:51Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Eric Wong <e@80x24.org> wrote:\n> Junio C Hamano <gitster@pobox.com> wrote:\n> > \n> >   http://public-inbox.org/git/20170118182831.pkhqu2np3bh2puei@LykOS.localdomain/\n> \n> Eeep!  This looks like a regression I introduced when working\n> around Richard Hansen's S/MIME mails the other week on git@vger:\n>\n>   https://public-inbox.org/meta/20170110222235.GB27356@dcvr/T/#u\n\nYep, I copied SUPER and used it improperly in a subclass.  Should be\nfixed now, and reimported several messages from my Maildir.  NNTP\nreaders will see new article numbers for reimported Message-IDs.\n"}]}