summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/config/include.c30
-rw-r--r--tests/config/snapshot.c26
2 files changed, 56 insertions, 0 deletions
diff --git a/tests/config/include.c b/tests/config/include.c
index 48261dd92..e2b0fc96c 100644
--- a/tests/config/include.c
+++ b/tests/config/include.c
@@ -202,3 +202,33 @@ void test_config_include__included_variables_cannot_be_modified(void)
cl_git_pass(p_unlink("top-level"));
cl_git_pass(p_unlink("included"));
}
+
+void test_config_include__variables_in_included_override_including(void)
+{
+ int i;
+
+ cl_git_mkfile("top-level", "[foo]\nbar = 1\n[include]\npath = included");
+ cl_git_mkfile("included", "[foo]\nbar = 2");
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "top-level"));
+ cl_git_pass(git_config_get_int32(&i, cfg, "foo.bar"));
+ cl_assert_equal_i(i, 2);
+
+ cl_git_pass(p_unlink("top-level"));
+ cl_git_pass(p_unlink("included"));
+}
+
+void test_config_include__variables_in_including_override_included(void)
+{
+ int i;
+
+ cl_git_mkfile("top-level", "[include]\npath = included\n[foo]\nbar = 1");
+ cl_git_mkfile("included", "[foo]\nbar = 2");
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "top-level"));
+ cl_git_pass(git_config_get_int32(&i, cfg, "foo.bar"));
+ cl_assert_equal_i(i, 1);
+
+ cl_git_pass(p_unlink("top-level"));
+ cl_git_pass(p_unlink("included"));
+}
diff --git a/tests/config/snapshot.c b/tests/config/snapshot.c
index 2e0679e25..61562d206 100644
--- a/tests/config/snapshot.c
+++ b/tests/config/snapshot.c
@@ -74,3 +74,29 @@ void test_config_snapshot__multivar(void)
cl_git_pass(p_unlink("config"));
}
+
+void test_config_snapshot__includes(void)
+{
+ int i;
+
+ cl_git_mkfile("including", "[include]\npath = included");
+ cl_git_mkfile("included", "[section]\nkey = 1\n");
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "including"));
+ cl_git_pass(git_config_snapshot(&snapshot, cfg));
+
+ cl_git_pass(git_config_get_int32(&i, snapshot, "section.key"));
+ cl_assert_equal_i(i, 1);
+
+ /* Rewrite "included" config */
+ cl_git_mkfile("included", "[section]\nkey = 11\n");
+
+ /* Assert that the live config changed, but snapshot remained the same */
+ cl_git_pass(git_config_get_int32(&i, cfg, "section.key"));
+ cl_assert_equal_i(i, 11);
+ cl_git_pass(git_config_get_int32(&i, snapshot, "section.key"));
+ cl_assert_equal_i(i, 1);
+
+ cl_git_pass(p_unlink("including"));
+ cl_git_pass(p_unlink("included"));
+}