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:
authorCarlos Martín Nieto <cmn@dwim.me>2014-08-09 12:56:50 +0400
committerCarlos Martín Nieto <cmn@dwim.me>2014-08-09 13:06:49 +0400
commit9dac1f957945f706f3f557ff0b964f3d33d761b4 (patch)
tree931ad3d194ae82be8fecb861a514ef8c912bef33 /tests/config
parentbb9e6028b8ec54c01b35f838e8eca7c81d4b751a (diff)
config: a multiline var can start immediately
In the check for multiline, we traverse the backslashes from the end backwards and int the end assert that we haven't gone past the beginning of the line. We make sure of this in the loop condition, but we also check in the return value. However, for certain configurations, a line in a multiline variable might be empty to aid formatting. In that case, 'end' == 'start', since we ended up looking at the first char which made it a multiline. There is no need for the (end > start) check in the return, since the loop guarantees we won't go further back than the first char in the line, and we do accept the first char to be the final backslash. This fixes #2483.
Diffstat (limited to 'tests/config')
-rw-r--r--tests/config/stress.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/config/stress.c b/tests/config/stress.c
index eeca54ff4..488915e79 100644
--- a/tests/config/stress.c
+++ b/tests/config/stress.c
@@ -90,3 +90,16 @@ void test_config_stress__trailing_backslash(void)
cl_assert_equal_s(path, str);
git_config_free(config);
}
+
+void test_config_stress__complex(void)
+{
+ git_config *config;
+ const char *str;
+ const char *path = "./config-immediate-multiline";
+
+ cl_git_mkfile(path, "[imm]\n multi = \"\\\nfoo\"");
+ cl_git_pass(git_config_open_ondisk(&config, path));
+ cl_git_pass(git_config_get_string(&str, config, "imm.multi"));
+ cl_assert_equal_s(str, "foo");
+ git_config_free(config);
+}