mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-19 22:44:42 +00:00
API to set a dangling remote's repository
This commit is contained in:
parent
a71c27ccda
commit
b914e17d82
@ -51,6 +51,16 @@ typedef int (*git_remote_rename_problem_cb)(const char *problematic_refspec, voi
|
|||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_remote_new(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch);
|
GIT_EXTERN(int) git_remote_new(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the owning repository for the remote. This is only allowed on
|
||||||
|
* dangling remotes.
|
||||||
|
*
|
||||||
|
* @param remote the remote to configure
|
||||||
|
* @param repo the repository that will own the remote
|
||||||
|
* @return 0 or an error code
|
||||||
|
*/
|
||||||
|
GIT_EXTERN(int) git_remote_set_repository(git_remote *remote, git_repository *repo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the information for a particular remote
|
* Get the information for a particular remote
|
||||||
*
|
*
|
||||||
|
13
src/remote.c
13
src/remote.c
@ -132,6 +132,19 @@ on_error:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int git_remote_set_repository(git_remote *remote, git_repository *repo)
|
||||||
|
{
|
||||||
|
assert(repo);
|
||||||
|
|
||||||
|
if (remote->repo) {
|
||||||
|
giterr_set(GITERR_INVALID, "Remotes can't change repositiories.");
|
||||||
|
return GIT_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
remote->repo = repo;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int git_remote_load(git_remote **out, git_repository *repo, const char *name)
|
int git_remote_load(git_remote **out, git_repository *repo, const char *name)
|
||||||
{
|
{
|
||||||
git_remote *remote;
|
git_remote *remote;
|
||||||
|
@ -330,9 +330,13 @@ void test_network_remotes__check_structure_version(void)
|
|||||||
void test_network_remotes__dangling(void)
|
void test_network_remotes__dangling(void)
|
||||||
{
|
{
|
||||||
cl_git_pass(git_remote_new(&_remote, NULL, "upstream", "git://github.com/libgit2/libgit2", NULL));
|
cl_git_pass(git_remote_new(&_remote, NULL, "upstream", "git://github.com/libgit2/libgit2", NULL));
|
||||||
cl_git_fail(git_remote_save(_remote));
|
|
||||||
cl_git_fail(git_remote_update_tips(_remote));
|
|
||||||
|
|
||||||
cl_git_pass(git_remote_rename(_remote, "newname", NULL, NULL));
|
cl_git_pass(git_remote_rename(_remote, "newname", NULL, NULL));
|
||||||
cl_assert_equal_s(git_remote_name(_remote), "newname");
|
cl_assert_equal_s(git_remote_name(_remote), "newname");
|
||||||
|
|
||||||
|
cl_git_fail(git_remote_save(_remote));
|
||||||
|
cl_git_fail(git_remote_update_tips(_remote));
|
||||||
|
|
||||||
|
cl_git_pass(git_remote_set_repository(_remote, _repo));
|
||||||
|
cl_git_pass(git_remote_save(_remote));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user