mirror of
https://git.proxmox.com/git/libgit2
synced 2026-01-04 16:24:52 +00:00
Remotes: Save a cleaned pushurl (by deleting it from the config)
This commit is contained in:
parent
8689a69d09
commit
413d556384
17
src/remote.c
17
src/remote.c
@ -207,15 +207,24 @@ int git_remote_save(const git_remote *remote)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (remote->pushurl) {
|
||||
git_buf_clear(&buf);
|
||||
if (git_buf_printf(&buf, "remote.%s.pushurl", remote->name) < 0)
|
||||
return -1;
|
||||
git_buf_clear(&buf);
|
||||
if (git_buf_printf(&buf, "remote.%s.pushurl", remote->name) < 0)
|
||||
return -1;
|
||||
|
||||
if (remote->pushurl) {
|
||||
if (git_config_set_string(config, git_buf_cstr(&buf), remote->pushurl) < 0) {
|
||||
git_buf_free(&buf);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
int error = git_config_delete(config, git_buf_cstr(&buf));
|
||||
if (error == GIT_ENOTFOUND) {
|
||||
error = 0;
|
||||
}
|
||||
if (error < 0) {
|
||||
git_buf_free(&buf);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (remote->fetch.src != NULL && remote->fetch.dst != NULL) {
|
||||
|
||||
@ -120,6 +120,15 @@ void test_network_remotes__save(void)
|
||||
|
||||
cl_assert_equal_s(git_remote_url(_remote), "git://github.com/libgit2/libgit2");
|
||||
cl_assert_equal_s(git_remote_pushurl(_remote), "git://github.com/libgit2/libgit2_push");
|
||||
|
||||
/* remove the pushurl again and see if we can save that too */
|
||||
cl_git_pass(git_remote_set_pushurl(_remote, NULL));
|
||||
cl_git_pass(git_remote_save(_remote));
|
||||
git_remote_free(_remote);
|
||||
_remote = NULL;
|
||||
|
||||
cl_git_pass(git_remote_load(&_remote, _repo, "upstream"));
|
||||
cl_assert(git_remote_pushurl(_remote) == NULL);
|
||||
}
|
||||
|
||||
void test_network_remotes__fnmatch(void)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user