Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tests/config/write.c')
-rw-r--r--tests/config/write.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/config/write.c b/tests/config/write.c
index 15f750dc0..402be9317 100644
--- a/tests/config/write.c
+++ b/tests/config/write.c
@@ -303,3 +303,31 @@ void test_config_write__updating_a_locked_config_file_returns_ELOCKED(void)
git_config_free(cfg);
}
+
+void test_config_write__outside_change(void)
+{
+ int32_t tmp;
+ git_config *cfg;
+ const char *filename = "config-ext-change";
+
+ cl_git_mkfile(filename, "[old]\nvalue = 5\n");
+
+ cl_git_pass(git_config_open_ondisk(&cfg, filename));
+
+ cl_git_pass(git_config_get_int32(&tmp, cfg, "old.value"));
+
+ /* Change the value on the file itself (simulate external process) */
+ cl_git_mkfile(filename, "[old]\nvalue = 6\n");
+
+ cl_git_pass(git_config_set_int32(cfg, "new.value", 7));
+
+ cl_git_pass(git_config_get_int32(&tmp, cfg, "old.value"));
+ cl_assert_equal_i(6, tmp);
+
+ cl_git_pass(git_config_refresh(cfg));
+
+ cl_git_pass(git_config_get_int32(&tmp, cfg, "old.value"));
+ cl_assert_equal_i(6, tmp);
+
+ git_config_free(cfg);
+}