mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-04 14:13:19 +00:00
Merge pull request #1279 from carlosmn/config-trailing-backslash
config: support trailing backslashes
This commit is contained in:
commit
ae386101d2
@ -1319,8 +1319,15 @@ out:
|
|||||||
|
|
||||||
static int is_multiline_var(const char *str)
|
static int is_multiline_var(const char *str)
|
||||||
{
|
{
|
||||||
|
int count = 0;
|
||||||
const char *end = str + strlen(str);
|
const char *end = str + strlen(str);
|
||||||
return (end > str) && (end[-1] == '\\');
|
while (end > str && end[-1] == '\\') {
|
||||||
|
count++;
|
||||||
|
end--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* An odd number means last backslash wasn't escaped, so it's multiline */
|
||||||
|
return (end > str) && (count & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_multiline_variable(diskfile_backend *cfg, git_buf *value, int in_quotes)
|
static int parse_multiline_variable(diskfile_backend *cfg, git_buf *value, int in_quotes)
|
||||||
|
@ -73,3 +73,20 @@ void test_config_stress__escape_subsection_names(void)
|
|||||||
cl_assert(!strcmp("foo", str));
|
cl_assert(!strcmp("foo", str));
|
||||||
git_config_free(config);
|
git_config_free(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_config_stress__trailing_backslash(void)
|
||||||
|
{
|
||||||
|
git_config *config;
|
||||||
|
const char *str;
|
||||||
|
const char *path = "C:\\iam\\some\\windows\\path\\";
|
||||||
|
|
||||||
|
cl_assert(git_path_exists("git-test-config"));
|
||||||
|
cl_git_pass(git_config_open_ondisk(&config, TEST_CONFIG));
|
||||||
|
cl_git_pass(git_config_set_string(config, "windows.path", path));
|
||||||
|
git_config_free(config);
|
||||||
|
|
||||||
|
cl_git_pass(git_config_open_ondisk(&config, TEST_CONFIG));
|
||||||
|
cl_git_pass(git_config_get_string(&str, config, "windows.path"));
|
||||||
|
cl_assert_equal_s(path, str);
|
||||||
|
git_config_free(config);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user