diff options
author | Daniel Rodríguez Troitiño <drodrigueztroitino@yahoo.es> | 2013-10-31 04:08:50 +0400 |
---|---|---|
committer | Daniel Rodríguez Troitiño <drodrigueztroitino@yahoo.es> | 2013-11-01 03:08:52 +0400 |
commit | 3793fa9b181f3595c24a1cc517646f8e7a4a7175 (patch) | |
tree | bb78115b16c217afa41257af7ea4af12ad23896b /src/remote.c | |
parent | f93f3790c511d3ed821bf63fdaf5aeec155e195b (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/remote.c')
-rw-r--r-- | src/remote.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/remote.c b/src/remote.c index bdfa08642..e2b40347a 100644 --- a/src/remote.c +++ b/src/remote.c @@ -365,16 +365,18 @@ static int update_config_refspec(const git_remote *remote, git_config *config, i const char *dir; size_t i; int error = 0; + const char *cname; push = direction == GIT_DIRECTION_PUSH; dir = push ? "push" : "fetch"; if (git_buf_printf(&name, "remote.%s.%s", remote->name, dir) < 0) return -1; + cname = git_buf_cstr(&name); /* Clear out the existing config */ while (!error) - error = git_config_delete_entry(config, git_buf_cstr(&name)); + error = git_config_delete_multivar(config, cname, ".*"); if (error != GIT_ENOTFOUND) return error; @@ -386,7 +388,7 @@ static int update_config_refspec(const git_remote *remote, git_config *config, i continue; if ((error = git_config_set_multivar( - config, git_buf_cstr(&name), "", spec->string)) < 0) { + config, cname, "", spec->string)) < 0) { goto cleanup; } } |