Commit 59403f1ff55346c64bfaa0744ea7f3375da71725

Vicent Marti 2014-08-09T12:24:02

Merge pull request #2509 from libgit2/cmn/immediate-multiline config: a multiline var can start immediately

diff --git a/src/config_file.c b/src/config_file.c
index 393a0b5..7106f18 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -1649,7 +1649,7 @@ static int is_multiline_var(const char *str)
 	}
 
 	/* An odd number means last backslash wasn't escaped, so it's multiline */
-	return (end > str) && (count & 1);
+	return count & 1;
 }
 
 static int parse_multiline_variable(struct reader *reader, git_buf *value, int in_quotes)
diff --git a/tests/config/stress.c b/tests/config/stress.c
index eeca54f..488915e 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);
+}