Re: [PATCH v5 08/14] builtin/config: introduce "get" subcommand
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 3, 2025, 22:30 UTC
- Message-ID
- <xmqqjz3kdomv.fsf@gitster.g>
- In-Reply-To
- <aI+oQvQgnNtC6DVw@szeder.dev>
SZEDER Gábor <szeder.dev@gmail.com> writes:
Show 16 quoted lines
>> #!/bin/sh
>> -WS=$(git config --get-color color.diff.whitespace "blue reverse")
>> -RESET=$(git config --get-color "" "reset")
>> +WS=$(git config get --type=color --default="blue reverse" color.diff.whitespace)
>> +RESET=$(git config get --type=color --default="reset" "")
>> echo "${WS}your whitespace color or blue reverse${RESET}"
>
> In this example the second command in the postimage doesn't work:
>
> $ RESET=$(git config get --type=color --default="reset" "")
> error: key does not contain a section:
>
> Consequently, the last command doesn't work as expected anymore,
> because the color is not reset at the end of the output.
>
> Luckily, the commands in the preimage still work.Instead of an empty string as a configuration variable, using something like no.such.variable that does not exist would also be a workaround. I.e.,
RESET=$(git config get --type=color --default=reset no.such.variable)
What is bad about this is that there is no generic variable that is guaranteed to be unset.