From: santiago@nyu.edu
To: git@vger.kernel.org
Cc: gitster@pobox.com, peff@peff.net, sunshine@sunshineco.com,
walters@verbum.org, Lukas Puehringer <luk.puehringer@gmail.com>
Subject: [PATCH v5 3/7] tag: add format specifier to gpg_verify_tag
Date: Sun, 15 Jan 2017 13:47:01 -0500 [thread overview]
Message-ID: <20170115184705.10376-4-santiago@nyu.edu> (raw)
In-Reply-To: <20170115184705.10376-1-santiago@nyu.edu>
From: Lukas Puehringer <luk.puehringer@gmail.com>
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@gmail.com>
---
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
next prev parent reply other threads:[~2017-01-15 18:47 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-15 18:46 [PATCH v5 0/7] Add --format to tag verification santiago
2017-01-15 18:46 ` [PATCH v5 1/7] gpg-interface, tag: add GPG_VERIFY_QUIET flag santiago
2017-01-15 18:47 ` [PATCH v5 2/7] ref-filter: add function to print single ref_array_item santiago
2017-01-15 18:47 ` santiago [this message]
2017-01-17 15:24 ` [PATCH v5 3/7] tag: add format specifier to gpg_verify_tag Jeff King
2017-01-17 15:30 ` Jeff King
2017-01-17 16:57 ` Santiago Torres
2017-01-17 17:25 ` Jeff King
2017-01-17 17:30 ` Jeff King
2017-01-17 17:33 ` Santiago Torres
2017-01-17 17:34 ` Jeff King
2017-01-15 18:47 ` [PATCH v5 4/7] builtin/verify-tag: add --format to verify-tag santiago
2017-01-15 18:47 ` [PATCH v5 5/7] builtin/tag: add --format argument for tag -v santiago
2017-01-17 15:34 ` Jeff King
2017-01-17 17:00 ` Santiago Torres
2017-01-17 17:32 ` Jeff King
2017-01-17 17:34 ` Santiago Torres
2017-01-15 18:47 ` [PATCH v5 6/7] t/t7030-verify-tag: Add --format specifier tests santiago
2017-01-15 18:47 ` [PATCH v5 7/7] t/t7004-tag: " santiago
2017-01-17 15:35 ` Jeff King
2017-01-17 15:36 ` [PATCH v5 0/7] Add --format to tag verification Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170115184705.10376-4-santiago@nyu.edu \
--to=santiago@nyu.edu \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=luk.puehringer@gmail.com \
--cc=peff@peff.net \
--cc=sunshine@sunshineco.com \
--cc=walters@verbum.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).