summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-05-31 22:27:19 +0200
committerPatrick Steinhardt <ps@pks.im>2017-07-15 14:14:50 +0200
commit1b32908973d687e4526079eeecdb82d9cb13c6e6 (patch)
treead967a300eb94ec365c95b258783331dad0dff42 /tests
parent28c2cc3de33a382a5ca6858c418ecd541ab57aeb (diff)
downloadlibgit2-1b32908973d687e4526079eeecdb82d9cb13c6e6.tar.gz
config_file: refuse modifying included variables
Modifying variables pulled in by an included file currently succeeds, but it doesn't actually do what one would expect, as refreshing the configuration will cause the values to reappear. As we are currently not really able to support this use case, we will instead just return an error for deleting and setting variables which were included via an include.
Diffstat (limited to 'tests')
-rw-r--r--tests/config/include.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/config/include.c b/tests/config/include.c
index bcf8e19ee..e440b9a78 100644
--- a/tests/config/include.c
+++ b/tests/config/include.c
@@ -146,3 +146,21 @@ void test_config_include__rewriting_include_refreshes_values(void)
cl_git_pass(git_config_get_string_buf(&buf, cfg, "first.other"));
cl_assert_equal_s(buf.ptr, "value");
}
+
+void test_config_include__included_variables_cannot_be_deleted(void)
+{
+ cl_git_mkfile("top-level", "[include]\npath = included\n");
+ cl_git_mkfile("included", "[foo]\nbar = value");
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "top-level"));
+ cl_git_fail(git_config_delete_entry(cfg, "foo.bar"));
+}
+
+void test_config_include__included_variables_cannot_be_modified(void)
+{
+ cl_git_mkfile("top-level", "[include]\npath = included\n");
+ cl_git_mkfile("included", "[foo]\nbar = value");
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "top-level"));
+ cl_git_fail(git_config_set_string(cfg, "foo.bar", "other-value"));
+}