* Git config multiple values
@ 2017-10-06 11:10 aleksander.baranowski
2017-10-06 14:32 ` Jeff King
0 siblings, 1 reply; 6+ messages in thread
From: aleksander.baranowski @ 2017-10-06 11:10 UTC (permalink / raw)
To: git
Hi,
I'm currently using git version 2.14.2. There is possible to put
multiple values into same variable with git config.
Case 1:
# git config --global user.name Foo - returns 0
# git config --global user.name Bar - returns 0 and replace Foo to Bar
# git config --global user.name Foo - returns 0 and replace Bar to Foo
Case 2:
# git config --global user.name Foo - returns 0
# git config --global user.name Foo2 Bar - returns 0 and put second name
# cat ~/.gitconfig
[user]
email = aleksander.baranowski@yahoo.pl
name = Foo
name = Foo2
# git config --global user.name Foo - return 5 and message
"warning: user.name has multiple values
error: cannot overwrite multiple values with a single value
Use a regexp, --add or --replace-all to change user.name."
It's just an opinion, but this behaviour is no consistent for me.
If it's not the bug it's a feature just let me know.
Bests,
Alex
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Git config multiple values
2017-10-06 11:10 Git config multiple values aleksander.baranowski
@ 2017-10-06 14:32 ` Jeff King
2017-10-06 16:57 ` aleksander.baranowski
2017-10-06 17:25 ` Jonathan Nieder
0 siblings, 2 replies; 6+ messages in thread
From: Jeff King @ 2017-10-06 14:32 UTC (permalink / raw)
To: aleksander.baranowski; +Cc: git
On Fri, Oct 06, 2017 at 01:10:17PM +0200, aleksander.baranowski wrote:
> I'm currently using git version 2.14.2. There is possible to put
> multiple values into same variable with git config.
Yep, your examples should behave the same even with older versions.
> Case 1:
> # git config --global user.name Foo - returns 0
> # git config --global user.name Bar - returns 0 and replace Foo to Bar
> # git config --global user.name Foo - returns 0 and replace Bar to Foo
This is all as expected. You're hitting the first case in the manpage
synopsis here (I snipped the uninteresting options):
git config name [value [value_regex]]
So you're doing:
git config name value
which replaces any existing key by default. You could also do:
git config --add name value
to add without replacing (if you had a config key that takes multiple
values).
> Case 2:
> # git config --global user.name Foo - returns 0
> # git config --global user.name Foo2 Bar - returns 0 and put second name
Here you're doing:
git config name value value_regex
So we're replacing any values which match the regex "Bar" (and there are
none), and leaving others intact. Hence after this you will have two
user.name values.
If you wanted a name with two strings, you'd have to quote the string
from the shell to leave it as a single argument:
git config user.name "Foo2 Bar"
> # cat ~/.gitconfig
> [user]
> email = aleksander.baranowski@yahoo.pl
> name = Foo
> name = Foo2
Right, this is what I'd expect.
> # git config --global user.name Foo - return 5 and message
> "warning: user.name has multiple values
> error: cannot overwrite multiple values with a single value
> Use a regexp, --add or --replace-all to change user.name."
And this, too (though I forgot we had such a safety check).
> It's just an opinion, but this behaviour is no consistent for me.
>
> If it's not the bug it's a feature just let me know.
It's a feature, though I agree that git-config is rather baroque. We're
mostly stuck with it for reasons of backwards compatibility, though.
-Peff
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Git config multiple values
2017-10-06 14:32 ` Jeff King
@ 2017-10-06 16:57 ` aleksander.baranowski
2017-10-06 17:25 ` Jonathan Nieder
1 sibling, 0 replies; 6+ messages in thread
From: aleksander.baranowski @ 2017-10-06 16:57 UTC (permalink / raw)
To: Jeff King; +Cc: git
Hi!,
Thank you very much for descriptive answer.
You are absolutely right. I should read manual more carefully! Still
it's quite odd interface. Thank you for your time.
Bests,
Alex
On 10/06/2017 04:32 PM, Jeff King wrote:
> On Fri, Oct 06, 2017 at 01:10:17PM +0200, aleksander.baranowski wrote:
>
>> I'm currently using git version 2.14.2. There is possible to put
>> multiple values into same variable with git config.
>
> Yep, your examples should behave the same even with older versions.
>
>> Case 1:
>> # git config --global user.name Foo - returns 0
>> # git config --global user.name Bar - returns 0 and replace Foo to Bar
>> # git config --global user.name Foo - returns 0 and replace Bar to Foo
>
> This is all as expected. You're hitting the first case in the manpage
> synopsis here (I snipped the uninteresting options):
>
> git config name [value [value_regex]]
>
> So you're doing:
>
> git config name value
>
> which replaces any existing key by default. You could also do:
>
> git config --add name value
>
> to add without replacing (if you had a config key that takes multiple
> values).
>
>> Case 2:
>> # git config --global user.name Foo - returns 0
>> # git config --global user.name Foo2 Bar - returns 0 and put second name
>
> Here you're doing:
>
> git config name value value_regex
>
> So we're replacing any values which match the regex "Bar" (and there are
> none), and leaving others intact. Hence after this you will have two
> user.name values.
>
> If you wanted a name with two strings, you'd have to quote the string
> from the shell to leave it as a single argument:
>
> git config user.name "Foo2 Bar"
>
>> # cat ~/.gitconfig
>> [user]
>> email = aleksander.baranowski@yahoo.pl
>> name = Foo
>> name = Foo2
>
> Right, this is what I'd expect.
>
>> # git config --global user.name Foo - return 5 and message
>> "warning: user.name has multiple values
>> error: cannot overwrite multiple values with a single value
>> Use a regexp, --add or --replace-all to change user.name."
>
> And this, too (though I forgot we had such a safety check).
>
>> It's just an opinion, but this behaviour is no consistent for me.
>>
>> If it's not the bug it's a feature just let me know.
>
> It's a feature, though I agree that git-config is rather baroque. We're
> mostly stuck with it for reasons of backwards compatibility, though.
>
> -Peff
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Git config multiple values
2017-10-06 14:32 ` Jeff King
2017-10-06 16:57 ` aleksander.baranowski
@ 2017-10-06 17:25 ` Jonathan Nieder
2017-10-06 17:28 ` Jeff King
2017-10-06 18:58 ` Andreas Heiduk
1 sibling, 2 replies; 6+ messages in thread
From: Jonathan Nieder @ 2017-10-06 17:25 UTC (permalink / raw)
To: Jeff King; +Cc: aleksander.baranowski, git
Hi,
Jeff King wrote:
> On Fri, Oct 06, 2017 at 01:10:17PM +0200, aleksander.baranowski wrote:
>> It's just an opinion, but this behaviour is no consistent for me.
>>
>> If it's not the bug it's a feature just let me know.
>
> It's a feature, though I agree that git-config is rather baroque. We're
> mostly stuck with it for reasons of backwards compatibility, though.
This feels like a dodge. Can we make a list of what is baroque here,
with an eye to fixing it? E.g. if we introduce a new --set option,
then what should its semantics be, to be more intuitive?
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Git config multiple values
2017-10-06 17:25 ` Jonathan Nieder
@ 2017-10-06 17:28 ` Jeff King
2017-10-06 18:58 ` Andreas Heiduk
1 sibling, 0 replies; 6+ messages in thread
From: Jeff King @ 2017-10-06 17:28 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: aleksander.baranowski, git
On Fri, Oct 06, 2017 at 10:25:30AM -0700, Jonathan Nieder wrote:
> Jeff King wrote:
> > On Fri, Oct 06, 2017 at 01:10:17PM +0200, aleksander.baranowski wrote:
>
> >> It's just an opinion, but this behaviour is no consistent for me.
> >>
> >> If it's not the bug it's a feature just let me know.
> >
> > It's a feature, though I agree that git-config is rather baroque. We're
> > mostly stuck with it for reasons of backwards compatibility, though.
>
> This feels like a dodge. Can we make a list of what is baroque here,
> with an eye to fixing it? E.g. if we introduce a new --set option,
> then what should its semantics be, to be more intuitive?
Maybe baroque isn't the right word. But changing the function of a
command drastically based on the number of arguments seems like a source
of confusion.
I'm fine if somebody wants to champion a new "--set" option, but frankly
I'm not sure it's worth the pain at this point.
-Peff
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Git config multiple values
2017-10-06 17:25 ` Jonathan Nieder
2017-10-06 17:28 ` Jeff King
@ 2017-10-06 18:58 ` Andreas Heiduk
1 sibling, 0 replies; 6+ messages in thread
From: Andreas Heiduk @ 2017-10-06 18:58 UTC (permalink / raw)
To: Jonathan Nieder, Jeff King; +Cc: aleksander.baranowski, git
Hi,
Am 06.10.2017 um 19:25 schrieb Jonathan Nieder:
> Hi,
>
> Jeff King wrote:
>> On Fri, Oct 06, 2017 at 01:10:17PM +0200, aleksander.baranowski wrote:
>
>>> It's just an opinion, but this behaviour is no consistent for me.
>>>
>>> If it's not the bug it's a feature just let me know.
>>
>> It's a feature, though I agree that git-config is rather baroque. We're
>> mostly stuck with it for reasons of backwards compatibility, though.
>
> This feels like a dodge. Can we make a list of what is baroque here,
> with an eye to fixing it? E.g. if we introduce a new --set option,
> then what should its semantics be, to be more intuitive?
My reading of the manual for
git config --global user.name Foo2 Bar
is this:
Multiple lines can be added to an option by using the --add option.
Does not apply here - no `--add` option, so no new value should be added.
If you want to update or unset an option which can occur on multiple
lines, a POSIX regexp value_regex needs to be given.
does not apply: First: no "--unset" variant is used here leaving only "update".
Second: before that command there is only one value.
Only the existing values that match the regexp are updated or unset.
Since "Two" does not match the previous value and `update` is the only
described case left I'd expect that the command changes nothing.I don't
understand how the description allows `git config` to add a new value,
because the manual talks about "update" twice, nothing about adding.
Confused
--Andreas
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-10-06 18:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-06 11:10 Git config multiple values aleksander.baranowski
2017-10-06 14:32 ` Jeff King
2017-10-06 16:57 ` aleksander.baranowski
2017-10-06 17:25 ` Jonathan Nieder
2017-10-06 17:28 ` Jeff King
2017-10-06 18:58 ` Andreas Heiduk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).