summaryrefslogtreecommitdiff
path: root/src/config.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2011-12-16 02:28:39 +0100
committerCarlos Martín Nieto <carlos@cmartin.tk>2011-12-16 02:28:39 +0100
commit80a665aaca70ea3f5fda0955c39884bead13d2a2 (patch)
tree73c1b97da7441e71ac129a58a8dad992e695a402 /src/config.c
parent7b2b4adfb1cb71f085a88418d1d5b631bf26ebd8 (diff)
downloadlibgit2-80a665aaca70ea3f5fda0955c39884bead13d2a2.tar.gz
config: really delete variables
Instead of just setting the value to NULL, which gives unwanted results when asking for that variable after deleting it, delete the variable from the list and re-write the file.
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/config.c b/src/config.c
index 2e341d256..ed7c947ed 100644
--- a/src/config.c
+++ b/src/config.c
@@ -162,7 +162,16 @@ int git_config_foreach(git_config *cfg, int (*fn)(const char *, const char *, vo
int git_config_delete(git_config *cfg, const char *name)
{
- return git_config_set_string(cfg, name, NULL);
+ file_internal *internal;
+ git_config_file *file;
+
+ if (cfg->files.length == 0)
+ return git__throw(GIT_EINVALIDARGS, "Cannot delete variable; no files open in the `git_config` instance");
+
+ internal = git_vector_get(&cfg->files, 0);
+ file = internal->file;
+
+ return file->delete(file, name);
}
/**************