summaryrefslogtreecommitdiff
path: root/src/config_file.c
diff options
context:
space:
mode:
authoryorah <yoram.harmelin@gmail.com>2012-09-18 14:10:40 +0200
committeryorah <yoram.harmelin@gmail.com>2012-10-23 11:48:50 +0200
commitf8ede94808348ac12db1d5dd91e5f66624d8b40d (patch)
tree2c8f93bdadb9c7e1d2cfc118c7bf2431ef45f210 /src/config_file.c
parent8a89aa1f57fc0b352800bc77e228554fe95caddd (diff)
downloadlibgit2-f8ede94808348ac12db1d5dd91e5f66624d8b40d.tar.gz
Fix adding variable to config file with no trailing newline
This can occur after a manual modification of a config file.
Diffstat (limited to 'src/config_file.c')
-rw-r--r--src/config_file.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/config_file.c b/src/config_file.c
index 4ba83d1d9..12ae4a214 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -1182,6 +1182,10 @@ static int config_write(diskfile_backend *cfg, const char *key, const regex_t *p
goto rewrite_fail;
}
+ /* If we are here, there is at least a section line */
+ if (*(cfg->reader.buffer.ptr + cfg->reader.buffer.size - 1) != '\n')
+ git_filebuf_write(&file, "\n", 1);
+
git_filebuf_printf(&file, "\t%s = %s\n", name, value);
}
}