mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-04 17:13:25 +00:00
API updates for remote.h
Includes typedef for git_direction, and renames for GIT_DIR_[FETCH|PUSH] to GIT_DIRECTION_(\1).
This commit is contained in:
parent
74f9132212
commit
df705148ec
@ -25,7 +25,7 @@ static void *download(void *ptr)
|
|||||||
|
|
||||||
// Connect to the remote end specifying that we want to fetch
|
// Connect to the remote end specifying that we want to fetch
|
||||||
// information from it.
|
// information from it.
|
||||||
if (git_remote_connect(data->remote, GIT_DIR_FETCH) < 0) {
|
if (git_remote_connect(data->remote, GIT_DIRECTION_FETCH) < 0) {
|
||||||
data->ret = -1;
|
data->ret = -1;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ static int use_unnamed(git_repository *repo, const char *url)
|
|||||||
|
|
||||||
// When connecting, the underlying code needs to know wether we
|
// When connecting, the underlying code needs to know wether we
|
||||||
// want to push or fetch
|
// want to push or fetch
|
||||||
error = git_remote_connect(remote, GIT_DIR_FETCH);
|
error = git_remote_connect(remote, GIT_DIRECTION_FETCH);
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ static int use_remote(git_repository *repo, char *name)
|
|||||||
if (error < 0)
|
if (error < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
error = git_remote_connect(remote, GIT_DIR_FETCH);
|
error = git_remote_connect(remote, GIT_DIRECTION_FETCH);
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -27,8 +27,10 @@ GIT_BEGIN_DECL
|
|||||||
* gets called.
|
* gets called.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define GIT_DIR_FETCH 0
|
typedef enum {
|
||||||
#define GIT_DIR_PUSH 1
|
GIT_DIRECTION_FETCH = 0,
|
||||||
|
GIT_DIRECTION_PUSH = 1
|
||||||
|
} git_direction;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
GIT_BEGIN_DECL
|
GIT_BEGIN_DECL
|
||||||
|
|
||||||
|
typedef int (*git_remote_rename_problem_cb)(const char *problematic_refspec, void *payload);
|
||||||
/*
|
/*
|
||||||
* TODO: This functions still need to be implemented:
|
* TODO: This functions still need to be implemented:
|
||||||
* - _listcb/_foreach
|
* - _listcb/_foreach
|
||||||
@ -71,7 +72,7 @@ GIT_EXTERN(int) git_remote_save(const git_remote *remote);
|
|||||||
* @param remote the remote
|
* @param remote the remote
|
||||||
* @return a pointer to the name
|
* @return a pointer to the name
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(const char *) git_remote_name(git_remote *remote);
|
GIT_EXTERN(const char *) git_remote_name(const git_remote *remote);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the remote's url
|
* Get the remote's url
|
||||||
@ -79,7 +80,7 @@ GIT_EXTERN(const char *) git_remote_name(git_remote *remote);
|
|||||||
* @param remote the remote
|
* @param remote the remote
|
||||||
* @return a pointer to the url
|
* @return a pointer to the url
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(const char *) git_remote_url(git_remote *remote);
|
GIT_EXTERN(const char *) git_remote_url(const git_remote *remote);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the remote's url for pushing
|
* Get the remote's url for pushing
|
||||||
@ -87,7 +88,7 @@ GIT_EXTERN(const char *) git_remote_url(git_remote *remote);
|
|||||||
* @param remote the remote
|
* @param remote the remote
|
||||||
* @return a pointer to the url or NULL if no special url for pushing is set
|
* @return a pointer to the url or NULL if no special url for pushing is set
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(const char *) git_remote_pushurl(git_remote *remote);
|
GIT_EXTERN(const char *) git_remote_pushurl(const git_remote *remote);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the remote's url
|
* Set the remote's url
|
||||||
@ -126,7 +127,7 @@ GIT_EXTERN(int) git_remote_set_fetchspec(git_remote *remote, const char *spec);
|
|||||||
* @param remote the remote
|
* @param remote the remote
|
||||||
* @return a pointer to the fetch refspec or NULL if it doesn't exist
|
* @return a pointer to the fetch refspec or NULL if it doesn't exist
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(const git_refspec *) git_remote_fetchspec(git_remote *remote);
|
GIT_EXTERN(const git_refspec *) git_remote_fetchspec(const git_remote *remote);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the remote's push refspec
|
* Set the remote's push refspec
|
||||||
@ -144,7 +145,7 @@ GIT_EXTERN(int) git_remote_set_pushspec(git_remote *remote, const char *spec);
|
|||||||
* @return a pointer to the push refspec or NULL if it doesn't exist
|
* @return a pointer to the push refspec or NULL if it doesn't exist
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GIT_EXTERN(const git_refspec *) git_remote_pushspec(git_remote *remote);
|
GIT_EXTERN(const git_refspec *) git_remote_pushspec(const git_remote *remote);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a connection to a remote
|
* Open a connection to a remote
|
||||||
@ -157,7 +158,7 @@ GIT_EXTERN(const git_refspec *) git_remote_pushspec(git_remote *remote);
|
|||||||
* @param direction whether you want to receive or send data
|
* @param direction whether you want to receive or send data
|
||||||
* @return 0 or an error code
|
* @return 0 or an error code
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_remote_connect(git_remote *remote, int direction);
|
GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of refs at the remote
|
* Get a list of refs at the remote
|
||||||
@ -194,7 +195,7 @@ GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void
|
|||||||
GIT_EXTERN(int) git_remote_download(
|
GIT_EXTERN(int) git_remote_download(
|
||||||
git_remote *remote,
|
git_remote *remote,
|
||||||
git_transfer_progress_callback progress_cb,
|
git_transfer_progress_callback progress_cb,
|
||||||
void *progress_payload);
|
void *payload);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the remote is connected
|
* Check whether the remote is connected
|
||||||
@ -266,11 +267,11 @@ GIT_EXTERN(int) git_remote_supported_url(const char* url);
|
|||||||
*
|
*
|
||||||
* The string array must be freed by the user.
|
* The string array must be freed by the user.
|
||||||
*
|
*
|
||||||
* @param remotes_list a string array with the names of the remotes
|
* @param out a string array which receives the names of the remotes
|
||||||
* @param repo the repository to query
|
* @param repo the repository to query
|
||||||
* @return 0 or an error code
|
* @return 0 or an error code
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_remote_list(git_strarray *remotes_list, git_repository *repo);
|
GIT_EXTERN(int) git_remote_list(git_strarray *out, git_repository *repo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a remote with the default fetch refspec to the repository's configuration
|
* Add a remote with the default fetch refspec to the repository's configuration
|
||||||
@ -340,7 +341,7 @@ struct git_remote_callbacks {
|
|||||||
void (*progress)(const char *str, int len, void *data);
|
void (*progress)(const char *str, int len, void *data);
|
||||||
int (*completion)(git_remote_completion_type type, void *data);
|
int (*completion)(git_remote_completion_type type, void *data);
|
||||||
int (*update_tips)(const char *refname, const git_oid *a, const git_oid *b, void *data);
|
int (*update_tips)(const char *refname, const git_oid *a, const git_oid *b, void *data);
|
||||||
void *data;
|
void *payload;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -398,7 +399,7 @@ GIT_EXTERN(void) git_remote_set_autotag(git_remote *remote, int value);
|
|||||||
GIT_EXTERN(int) git_remote_rename(
|
GIT_EXTERN(int) git_remote_rename(
|
||||||
git_remote *remote,
|
git_remote *remote,
|
||||||
const char *new_name,
|
const char *new_name,
|
||||||
int (*callback)(const char *problematic_refspec, void *payload),
|
git_remote_rename_problem_cb callback,
|
||||||
void *payload);
|
void *payload);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -278,7 +278,7 @@ static int setup_remotes_and_fetch(
|
|||||||
git_remote_set_update_fetchhead(origin, 0);
|
git_remote_set_update_fetchhead(origin, 0);
|
||||||
|
|
||||||
/* Connect and download everything */
|
/* Connect and download everything */
|
||||||
if (!git_remote_connect(origin, GIT_DIR_FETCH)) {
|
if (!git_remote_connect(origin, GIT_DIRECTION_FETCH)) {
|
||||||
if (!git_remote_download(origin, progress_cb, progress_payload)) {
|
if (!git_remote_download(origin, progress_cb, progress_payload)) {
|
||||||
/* Create "origin/foo" branches for all remote branches */
|
/* Create "origin/foo" branches for all remote branches */
|
||||||
if (!git_remote_update_tips(origin)) {
|
if (!git_remote_update_tips(origin)) {
|
||||||
|
32
src/remote.c
32
src/remote.c
@ -252,7 +252,7 @@ static int update_config_refspec(
|
|||||||
&name,
|
&name,
|
||||||
"remote.%s.%s",
|
"remote.%s.%s",
|
||||||
remote_name,
|
remote_name,
|
||||||
git_direction == GIT_DIR_FETCH ? "fetch" : "push") < 0)
|
git_direction == GIT_DIRECTION_FETCH ? "fetch" : "push") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (git_refspec__serialize(&value, refspec) < 0)
|
if (git_refspec__serialize(&value, refspec) < 0)
|
||||||
@ -318,14 +318,14 @@ int git_remote_save(const git_remote *remote)
|
|||||||
config,
|
config,
|
||||||
remote->name,
|
remote->name,
|
||||||
&remote->fetch,
|
&remote->fetch,
|
||||||
GIT_DIR_FETCH) < 0)
|
GIT_DIRECTION_FETCH) < 0)
|
||||||
goto on_error;
|
goto on_error;
|
||||||
|
|
||||||
if (update_config_refspec(
|
if (update_config_refspec(
|
||||||
config,
|
config,
|
||||||
remote->name,
|
remote->name,
|
||||||
&remote->push,
|
&remote->push,
|
||||||
GIT_DIR_PUSH) < 0)
|
GIT_DIRECTION_PUSH) < 0)
|
||||||
goto on_error;
|
goto on_error;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -369,13 +369,13 @@ on_error:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *git_remote_name(git_remote *remote)
|
const char *git_remote_name(const git_remote *remote)
|
||||||
{
|
{
|
||||||
assert(remote);
|
assert(remote);
|
||||||
return remote->name;
|
return remote->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *git_remote_url(git_remote *remote)
|
const char *git_remote_url(const git_remote *remote)
|
||||||
{
|
{
|
||||||
assert(remote);
|
assert(remote);
|
||||||
return remote->url;
|
return remote->url;
|
||||||
@ -393,7 +393,7 @@ int git_remote_set_url(git_remote *remote, const char* url)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *git_remote_pushurl(git_remote *remote)
|
const char *git_remote_pushurl(const git_remote *remote)
|
||||||
{
|
{
|
||||||
assert(remote);
|
assert(remote);
|
||||||
return remote->pushurl;
|
return remote->pushurl;
|
||||||
@ -429,7 +429,7 @@ int git_remote_set_fetchspec(git_remote *remote, const char *spec)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const git_refspec *git_remote_fetchspec(git_remote *remote)
|
const git_refspec *git_remote_fetchspec(const git_remote *remote)
|
||||||
{
|
{
|
||||||
assert(remote);
|
assert(remote);
|
||||||
return &remote->fetch;
|
return &remote->fetch;
|
||||||
@ -451,7 +451,7 @@ int git_remote_set_pushspec(git_remote *remote, const char *spec)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const git_refspec *git_remote_pushspec(git_remote *remote)
|
const git_refspec *git_remote_pushspec(const git_remote *remote)
|
||||||
{
|
{
|
||||||
assert(remote);
|
assert(remote);
|
||||||
return &remote->push;
|
return &remote->push;
|
||||||
@ -461,18 +461,18 @@ const char* git_remote__urlfordirection(git_remote *remote, int direction)
|
|||||||
{
|
{
|
||||||
assert(remote);
|
assert(remote);
|
||||||
|
|
||||||
if (direction == GIT_DIR_FETCH) {
|
if (direction == GIT_DIRECTION_FETCH) {
|
||||||
return remote->url;
|
return remote->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (direction == GIT_DIR_PUSH) {
|
if (direction == GIT_DIRECTION_PUSH) {
|
||||||
return remote->pushurl ? remote->pushurl : remote->url;
|
return remote->pushurl ? remote->pushurl : remote->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_remote_connect(git_remote *remote, int direction)
|
int git_remote_connect(git_remote *remote, git_direction direction)
|
||||||
{
|
{
|
||||||
git_transport *t;
|
git_transport *t;
|
||||||
const char *url;
|
const char *url;
|
||||||
@ -492,7 +492,7 @@ int git_remote_connect(git_remote *remote, int direction)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (t->set_callbacks &&
|
if (t->set_callbacks &&
|
||||||
t->set_callbacks(t, remote->callbacks.progress, NULL, remote->callbacks.data) < 0)
|
t->set_callbacks(t, remote->callbacks.progress, NULL, remote->callbacks.payload) < 0)
|
||||||
goto on_error;
|
goto on_error;
|
||||||
|
|
||||||
if (!remote->check_cert)
|
if (!remote->check_cert)
|
||||||
@ -753,7 +753,7 @@ int git_remote_update_tips(git_remote *remote)
|
|||||||
git_reference_free(ref);
|
git_reference_free(ref);
|
||||||
|
|
||||||
if (remote->callbacks.update_tips != NULL) {
|
if (remote->callbacks.update_tips != NULL) {
|
||||||
if (remote->callbacks.update_tips(refname.ptr, &old, &head->oid, remote->callbacks.data) < 0)
|
if (remote->callbacks.update_tips(refname.ptr, &old, &head->oid, remote->callbacks.payload) < 0)
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -936,7 +936,7 @@ void git_remote_set_callbacks(git_remote *remote, git_remote_callbacks *callback
|
|||||||
remote->transport->set_callbacks(remote->transport,
|
remote->transport->set_callbacks(remote->transport,
|
||||||
remote->callbacks.progress,
|
remote->callbacks.progress,
|
||||||
NULL,
|
NULL,
|
||||||
remote->callbacks.data);
|
remote->callbacks.payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
void git_remote_set_cred_acquire_cb(
|
void git_remote_set_cred_acquire_cb(
|
||||||
@ -1194,7 +1194,7 @@ static int rename_fetch_refspecs(
|
|||||||
if (git_repository_config__weakptr(&config, remote->repo) < 0)
|
if (git_repository_config__weakptr(&config, remote->repo) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
error = update_config_refspec(config, new_name, &remote->fetch, GIT_DIR_FETCH);
|
error = update_config_refspec(config, new_name, &remote->fetch, GIT_DIRECTION_FETCH);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
git_buf_free(&serialized);
|
git_buf_free(&serialized);
|
||||||
@ -1205,7 +1205,7 @@ cleanup:
|
|||||||
int git_remote_rename(
|
int git_remote_rename(
|
||||||
git_remote *remote,
|
git_remote *remote,
|
||||||
const char *new_name,
|
const char *new_name,
|
||||||
int (*callback)(const char *problematic_refspec, void *payload),
|
git_remote_rename_problem_cb callback,
|
||||||
void *payload)
|
void *payload)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
@ -73,7 +73,7 @@ static int git_smart__connect(
|
|||||||
t->flags = flags;
|
t->flags = flags;
|
||||||
t->cred_acquire_cb = cred_acquire_cb;
|
t->cred_acquire_cb = cred_acquire_cb;
|
||||||
|
|
||||||
if (GIT_DIR_FETCH == direction)
|
if (GIT_DIRECTION_FETCH == direction)
|
||||||
{
|
{
|
||||||
if ((error = t->wrapped->action(&stream, t->wrapped, t->url, GIT_SERVICE_UPLOADPACK_LS)) < 0)
|
if ((error = t->wrapped->action(&stream, t->wrapped, t->url, GIT_SERVICE_UPLOADPACK_LS)) < 0)
|
||||||
return error;
|
return error;
|
||||||
@ -159,7 +159,7 @@ int git_smart__negotiation_step(git_transport *transport, void *data, size_t len
|
|||||||
if (t->rpc)
|
if (t->rpc)
|
||||||
git_smart__reset_stream(t);
|
git_smart__reset_stream(t);
|
||||||
|
|
||||||
if (GIT_DIR_FETCH == t->direction) {
|
if (GIT_DIRECTION_FETCH == t->direction) {
|
||||||
if ((error = t->wrapped->action(&stream, t->wrapped, t->url, GIT_SERVICE_UPLOADPACK)) < 0)
|
if ((error = t->wrapped->action(&stream, t->wrapped, t->url, GIT_SERVICE_UPLOADPACK)) < 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ static void fetchhead_test_fetch(const char *fetchspec, const char *expected_fet
|
|||||||
if(fetchspec != NULL)
|
if(fetchspec != NULL)
|
||||||
git_remote_set_fetchspec(remote, fetchspec);
|
git_remote_set_fetchspec(remote, fetchspec);
|
||||||
|
|
||||||
cl_git_pass(git_remote_connect(remote, GIT_DIR_FETCH));
|
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH));
|
||||||
cl_git_pass(git_remote_download(remote, NULL, NULL));
|
cl_git_pass(git_remote_download(remote, NULL, NULL));
|
||||||
cl_git_pass(git_remote_update_tips(remote));
|
cl_git_pass(git_remote_update_tips(remote));
|
||||||
git_remote_disconnect(remote);
|
git_remote_disconnect(remote);
|
||||||
|
@ -46,7 +46,7 @@ static void do_fetch(const char *url, int flag, int n)
|
|||||||
cl_git_pass(git_remote_add(&remote, _repo, "test", url));
|
cl_git_pass(git_remote_add(&remote, _repo, "test", url));
|
||||||
git_remote_set_callbacks(remote, &callbacks);
|
git_remote_set_callbacks(remote, &callbacks);
|
||||||
git_remote_set_autotag(remote, flag);
|
git_remote_set_autotag(remote, flag);
|
||||||
cl_git_pass(git_remote_connect(remote, GIT_DIR_FETCH));
|
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH));
|
||||||
cl_git_pass(git_remote_download(remote, progress, &bytes_received));
|
cl_git_pass(git_remote_download(remote, progress, &bytes_received));
|
||||||
git_remote_disconnect(remote);
|
git_remote_disconnect(remote);
|
||||||
cl_git_pass(git_remote_update_tips(remote));
|
cl_git_pass(git_remote_update_tips(remote));
|
||||||
|
@ -22,7 +22,7 @@ void test_network_fetchlocal__complete(void)
|
|||||||
cl_git_pass(git_repository_init(&repo, "foo", true));
|
cl_git_pass(git_repository_init(&repo, "foo", true));
|
||||||
|
|
||||||
cl_git_pass(git_remote_add(&origin, repo, GIT_REMOTE_ORIGIN, url));
|
cl_git_pass(git_remote_add(&origin, repo, GIT_REMOTE_ORIGIN, url));
|
||||||
cl_git_pass(git_remote_connect(origin, GIT_DIR_FETCH));
|
cl_git_pass(git_remote_connect(origin, GIT_DIRECTION_FETCH));
|
||||||
cl_git_pass(git_remote_download(origin, transfer_cb, &callcount));
|
cl_git_pass(git_remote_download(origin, transfer_cb, &callcount));
|
||||||
cl_git_pass(git_remote_update_tips(origin));
|
cl_git_pass(git_remote_update_tips(origin));
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ void test_network_fetchlocal__partial(void)
|
|||||||
|
|
||||||
url = cl_git_fixture_url("testrepo.git");
|
url = cl_git_fixture_url("testrepo.git");
|
||||||
cl_git_pass(git_remote_add(&origin, repo, GIT_REMOTE_ORIGIN, url));
|
cl_git_pass(git_remote_add(&origin, repo, GIT_REMOTE_ORIGIN, url));
|
||||||
cl_git_pass(git_remote_connect(origin, GIT_DIR_FETCH));
|
cl_git_pass(git_remote_connect(origin, GIT_DIRECTION_FETCH));
|
||||||
cl_git_pass(git_remote_download(origin, transfer_cb, &callcount));
|
cl_git_pass(git_remote_download(origin, transfer_cb, &callcount));
|
||||||
cl_git_pass(git_remote_update_tips(origin));
|
cl_git_pass(git_remote_update_tips(origin));
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ static void assert_refspec(unsigned int direction, const char *input, bool is_ex
|
|||||||
git_refspec refspec;
|
git_refspec refspec;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = git_refspec__parse(&refspec, input, direction == GIT_DIR_FETCH);
|
error = git_refspec__parse(&refspec, input, direction == GIT_DIRECTION_FETCH);
|
||||||
git_refspec__free(&refspec);
|
git_refspec__free(&refspec);
|
||||||
|
|
||||||
if (is_expected_to_be_valid)
|
if (is_expected_to_be_valid)
|
||||||
@ -20,19 +20,19 @@ void test_network_refspecs__parsing(void)
|
|||||||
{
|
{
|
||||||
// Ported from https://github.com/git/git/blob/abd2bde78bd994166900290434a2048e660dabed/t/t5511-refspec.sh
|
// Ported from https://github.com/git/git/blob/abd2bde78bd994166900290434a2048e660dabed/t/t5511-refspec.sh
|
||||||
|
|
||||||
assert_refspec(GIT_DIR_PUSH, "", false);
|
assert_refspec(GIT_DIRECTION_PUSH, "", false);
|
||||||
assert_refspec(GIT_DIR_PUSH, ":", true);
|
assert_refspec(GIT_DIRECTION_PUSH, ":", true);
|
||||||
assert_refspec(GIT_DIR_PUSH, "::", false);
|
assert_refspec(GIT_DIRECTION_PUSH, "::", false);
|
||||||
assert_refspec(GIT_DIR_PUSH, "+:", true);
|
assert_refspec(GIT_DIRECTION_PUSH, "+:", true);
|
||||||
|
|
||||||
assert_refspec(GIT_DIR_FETCH, "", true);
|
assert_refspec(GIT_DIRECTION_FETCH, "", true);
|
||||||
assert_refspec(GIT_DIR_PUSH, ":", true);
|
assert_refspec(GIT_DIRECTION_PUSH, ":", true);
|
||||||
assert_refspec(GIT_DIR_FETCH, "::", false);
|
assert_refspec(GIT_DIRECTION_FETCH, "::", false);
|
||||||
|
|
||||||
assert_refspec(GIT_DIR_PUSH, "refs/heads/*:refs/remotes/frotz/*", true);
|
assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/*:refs/remotes/frotz/*", true);
|
||||||
assert_refspec(GIT_DIR_PUSH, "refs/heads/*:refs/remotes/frotz", false);
|
assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/*:refs/remotes/frotz", false);
|
||||||
assert_refspec(GIT_DIR_PUSH, "refs/heads:refs/remotes/frotz/*", false);
|
assert_refspec(GIT_DIRECTION_PUSH, "refs/heads:refs/remotes/frotz/*", false);
|
||||||
assert_refspec(GIT_DIR_PUSH, "refs/heads/master:refs/remotes/frotz/xyzzy", true);
|
assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/master:refs/remotes/frotz/xyzzy", true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These have invalid LHS, but we do not have a formal "valid sha-1
|
* These have invalid LHS, but we do not have a formal "valid sha-1
|
||||||
@ -40,45 +40,45 @@ void test_network_refspecs__parsing(void)
|
|||||||
* code. They will be caught downstream anyway, but we may want to
|
* code. They will be caught downstream anyway, but we may want to
|
||||||
* have tighter check later...
|
* have tighter check later...
|
||||||
*/
|
*/
|
||||||
//assert_refspec(GIT_DIR_PUSH, "refs/heads/master::refs/remotes/frotz/xyzzy", false);
|
//assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/master::refs/remotes/frotz/xyzzy", false);
|
||||||
//assert_refspec(GIT_DIR_PUSH, "refs/heads/maste :refs/remotes/frotz/xyzzy", false);
|
//assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/maste :refs/remotes/frotz/xyzzy", false);
|
||||||
|
|
||||||
assert_refspec(GIT_DIR_FETCH, "refs/heads/*:refs/remotes/frotz/*", true);
|
assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/*:refs/remotes/frotz/*", true);
|
||||||
assert_refspec(GIT_DIR_FETCH, "refs/heads/*:refs/remotes/frotz", false);
|
assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/*:refs/remotes/frotz", false);
|
||||||
assert_refspec(GIT_DIR_FETCH, "refs/heads:refs/remotes/frotz/*", false);
|
assert_refspec(GIT_DIRECTION_FETCH, "refs/heads:refs/remotes/frotz/*", false);
|
||||||
assert_refspec(GIT_DIR_FETCH, "refs/heads/master:refs/remotes/frotz/xyzzy", true);
|
assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/master:refs/remotes/frotz/xyzzy", true);
|
||||||
assert_refspec(GIT_DIR_FETCH, "refs/heads/master::refs/remotes/frotz/xyzzy", false);
|
assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/master::refs/remotes/frotz/xyzzy", false);
|
||||||
assert_refspec(GIT_DIR_FETCH, "refs/heads/maste :refs/remotes/frotz/xyzzy", false);
|
assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/maste :refs/remotes/frotz/xyzzy", false);
|
||||||
|
|
||||||
assert_refspec(GIT_DIR_PUSH, "master~1:refs/remotes/frotz/backup", true);
|
assert_refspec(GIT_DIRECTION_PUSH, "master~1:refs/remotes/frotz/backup", true);
|
||||||
assert_refspec(GIT_DIR_FETCH, "master~1:refs/remotes/frotz/backup", false);
|
assert_refspec(GIT_DIRECTION_FETCH, "master~1:refs/remotes/frotz/backup", false);
|
||||||
assert_refspec(GIT_DIR_PUSH, "HEAD~4:refs/remotes/frotz/new", true);
|
assert_refspec(GIT_DIRECTION_PUSH, "HEAD~4:refs/remotes/frotz/new", true);
|
||||||
assert_refspec(GIT_DIR_FETCH, "HEAD~4:refs/remotes/frotz/new", false);
|
assert_refspec(GIT_DIRECTION_FETCH, "HEAD~4:refs/remotes/frotz/new", false);
|
||||||
|
|
||||||
assert_refspec(GIT_DIR_PUSH, "HEAD", true);
|
assert_refspec(GIT_DIRECTION_PUSH, "HEAD", true);
|
||||||
assert_refspec(GIT_DIR_FETCH, "HEAD", true);
|
assert_refspec(GIT_DIRECTION_FETCH, "HEAD", true);
|
||||||
assert_refspec(GIT_DIR_PUSH, "refs/heads/ nitfol", false);
|
assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/ nitfol", false);
|
||||||
assert_refspec(GIT_DIR_FETCH, "refs/heads/ nitfol", false);
|
assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/ nitfol", false);
|
||||||
|
|
||||||
assert_refspec(GIT_DIR_PUSH, "HEAD:", false);
|
assert_refspec(GIT_DIRECTION_PUSH, "HEAD:", false);
|
||||||
assert_refspec(GIT_DIR_FETCH, "HEAD:", true);
|
assert_refspec(GIT_DIRECTION_FETCH, "HEAD:", true);
|
||||||
assert_refspec(GIT_DIR_PUSH, "refs/heads/ nitfol:", false);
|
assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/ nitfol:", false);
|
||||||
assert_refspec(GIT_DIR_FETCH, "refs/heads/ nitfol:", false);
|
assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/ nitfol:", false);
|
||||||
|
|
||||||
assert_refspec(GIT_DIR_PUSH, ":refs/remotes/frotz/deleteme", true);
|
assert_refspec(GIT_DIRECTION_PUSH, ":refs/remotes/frotz/deleteme", true);
|
||||||
assert_refspec(GIT_DIR_FETCH, ":refs/remotes/frotz/HEAD-to-me", true);
|
assert_refspec(GIT_DIRECTION_FETCH, ":refs/remotes/frotz/HEAD-to-me", true);
|
||||||
assert_refspec(GIT_DIR_PUSH, ":refs/remotes/frotz/delete me", false);
|
assert_refspec(GIT_DIRECTION_PUSH, ":refs/remotes/frotz/delete me", false);
|
||||||
assert_refspec(GIT_DIR_FETCH, ":refs/remotes/frotz/HEAD to me", false);
|
assert_refspec(GIT_DIRECTION_FETCH, ":refs/remotes/frotz/HEAD to me", false);
|
||||||
|
|
||||||
assert_refspec(GIT_DIR_FETCH, "refs/heads/*/for-linus:refs/remotes/mine/*-blah", false);
|
assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/*/for-linus:refs/remotes/mine/*-blah", false);
|
||||||
assert_refspec(GIT_DIR_PUSH, "refs/heads/*/for-linus:refs/remotes/mine/*-blah", false);
|
assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/*/for-linus:refs/remotes/mine/*-blah", false);
|
||||||
|
|
||||||
assert_refspec(GIT_DIR_FETCH, "refs/heads*/for-linus:refs/remotes/mine/*", false);
|
assert_refspec(GIT_DIRECTION_FETCH, "refs/heads*/for-linus:refs/remotes/mine/*", false);
|
||||||
assert_refspec(GIT_DIR_PUSH, "refs/heads*/for-linus:refs/remotes/mine/*", false);
|
assert_refspec(GIT_DIRECTION_PUSH, "refs/heads*/for-linus:refs/remotes/mine/*", false);
|
||||||
|
|
||||||
assert_refspec(GIT_DIR_FETCH, "refs/heads/*/*/for-linus:refs/remotes/mine/*", false);
|
assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/*/*/for-linus:refs/remotes/mine/*", false);
|
||||||
assert_refspec(GIT_DIR_PUSH, "refs/heads/*/*/for-linus:refs/remotes/mine/*", false);
|
assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/*/*/for-linus:refs/remotes/mine/*", false);
|
||||||
|
|
||||||
assert_refspec(GIT_DIR_FETCH, "refs/heads/*/for-linus:refs/remotes/mine/*", true);
|
assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/*/for-linus:refs/remotes/mine/*", true);
|
||||||
assert_refspec(GIT_DIR_PUSH, "refs/heads/*/for-linus:refs/remotes/mine/*", true);
|
assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/*/for-linus:refs/remotes/mine/*", true);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ static void connect_to_local_repository(const char *local_repository)
|
|||||||
git_buf_sets(&file_path_buf, cl_git_path_url(local_repository));
|
git_buf_sets(&file_path_buf, cl_git_path_url(local_repository));
|
||||||
|
|
||||||
cl_git_pass(git_remote_new(&remote, repo, NULL, git_buf_cstr(&file_path_buf), NULL));
|
cl_git_pass(git_remote_new(&remote, repo, NULL, git_buf_cstr(&file_path_buf), NULL));
|
||||||
cl_git_pass(git_remote_connect(remote, GIT_DIR_FETCH));
|
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,9 +33,9 @@ void test_network_remotes__parsing(void)
|
|||||||
cl_assert_equal_s(git_remote_url(_remote), "git://github.com/libgit2/libgit2");
|
cl_assert_equal_s(git_remote_url(_remote), "git://github.com/libgit2/libgit2");
|
||||||
cl_assert(git_remote_pushurl(_remote) == NULL);
|
cl_assert(git_remote_pushurl(_remote) == NULL);
|
||||||
|
|
||||||
cl_assert_equal_s(git_remote__urlfordirection(_remote, GIT_DIR_FETCH),
|
cl_assert_equal_s(git_remote__urlfordirection(_remote, GIT_DIRECTION_FETCH),
|
||||||
"git://github.com/libgit2/libgit2");
|
"git://github.com/libgit2/libgit2");
|
||||||
cl_assert_equal_s(git_remote__urlfordirection(_remote, GIT_DIR_PUSH),
|
cl_assert_equal_s(git_remote__urlfordirection(_remote, GIT_DIRECTION_PUSH),
|
||||||
"git://github.com/libgit2/libgit2");
|
"git://github.com/libgit2/libgit2");
|
||||||
|
|
||||||
cl_git_pass(git_remote_load(&_remote2, _repo, "test_with_pushurl"));
|
cl_git_pass(git_remote_load(&_remote2, _repo, "test_with_pushurl"));
|
||||||
@ -43,9 +43,9 @@ void test_network_remotes__parsing(void)
|
|||||||
cl_assert_equal_s(git_remote_url(_remote2), "git://github.com/libgit2/fetchlibgit2");
|
cl_assert_equal_s(git_remote_url(_remote2), "git://github.com/libgit2/fetchlibgit2");
|
||||||
cl_assert_equal_s(git_remote_pushurl(_remote2), "git://github.com/libgit2/pushlibgit2");
|
cl_assert_equal_s(git_remote_pushurl(_remote2), "git://github.com/libgit2/pushlibgit2");
|
||||||
|
|
||||||
cl_assert_equal_s(git_remote__urlfordirection(_remote2, GIT_DIR_FETCH),
|
cl_assert_equal_s(git_remote__urlfordirection(_remote2, GIT_DIRECTION_FETCH),
|
||||||
"git://github.com/libgit2/fetchlibgit2");
|
"git://github.com/libgit2/fetchlibgit2");
|
||||||
cl_assert_equal_s(git_remote__urlfordirection(_remote2, GIT_DIR_PUSH),
|
cl_assert_equal_s(git_remote__urlfordirection(_remote2, GIT_DIRECTION_PUSH),
|
||||||
"git://github.com/libgit2/pushlibgit2");
|
"git://github.com/libgit2/pushlibgit2");
|
||||||
|
|
||||||
git_remote_free(_remote2);
|
git_remote_free(_remote2);
|
||||||
|
Loading…
Reference in New Issue
Block a user