diff options
author | Jeff King <peff@peff.net> | 2017-10-03 09:45:47 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-10-04 11:35:29 +0900 |
commit | 0c88bf50502e2be7d7d8965052d77bbf08e1d519 (patch) | |
tree | 2e0526a67f059be8fce0eaac254232845bdb9544 /builtin | |
parent | 8126b1267c9b3c8cdc79daf56492972b82f0a57d (diff) | |
download | git-0c88bf50502e2be7d7d8965052d77bbf08e1d519.tar.gz git-0c88bf50502e2be7d7d8965052d77bbf08e1d519.tar.xz |
provide --color option for all ref-filter users
When ref-filter learned about want_color() in 11b087adfd
(ref-filter: consult want_color() before emitting colors,
2017-07-13), it became useful to be able to turn colors off
and on for specific commands. For git-branch, you can do so
with --color/--no-color.
But for git-for-each-ref and git-tag, the other users of
ref-filter, you have no option except to tweak the
"color.ui" config setting. Let's give both of these commands
the usual color command-line options.
This is a bit more obvious as a method for overriding the
config. And it also prepares us for the behavior of "always"
changing (so that we are still left with a way of forcing
color when our output goes to a non-terminal).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/for-each-ref.c | 1 | ||||
-rw-r--r-- | builtin/tag.c | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index 5d7c921a7..e931be9ce 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -36,6 +36,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix) OPT_GROUP(""), OPT_INTEGER( 0 , "count", &maxcount, N_("show only <n> matched refs")), OPT_STRING( 0 , "format", &format.format, N_("format"), N_("format to use for the output")), + OPT__COLOR(&format.use_color, N_("respect format colors")), OPT_CALLBACK(0 , "sort", sorting_tail, N_("key"), N_("field name to sort on"), &parse_opt_ref_sorting), OPT_CALLBACK(0, "points-at", &filter.points_at, diff --git a/builtin/tag.c b/builtin/tag.c index 66e35b823..b9d1a13af 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -411,6 +411,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix) }, OPT_STRING( 0 , "format", &format.format, N_("format"), N_("format to use for the output")), + OPT__COLOR(&format.use_color, N_("respect format colors")), OPT_BOOL('i', "ignore-case", &icase, N_("sorting and filtering are case insensitive")), OPT_END() }; |