From: Taylor Blau <me@ttaylorr.com>
To: git@vger.kernel.org
Cc: sunshine@sunshineco.com, gitster@pobox.com, peff@peff.net
Subject: [PATCH v6 0/3] Teach `--default` to `git-config(1)`
Date: Mon, 9 Apr 2018 17:18:22 -0700 [thread overview]
Message-ID: <20180410001822.GA67209@syl.local> (raw)
In-Reply-To: <20180306021729.45813-1-me@ttaylorr.com>
Hi,
Attached is the sixth re-roll of my series to add '--type=color' as a valid
option to 'git-config(1)'.
I have changed the following since v5 (an inter-diff is available below for
easier consumption):
- Update prose in Documentation/git-config.txt to match Eric's
suggestions.
- Remove extraneous braces, newlines from builtin/config.c. (cc:
Eric).
- Rename, reorder tests in t1310 to make clear which tests are duals
of one another. Use '-c' to introduce short-lived configuration
values. (cc: Eric).
Thanks,
Taylor
Taylor Blau (3):
builtin/config: introduce `--default`
config.c: introduce 'git_config_color' to parse ANSI colors
builtin/config: introduce `color` type specifier
Documentation/git-config.txt | 10 +++++++++
builtin/config.c | 40 ++++++++++++++++++++++++++++++++++++
config.c | 10 +++++++++
config.h | 1 +
t/t1300-repo-config.sh | 30 +++++++++++++++++++++++++++
t/t1310-config-default.sh | 36 ++++++++++++++++++++++++++++++++
6 files changed, 127 insertions(+)
create mode 100755 t/t1310-config-default.sh
Inter-diff (since v5):
diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
index 05a555b568..7c8365e377 100644
--- a/Documentation/git-config.txt
+++ b/Documentation/git-config.txt
@@ -177,10 +177,10 @@ Valid `<type>`'s include:
~/` from the command line to let your shell do the expansion.)
- 'expiry-date': canonicalize by converting from a fixed or relative date-string
to a timestamp. This specifier has no effect when setting the value.
-- 'color': When writing to a caller, canonicalize by converting to an ANSI color
- escape sequence. When writing to the configuration file, a sanity-check is
- performed to ensure that the given value is canonicalize-able as an ANSI
- color, but it is written as-is.
+- 'color': When getting a value, canonicalize by converting to an ANSI color
+ escape sequence. When setting a value, a sanity-check is performed to ensure
+ that the given value is canonicalize-able as an ANSI color, but it is written
+ as-is.
+
--bool::
@@ -233,8 +233,7 @@ Valid `<type>`'s include:
output. The optional `default` parameter is used instead, if
there is no color configured for `name`.
+
-It is preferred to use `--type=color`, or `--type=color [--default=<default>]`
-instead of `--get-color`.
+`--type=color [--default=<default>]` is preferred over `--get-color`.
-e::
--edit::
diff --git a/builtin/config.c b/builtin/config.c
index 0c7cfcf6c9..08016863ac 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -300,9 +300,9 @@ static int get_value(const char *key_, const char *regex_)
ALLOC_GROW(values.items, values.nr + 1, values.alloc);
item = &values.items[values.nr++];
strbuf_init(item, 0);
- if (format_config(item, key_, default_value) < 0) {
- die(_("failed to format default config value"));
- }
+ if (format_config(item, key_, default_value) < 0)
+ die(_("failed to format default config value: %s"),
+ default_value);
}
ret = !values.nr;
@@ -657,7 +657,6 @@ int cmd_config(int argc, const char **argv, const char *prefix)
usage_with_options(builtin_config_usage, builtin_config_options);
}
-
if (default_value && !(actions & ACTION_GET)) {
error("--default is only applicable to --get");
usage_with_options(builtin_config_usage,
@@ -814,3 +813,4 @@ int cmd_config(int argc, const char **argv, const char *prefix)
}
return 0;
+}
diff --git a/t/t1310-config-default.sh b/t/t1310-config-default.sh
index b74c932763..6049d91708 100755
--- a/t/t1310-config-default.sh
+++ b/t/t1310-config-default.sh
@@ -4,23 +4,21 @@ test_description='Test git config in different settings (with --default)'
. ./test-lib.sh
-test_expect_success 'uses --default when missing entry' '
+test_expect_success 'uses --default when entry missing' '
echo quux >expect &&
- git config -f config --default quux core.foo >actual &&
+ git config -f config --default=quux core.foo >actual &&
test_cmp expect actual
'
-test_expect_success 'canonicalizes --default with appropriate type' '
- echo true >expect &&
- git config -f config --default=true --bool core.foo >actual &&
+test_expect_success 'does not use --default when entry present' '
+ echo bar >expect &&
+ git -c core.foo=bar config --default=baz core.foo >actual &&
test_cmp expect actual
'
-test_expect_success 'uses entry when available' '
- echo bar >expect &&
- git config --add core.foo bar &&
- git config --default baz core.foo >actual &&
- git config --unset core.foo &&
+test_expect_success 'canonicalizes --default with appropriate type' '
+ echo true >expect &&
+ git config -f config --default=yes --bool core.foo >actual &&
test_cmp expect actual
'
--
2.17.0
next prev parent reply other threads:[~2018-04-10 0:18 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-06 2:17 [PATCH 0/4] Teach `--default` to `git-config(1)` Taylor Blau
2018-03-06 2:17 ` [PATCH 1/4] builtin/config: introduce `--default` Taylor Blau
2018-03-06 6:52 ` Jeff King
2018-03-06 7:14 ` Eric Sunshine
2018-03-06 7:08 ` Eric Sunshine
2018-03-06 2:17 ` [PATCH 2/4] Documentation: list all type specifiers in config prose Taylor Blau
2018-03-06 6:52 ` Jeff King
2018-03-06 7:40 ` Junio C Hamano
2018-03-06 2:17 ` [PATCH 3/4] config.c: introduce 'git_config_color' to parse ANSI colors Taylor Blau
2018-03-06 6:53 ` Jeff King
2018-03-06 2:17 ` [PATCH 4/4] builtin/config: introduce `--color` type specifier Taylor Blau
2018-03-06 7:00 ` Jeff King
2018-03-06 2:20 ` [PATCH 0/4] Teach `--default` to `git-config(1)` Taylor Blau
2018-03-24 0:55 ` [PATCH v2 " Taylor Blau
2018-03-24 0:55 ` [PATCH v2 1/4] builtin/config: introduce `--default` Taylor Blau
2018-03-26 8:34 ` Jeff King
2018-03-29 1:31 ` Taylor Blau
2018-03-24 0:55 ` [PATCH v2 2/4] Documentation: list all type specifiers in config prose Taylor Blau
2018-03-26 8:55 ` Jeff King
2018-03-29 1:32 ` Taylor Blau
2018-03-24 0:55 ` [PATCH v2 3/4] config.c: introduce 'git_config_color' to parse ANSI colors Taylor Blau
2018-03-24 0:55 ` [PATCH v2 4/4] builtin/config: introduce `--color` type specifier Taylor Blau
2018-03-26 9:16 ` Jeff King
2018-03-29 1:36 ` Taylor Blau
2018-03-26 9:18 ` [PATCH v2 0/4] Teach `--default` to `git-config(1)` Jeff King
2018-03-29 1:16 ` [PATCH v3 " Taylor Blau
2018-03-29 1:16 ` [PATCH v3 1/3] builtin/config: introduce `--default` Taylor Blau
2018-03-30 18:06 ` Junio C Hamano
2018-04-05 2:45 ` Taylor Blau
2018-03-30 20:23 ` Eric Sunshine
2018-04-05 2:46 ` Taylor Blau
2018-03-29 1:16 ` [PATCH v3 2/3] config.c: introduce 'git_config_color' to parse ANSI colors Taylor Blau
2018-03-30 20:26 ` Eric Sunshine
2018-04-05 2:47 ` Taylor Blau
2018-03-29 1:16 ` [PATCH v3 3/3] builtin/config: introduce `color` type specifier Taylor Blau
2018-03-30 18:09 ` Junio C Hamano
2018-04-05 2:48 ` Taylor Blau
2018-03-29 1:29 ` [PATCH v3 0/4] Teach `--default` to `git-config(1)` Taylor Blau
2018-04-05 2:58 ` [PATCH v4 0/3] " Taylor Blau
2018-04-05 22:37 ` Jeff King
[not found] ` <cover.1522896713.git.me@ttaylorr.com>
2018-04-05 2:59 ` [PATCH v4 1/3] builtin/config: introduce `--default` Taylor Blau
2018-04-05 22:29 ` Jeff King
2018-04-06 5:40 ` Taylor Blau
2018-04-08 23:18 ` Junio C Hamano
2018-04-10 0:20 ` Taylor Blau
2018-04-05 22:40 ` Eric Sunshine
2018-04-06 5:50 ` Taylor Blau
2018-04-05 2:59 ` [PATCH v4 2/3] config.c: introduce 'git_config_color' to parse ANSI colors Taylor Blau
2018-04-05 2:59 ` [PATCH v4 3/3] builtin/config: introduce `color` type specifier Taylor Blau
2018-04-05 22:36 ` Jeff King
2018-04-05 22:52 ` Eric Sunshine
2018-04-05 22:53 ` Jeff King
2018-04-06 6:05 ` Taylor Blau
2018-04-06 6:02 ` Taylor Blau
2018-04-06 5:27 ` [PATCH v5 0/2] *** SUBJECT HERE *** Taylor Blau
2018-04-06 5:40 ` Jacob Keller
2018-04-06 5:29 ` [PATCH v5 0/2] builtin/config.c: prefer `--type=bool` over `--bool`, etc Taylor Blau
2018-04-06 5:32 ` Taylor Blau
[not found] ` <cover.1522992443.git.me@ttaylorr.com>
2018-04-06 5:29 ` [PATCH v5 1/2] builtin/config.c: treat type specifiers singularly Taylor Blau
2018-04-06 5:29 ` [PATCH v5 2/2] builtin/config.c: prefer `--type=bool` over `--bool`, etc Taylor Blau
2018-04-06 6:14 ` Eric Sunshine
2018-04-06 6:41 ` Taylor Blau
2018-04-06 14:55 ` Jeff King
2018-04-07 1:00 ` Taylor Blau
2018-04-06 6:30 ` [PATCH v5 0/3] builtin/config: introduce `--default` Taylor Blau
[not found] ` <cover.1522996150.git.me@ttaylorr.com>
2018-04-06 6:30 ` [PATCH v5 1/3] " Taylor Blau
2018-04-06 6:53 ` Eric Sunshine
2018-04-06 7:40 ` Eric Sunshine
2018-04-07 0:58 ` Taylor Blau
2018-04-07 8:44 ` Eric Sunshine
2018-04-07 0:49 ` Taylor Blau
2018-04-07 8:38 ` Eric Sunshine
2018-04-06 6:30 ` [PATCH v5 2/3] config.c: introduce 'git_config_color' to parse ANSI colors Taylor Blau
2018-04-06 6:30 ` [PATCH v5 3/3] builtin/config: introduce `color` type specifier Taylor Blau
2018-04-06 7:29 ` Eric Sunshine
2018-04-07 0:42 ` Taylor Blau
2018-04-10 0:18 ` Taylor Blau [this message]
[not found] ` <cover.1523319159.git.me@ttaylorr.com>
2018-04-10 0:18 ` [PATCH v6 1/3] builtin/config: introduce `--default` Taylor Blau
2018-04-10 1:50 ` Junio C Hamano
2018-04-10 0:18 ` [PATCH v6 2/3] config.c: introduce 'git_config_color' to parse ANSI colors Taylor Blau
2018-04-10 0:18 ` [PATCH v6 3/3] builtin/config: introduce `color` type specifier Taylor Blau
2018-04-10 0:18 ` Taylor Blau
2018-04-10 1:54 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180410001822.GA67209@syl.local \
--to=me@ttaylorr.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=sunshine@sunshineco.com \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.