mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-04 15:07:41 +00:00
Make sure \n is at the end of config file before a new section is written
This commit is contained in:
parent
ad082501a7
commit
991dab2dd0
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user