diff options
author | Linquize <linquize@yahoo.com.hk> | 2014-07-16 21:09:53 +0800 |
---|---|---|
committer | Linquize <linquize@yahoo.com.hk> | 2014-07-16 21:09:53 +0800 |
commit | 991dab2dd09baa23bd216896a273cf6c256fa7b4 (patch) | |
tree | c1ea19758553a5cb9a67fe3d2b6a39d76d7b2b53 /src/config_file.c | |
parent | ad082501a76da1e007dd9c47e91e0f975526e531 (diff) | |
download | libgit2-991dab2dd09baa23bd216896a273cf6c256fa7b4.tar.gz |
Make sure \n is at the end of config file before a new section is written
Diffstat (limited to 'src/config_file.c')
-rw-r--r-- | src/config_file.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/config_file.c b/src/config_file.c index 56271144b..393a0b547 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -1522,6 +1522,9 @@ static int config_write(diskfile_backend *cfg, const char *key, const regex_t *p git_filebuf_write(&file, reader->buffer.ptr, reader->buffer.size); + if (reader->buffer.size > 0 && *(reader->buffer.ptr + reader->buffer.size - 1) != '\n') + git_filebuf_write(&file, "\n", 1); + /* And now if we just need to add a variable */ if (!section_matches && write_section(&file, section) < 0) goto rewrite_fail; @@ -1536,9 +1539,6 @@ static int config_write(diskfile_backend *cfg, const char *key, const regex_t *p } /* If we are here, there is at least a section line */ - if (reader->buffer.size > 0 && *(reader->buffer.ptr + reader->buffer.size - 1) != '\n') - git_filebuf_write(&file, "\n", 1); - q = quotes_for_value(value); git_filebuf_printf(&file, "\t%s = %s%s%s\n", name, q, value, q); } |