From 9ac581bf7fffaf809214fdd950bb62d242ee52fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Sat, 1 Oct 2011 19:56:04 +0200 Subject: config: behave like git with [section.subsection] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The documentation is a bit misleading. The subsection name is always case-sensitive, but with a [section.subsection] header, the subsection is transformed to lowercase when the configuration is parsed. Signed-off-by: Carlos Martín Nieto --- tests/t15-config.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'tests/t15-config.c') diff --git a/tests/t15-config.c b/tests/t15-config.c index 3ec54fee..c4cb590f 100644 --- a/tests/t15-config.c +++ b/tests/t15-config.c @@ -107,10 +107,8 @@ BEGIN_TEST(config3, "parse a [section.subsection] header") must_pass(git_config_get_string(cfg, "section.subsection.var", &str)); must_be_true(!strcmp(str, "hello")); - /* Avoid a false positive */ - str = "nohello"; - must_pass(git_config_get_string(cfg, "section.subSectIon.var", &str)); - must_be_true(!strcmp(str, "hello")); + /* The subsection is transformed to lower-case */ + must_fail(git_config_get_string(cfg, "section.subSectIon.var", &str)); git_config_free(cfg); END_TEST @@ -324,6 +322,20 @@ BEGIN_TEST(config16, "add a variable in a new section") must_pass(git_filebuf_commit(&buf)); END_TEST +BEGIN_TEST(config17, "prefixes aren't broken") + git_config *cfg; + const char *str; + + must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9")); + must_pass(git_config_get_string(cfg, "remote.ab.url", &str)); + must_be_true(strcmp(str, "http://example.com/git/ab") == 0); + + must_pass(git_config_get_string(cfg, "remote.abba.url", &str)); + must_be_true(strcmp(str, "http://example.com/git/abba") == 0); + + git_config_free(cfg); +END_TEST + BEGIN_SUITE(config) ADD_TEST(config0); ADD_TEST(config1); @@ -342,4 +354,5 @@ BEGIN_SUITE(config) ADD_TEST(config14); ADD_TEST(config15); ADD_TEST(config16); + ADD_TEST(config17); END_SUITE -- cgit v1.2.1