diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2022-01-05 09:18:59 -0500 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2022-01-05 09:18:59 -0500 |
| commit | 83a1e614fa4435d8708792202e4f2f2c0b3ce51f (patch) | |
| tree | 11f3d9a1fbc5690d9b5703e7ba59f04982610e84 /tests | |
| parent | 50b4d53ef3897fd4066cd74734f4a6e141a64201 (diff) | |
| download | libgit2-83a1e614fa4435d8708792202e4f2f2c0b3ce51f.tar.gz | |
config: handle empty conditional in includeIf
When a config file contains `[includeIf]` (with no condition), we should
treat that as a falsey value. This means that we should properly parse
a config value of `includeIf.path`.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/config/conditionals.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/config/conditionals.c b/tests/config/conditionals.c index 6249dbd79..564719dcb 100644 --- a/tests/config/conditionals.c +++ b/tests/config/conditionals.c @@ -148,3 +148,28 @@ void test_config_conditionals__onbranch(void) assert_condition_includes("onbranch", "dir*", false); assert_condition_includes("onbranch", "dir/*", false); } + +void test_config_conditionals__empty(void) +{ + git_buf value = GIT_BUF_INIT; + git_str buf = GIT_STR_INIT; + git_config *cfg; + + cl_git_pass(git_str_puts(&buf, "[includeIf]\n")); + cl_git_pass(git_str_puts(&buf, "path = other\n")); + + cl_git_mkfile("empty_standard_repo/.git/config", buf.ptr); + cl_git_mkfile("empty_standard_repo/.git/other", "[foo]\nbar=baz\n"); + _repo = cl_git_sandbox_reopen(); + + git_str_dispose(&buf); + + cl_git_pass(git_repository_config(&cfg, _repo)); + + cl_git_fail_with(GIT_ENOTFOUND, + git_config_get_string_buf(&value, cfg, "foo.bar")); + + git_str_dispose(&buf); + git_buf_dispose(&value); + git_config_free(cfg); +} |
