Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Rodríguez Troitiño <drodrigueztroitino@yahoo.es>2013-10-31 04:08:50 +0400
committerDaniel Rodríguez Troitiño <drodrigueztroitino@yahoo.es>2013-11-01 03:08:52 +0400
commit3793fa9b181f3595c24a1cc517646f8e7a4a7175 (patch)
treebb78115b16c217afa41257af7ea4af12ad23896b /src/config.c
parentf93f3790c511d3ed821bf63fdaf5aeec155e195b (diff)
Fix saving remotes with several fetch/push ref specs.
At some moment git_config_delete_entry lost the ability to delete one entry of a multivar configuration. The moment you had more than one fetch or push ref spec for a remote you will not be able to save that remote anymore. The changes in network::remote::remotes::save show that problem. I needed to create a new git_config_delete_multivar because I was not able to remove one or several entries of a multivar config with the current API. Several tries modifying how git_config_set_multivar(..., NULL) behaved were not successful. git_config_delete_multivar is very similar to git_config_set_multivar, and delegates into config_delete_multivar of config_file. This function search for the cvar_t that will be deleted, storing them in a temporal array, and rebuilding the linked list. After calling config_write to delete the entries, the cvar_t stored in the temporal array are freed. There is a little fix in config_write, it avoids an infinite loop when using a regular expression (case for the multivars). This error was found by the test network::remote::remotes::tagopt.
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
index c98d6a52d..0d9471383 100644
--- a/src/config.c
+++ b/src/config.c
@@ -862,6 +862,19 @@ int git_config_set_multivar(git_config *cfg, const char *name, const char *regex
return file->set_multivar(file, name, regexp, value);
}
+int git_config_delete_multivar(git_config *cfg, const char *name, const char *regexp)
+{
+ git_config_backend *file;
+ file_internal *internal;
+
+ internal = git_vector_get(&cfg->files, 0);
+ if (!internal || !internal->file)
+ return config_error_nofiles(name);
+ file = internal->file;
+
+ return file->del_multivar(file, name, regexp);
+}
+
int git_config_next(git_config_entry **entry, git_config_iterator *iter)
{
return iter->next(entry, iter);