mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-05 15:33:51 +00:00
remote: Make git_remote_add() generate a default refspec with a force update specifier
This commit is contained in:
parent
d05e2c64dd
commit
d27bf66561
@ -494,7 +494,7 @@ int git_remote_add(git_remote **out, git_repository *repo, const char *name, con
|
|||||||
{
|
{
|
||||||
git_buf buf = GIT_BUF_INIT;
|
git_buf buf = GIT_BUF_INIT;
|
||||||
|
|
||||||
if (git_buf_printf(&buf, "refs/heads/*:refs/remotes/%s/*", name) < 0)
|
if (git_buf_printf(&buf, "+refs/heads/*:refs/remotes/%s/*", name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (git_remote_new(out, repo, name, url, git_buf_cstr(&buf)) < 0)
|
if (git_remote_new(out, repo, name, url, git_buf_cstr(&buf)) < 0)
|
||||||
|
@ -160,6 +160,15 @@ void test_network_remotes__loading_a_missing_remote_returns_ENOTFOUND(void)
|
|||||||
cl_assert_equal_i(GIT_ENOTFOUND, git_remote_load(&_remote, _repo, "just-left-few-minutes-ago"));
|
cl_assert_equal_i(GIT_ENOTFOUND, git_remote_load(&_remote, _repo, "just-left-few-minutes-ago"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* $ git remote add addtest http://github.com/libgit2/libgit2
|
||||||
|
*
|
||||||
|
* $ cat .git/config
|
||||||
|
* [...]
|
||||||
|
* [remote "addtest"]
|
||||||
|
* url = http://github.com/libgit2/libgit2
|
||||||
|
* fetch = +refs/heads/*:refs/remotes/addtest/*
|
||||||
|
*/
|
||||||
void test_network_remotes__add(void)
|
void test_network_remotes__add(void)
|
||||||
{
|
{
|
||||||
git_remote_free(_remote);
|
git_remote_free(_remote);
|
||||||
@ -169,5 +178,6 @@ void test_network_remotes__add(void)
|
|||||||
cl_git_pass(git_remote_load(&_remote, _repo, "addtest"));
|
cl_git_pass(git_remote_load(&_remote, _repo, "addtest"));
|
||||||
_refspec = git_remote_fetchspec(_remote);
|
_refspec = git_remote_fetchspec(_remote);
|
||||||
cl_assert(!strcmp(git_refspec_src(_refspec), "refs/heads/*"));
|
cl_assert(!strcmp(git_refspec_src(_refspec), "refs/heads/*"));
|
||||||
|
cl_assert(git_refspec_force(_refspec) == 1);
|
||||||
cl_assert(!strcmp(git_refspec_dst(_refspec), "refs/remotes/addtest/*"));
|
cl_assert(!strcmp(git_refspec_dst(_refspec), "refs/remotes/addtest/*"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user