Commit 39d7cf60 by Vicent Martí

Merge pull request #1059 from nulltoken/fix/config-open-level

config: make git_config_open_level() work with an empty config
parents 0f674411 55f9837f
...@@ -127,8 +127,6 @@ static int find_internal_file_by_level( ...@@ -127,8 +127,6 @@ static int find_internal_file_by_level(
file_internal *internal; file_internal *internal;
unsigned int i; unsigned int i;
assert(cfg->files.length);
/* when passing GIT_CONFIG_HIGHEST_LEVEL, the idea is to get the config file /* 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 * 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 * sorted by decreasing order of level, getting the file at position 0
......
...@@ -57,3 +57,16 @@ void test_config_configlevel__can_read_from_a_single_level_focused_file_after_pa ...@@ -57,3 +57,16 @@ void test_config_configlevel__can_read_from_a_single_level_focused_file_after_pa
git_config_free(single_level_cfg); 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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment