config: fix case sensitive subsection names on writing
authorStefan Beller <sbeller@google.com>
Wed, 8 Aug 2018 19:50:19 +0000 (12:50 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Aug 2018 20:26:48 +0000 (13:26 -0700)
A user reported a submodule issue regarding a section mix-up,
but it could be boiled down to the following test case:

$ git init test && cd test
$ git config foo."Bar".key test
$ git config foo."bar".key test
$ tail -n 3 .git/config
[foo "Bar"]
key = test
key = test

Sub sections are case sensitive and we have a test for correctly reading
them. However we do not have a test for writing out config correctly with
case sensitive subsection names, which is why this went unnoticed in
6ae996f2acf (git_config_set: make use of the config parser's event
stream, 2018-04-09)

Unfortunately we have to make a distinction between old style configuration
that looks like

[foo.Bar]
key = test

and the new quoted style as seen above. The old style is documented as
case-agnostic, hence we need to keep 'strncasecmp'; although the
resulting setting for the old style config differs from the configuration.
That will be fixed in a follow up patch.

Reported-by: JP Sugarbroad <jpsugar@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
No differences found