summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Roden-Corrent <ryrode@microsoft.com>2015-04-16 15:32:16 -0400
committerRyan Roden-Corrent <ryrode@microsoft.com>2015-04-21 14:24:08 -0400
commit9a810c5e336afe10188c7cf3fb68c598d3c2a876 (patch)
treeb78cfb534931a16d46a4d00e96ccea403c21e6ae
parentf56a417de4b2b670b6c86017f73671a519989488 (diff)
downloadlibgit2-9a810c5e336afe10188c7cf3fb68c598d3c2a876.tar.gz
git_config_delete: search until last section.
If git_config_delete is to work properly in the presence of duplicate section headers, it cannot stop searching at the end of the first matching section, as there may be another matching section later. When config_write is used for deletion (value = NULL), it may only terminate when the desired key is found or there are no sections left to parse.
-rw-r--r--src/config_file.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/config_file.c b/src/config_file.c
index 350473434..7c6cb81fe 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -1460,9 +1460,12 @@ static int config_write(diskfile_backend *cfg, const char *key, const regex_t *p
* don't loose that information, but we only need to
* update post_start if we're going to use it in this
* iteration.
+ * If the section doesn't match and we are trying to delete an entry
+ * (value == NULL), we must continue searching; there may be another
+ * matching section later.
*/
if (!section_matches) {
- if (!last_section_matched) {
+ if (!last_section_matched || value == NULL) {
reader_consume_line(reader);
continue;
}