]> git.ipfire.org Git - thirdparty/git.git/commit - Documentation/git-config.txt
builtin/config.c: support `--type=<type>` as preferred alias for `--<type>`
authorTaylor Blau <me@ttaylorr.com>
Wed, 18 Apr 2018 21:43:35 +0000 (14:43 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 19 Apr 2018 02:49:19 +0000 (11:49 +0900)
commitfb0dc3bac135e9f6243bd6d293e8c9293c73b9cd
treecb2870a582884898d13abec3d15078d49c6d3bae
parent0a8950be5d5d8699b4c1f31116bdf896278db484
builtin/config.c: support `--type=<type>` as preferred alias for `--<type>`

`git config` has long allowed the ability for callers to provide a 'type
specifier', which instructs `git config` to (1) ensure that incoming
values can be interpreted as that type, and (2) that outgoing values are
canonicalized under that type.

In another series, we propose to extend this functionality with
`--type=color` and `--default` to replace `--get-color`.

However, we traditionally use `--color` to mean "colorize this output",
instead of "this value should be treated as a color".

Currently, `git config` does not support this kind of colorization, but
we should be careful to avoid squatting on this option too soon, so that
`git config` can support `--color` (in the traditional sense) in the
future, if that is desired.

In this patch, we support `--type=<int|bool|bool-or-int|...>` in
addition to `--int`, `--bool`, and etc. This allows the aforementioned
upcoming patch to support querying a color value with a default via
`--type=color --default=...`, without squandering `--color`.

We retain the historic behavior of complaining when multiple,
legacy-style `--<type>` flags are given, as well as extend this to
conflicting new-style `--type=<type>` flags. `--int --type=int` (and its
commutative pair) does not complain, but `--bool --type=int` (and its
commutative pair) does.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-config.txt
builtin/config.c
t/t1300-repo-config.sh