Re: [PATCH v3 1/3] builtin/config: introduce `--default`
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Mar 30, 2018, 20:23 UTC
- Message-ID
- <CAPig+cSk_H-Dh585JsynNfp1GSuXSkKay0Vo3Jhda6-vPdi6Uw@mail.gmail.com>
- In-Reply-To
- <20180329011634.68582-2-me@ttaylorr.com>
On Wed, Mar 28, 2018 at 9:16 PM, Taylor Blau <me@ttaylorr.com> wrote:
Show 25 quoted lines
> For some use cases, callers of the `git-config(1)` builtin would like to > fallback to default values when the slot asked for does not exist. In > addition, users would like to use existing type specifiers to ensure > that values are parsed correctly when they do exist in the > configuration. > > For example, to fetch a value without a type specifier and fallback to > `$fallback`, the following is required: > > $ git config core.foo || echo "$fallback" > > This is fine for most values, but can be tricky for difficult-to-express > `$fallback`'s, like ANSI color codes. > > This motivates `--get-color`, which is a one-off exception to the normal > type specifier rules wherein a user specifies both the configuration > slot and an optional fallback. Both are formatted according to their > type specifier, which eases the burden on the user to ensure that values > are correctly formatted. > > This commit (and those following it in this series) aim to eventually > replace `--get-color` with a consistent alternative. By introducing > `--default`, we allow the `--get-color` action to be promoted to a > `--color` type specifier, retaining the "fallback" behavior via the > `--default` flag introduced in this commit.
I'm confused. The cover letter said that this iteration no longer introduces a --color option (favoring instead --type=color), but this commit message still talks about --color. Did you mean s/--color/--type=color/ ?
Show 7 quoted lines
> For example, we aim to replace: > > $ git config --get-color slot [default] [...] > > with: > > $ git config --default default --color slot [...]
Ditto: s/--color/--type=color/
Show 12 quoted lines
> Values filled by `--default` behave exactly as if they were present in > the affected configuration file; they will be parsed by type specifiers > without the knowledge that they are not themselves present in the > configuration. > > Specifically, this means that the following will work: > > $ git config --int --default 1M does.not.exist > 1048576 > > In subsequent commits, we will offer `--color`, which (in conjunction > with `--default`) will be sufficient to replace `--get-color`.
Ditto: s/--color/--type=color/
> Signed-off-by: Taylor Blau <me@ttaylorr.com>