summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2012-11-09 13:15:57 -0800
committerVicent Martí <vicent@github.com>2012-11-09 13:15:57 -0800
commit39d7cf60de8bed86c69892c3076bd929dce02b8a (patch)
tree5722b6c654c5e9e44a198a4dd07507e65a0479be
parent0f674411e9358a9d42ba892e853c6abd2303f296 (diff)
parent55f9837f11cae1d9c56e9f81eba3a3b7553ec8dd (diff)
downloadlibgit2-39d7cf60de8bed86c69892c3076bd929dce02b8a.tar.gz
Merge pull request #1059 from nulltoken/fix/config-open-level
config: make git_config_open_level() work with an empty config
-rw-r--r--src/config.c2
-rw-r--r--tests-clar/config/configlevel.c13
2 files changed, 13 insertions, 2 deletions
diff --git a/src/config.c b/src/config.c
index 033bde425..9945aaed7 100644
--- a/src/config.c
+++ b/src/config.c
@@ -127,8 +127,6 @@ static int find_internal_file_by_level(
file_internal *internal;
unsigned int i;
- assert(cfg->files.length);
-
/* when passing GIT_CONFIG_HIGHEST_LEVEL, the idea is to get the config file
* which has the highest level. As config files are stored in a vector
* sorted by decreasing order of level, getting the file at position 0
diff --git a/tests-clar/config/configlevel.c b/tests-clar/config/configlevel.c
index d947856fa..69aede6d3 100644
--- a/tests-clar/config/configlevel.c
+++ b/tests-clar/config/configlevel.c
@@ -57,3 +57,16 @@ void test_config_configlevel__can_read_from_a_single_level_focused_file_after_pa
git_config_free(single_level_cfg);
}
+
+void test_config_configlevel__fetching_a_level_from_an_empty_compound_config_returns_ENOTFOUND(void)
+{
+ git_config *cfg;
+ git_config *local_cfg;
+ const char *s;
+
+ cl_git_pass(git_config_new(&cfg));
+
+ cl_assert_equal_i(GIT_ENOTFOUND, git_config_open_level(&local_cfg, cfg, GIT_CONFIG_LEVEL_LOCAL));
+
+ git_config_free(cfg);
+}