diff options
author | Jeff King <peff@peff.net> | 2017-07-13 18:01:18 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-07-13 22:42:50 +0300 |
commit | 4a68e36d7d106abaf44e3ac960276145b5a25723 (patch) | |
tree | e31869cd9a8b21809edc0e7fd77f9f133283da7f /builtin/verify-tag.c | |
parent | 51331aad69a1d89a8b6d1ff82bb5fedbdb6ccc6a (diff) |
ref-filter: abstract ref format into its own struct
The ref-filter module provides routines for formatting a ref
for output. The fundamental interface for the format is a
"const char *" containing the format, and any additional
options need to be passed to each invocation of
show_ref_array_item.
Instead, let's make a ref_format struct that holds the
format, along with any associated format options. That will
make some enhancements easier in the future:
1. new formatting options can be added without disrupting
existing callers
2. some state can be carried in the struct rather than as
global variables
For now this just has the text format itself along with the
quote_style option, but we'll add more fields in future patches.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/verify-tag.c')
-rw-r--r-- | builtin/verify-tag.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c index a10eca2b2d..87d73e856a 100644 --- a/builtin/verify-tag.c +++ b/builtin/verify-tag.c @@ -32,11 +32,11 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix) { int i = 1, verbose = 0, had_error = 0; unsigned flags = 0; - char *fmt_pretty = NULL; + struct ref_format format = REF_FORMAT_INIT; const struct option verify_tag_options[] = { OPT__VERBOSE(&verbose, N_("print tag contents")), OPT_BIT(0, "raw", &flags, N_("print raw gpg status output"), GPG_VERIFY_RAW), - OPT_STRING( 0 , "format", &fmt_pretty, N_("format"), N_("format to use for the output")), + OPT_STRING(0, "format", &format.format, N_("format"), N_("format to use for the output")), OPT_END() }; @@ -50,8 +50,8 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix) if (verbose) flags |= GPG_VERIFY_VERBOSE; - if (fmt_pretty) { - if (verify_ref_format(fmt_pretty)) + if (format.format) { + if (verify_ref_format(&format)) usage_with_options(verify_tag_usage, verify_tag_options); flags |= GPG_VERIFY_OMIT_STATUS; @@ -70,8 +70,8 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix) continue; } - if (fmt_pretty) - pretty_print_ref(name, sha1, fmt_pretty); + if (format.format) + pretty_print_ref(name, sha1, &format); } return had_error; } |