Commit 9c206a22 by Carlos Martín Nieto

remote: use active refspec override in the tests

This lets us test this bit as well as getting closer to what they were
trying to do.
parent 3f894205
......@@ -116,16 +116,20 @@ void test_network_remote_local__nested_tags_are_completely_peeled(void)
void test_network_remote_local__shorthand_fetch_refspec0(void)
{
const char *refspec = "master:remotes/sloppy/master";
const char *refspec2 = "master:boh/sloppy/master";
char *refspec_strings[] = {
"master:remotes/sloppy/master",
"master:boh/sloppy/master",
};
git_strarray array = {
refspec_strings,
2,
};
git_reference *ref;
connect_to_local_repository(cl_fixture("testrepo.git"));
cl_git_pass(git_remote_add_fetch(remote, refspec));
cl_git_pass(git_remote_add_fetch(remote, refspec2));
cl_git_pass(git_remote_download(remote, NULL));
cl_git_pass(git_remote_download(remote, &array));
cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
cl_git_pass(git_reference_lookup(&ref, repo, "refs/remotes/sloppy/master"));
......@@ -137,17 +141,21 @@ void test_network_remote_local__shorthand_fetch_refspec0(void)
void test_network_remote_local__shorthand_fetch_refspec1(void)
{
const char *refspec = "master";
const char *refspec2 = "hard_tag";
char *refspec_strings[] = {
"master",
"hard_tag",
};
git_strarray array = {
refspec_strings,
2,
};
git_reference *ref;
connect_to_local_repository(cl_fixture("testrepo.git"));
git_remote_clear_refspecs(remote);
cl_git_pass(git_remote_add_fetch(remote, refspec));
cl_git_pass(git_remote_add_fetch(remote, refspec2));
cl_git_pass(git_remote_download(remote, NULL));
cl_git_pass(git_remote_download(remote, &array));
cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
cl_git_fail(git_reference_lookup(&ref, repo, "refs/remotes/master"));
......@@ -174,14 +182,20 @@ void test_network_remote_local__tagopt(void)
void test_network_remote_local__push_to_bare_remote(void)
{
char *refspec_strings[] = {
"master:master",
};
git_strarray array = {
refspec_strings,
1,
};
/* Should be able to push to a bare remote */
git_remote *localremote;
git_push *push;
/* Get some commits */
connect_to_local_repository(cl_fixture("testrepo.git"));
cl_git_pass(git_remote_add_fetch(remote, "master:master"));
cl_git_pass(git_remote_download(remote, NULL));
cl_git_pass(git_remote_download(remote, &array));
cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
git_remote_disconnect(remote);
......@@ -210,6 +224,13 @@ void test_network_remote_local__push_to_bare_remote(void)
void test_network_remote_local__push_to_bare_remote_with_file_url(void)
{
char *refspec_strings[] = {
"master:master",
};
git_strarray array = {
refspec_strings,
1,
};
/* Should be able to push to a bare remote */
git_remote *localremote;
git_push *push;
......@@ -217,8 +238,7 @@ void test_network_remote_local__push_to_bare_remote_with_file_url(void)
/* Get some commits */
connect_to_local_repository(cl_fixture("testrepo.git"));
cl_git_pass(git_remote_add_fetch(remote, "master:master"));
cl_git_pass(git_remote_download(remote, NULL));
cl_git_pass(git_remote_download(remote, &array));
cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
git_remote_disconnect(remote);
......@@ -251,14 +271,20 @@ void test_network_remote_local__push_to_bare_remote_with_file_url(void)
void test_network_remote_local__push_to_non_bare_remote(void)
{
char *refspec_strings[] = {
"master:master",
};
git_strarray array = {
refspec_strings,
1,
};
/* Shouldn't be able to push to a non-bare remote */
git_remote *localremote;
git_push *push;
/* Get some commits */
connect_to_local_repository(cl_fixture("testrepo.git"));
cl_git_pass(git_remote_add_fetch(remote, "master:master"));
cl_git_pass(git_remote_download(remote, NULL));
cl_git_pass(git_remote_download(remote, &array));
cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
git_remote_disconnect(remote);
......@@ -287,7 +313,13 @@ void test_network_remote_local__push_to_non_bare_remote(void)
void test_network_remote_local__fetch(void)
{
const char *refspec = "master:remotes/sloppy/master";
char *refspec_strings[] = {
"master:remotes/sloppy/master",
};
git_strarray array = {
refspec_strings,
1,
};
git_reflog *log;
const git_reflog_entry *entry;
......@@ -297,9 +329,8 @@ void test_network_remote_local__fetch(void)
cl_git_pass(git_signature_now(&sig, "Foo Bar", "foo@example.com"));
connect_to_local_repository(cl_fixture("testrepo.git"));
cl_git_pass(git_remote_add_fetch(remote, refspec));
cl_git_pass(git_remote_fetch(remote, NULL, sig, "UPDAAAAAATE!!"));
cl_git_pass(git_remote_fetch(remote, &array, sig, "UPDAAAAAATE!!"));
cl_git_pass(git_reference_lookup(&ref, repo, "refs/remotes/sloppy/master"));
git_reference_free(ref);
......@@ -316,7 +347,13 @@ void test_network_remote_local__fetch(void)
void test_network_remote_local__reflog(void)
{
const char *refspec = "master:remotes/sloppy/master";
char *refspec_strings[] = {
"master:remotes/sloppy/master",
};
git_strarray array = {
refspec_strings,
1,
};
git_reflog *log;
const git_reflog_entry *entry;
......@@ -325,9 +362,8 @@ void test_network_remote_local__reflog(void)
cl_git_pass(git_signature_now(&sig, "Foo Bar", "foo@example.com"));
connect_to_local_repository(cl_fixture("testrepo.git"));
cl_git_pass(git_remote_add_fetch(remote, refspec));
cl_git_pass(git_remote_download(remote, NULL));
cl_git_pass(git_remote_download(remote, &array));
cl_git_pass(git_remote_update_tips(remote, sig, "UPDAAAAAATE!!"));
cl_git_pass(git_reflog_read(&log, repo, "refs/remotes/sloppy/master"));
......@@ -342,7 +378,13 @@ void test_network_remote_local__reflog(void)
void test_network_remote_local__fetch_default_reflog_message(void)
{
const char *refspec = "master:remotes/sloppy/master";
char *refspec_strings[] = {
"master:remotes/sloppy/master",
};
git_strarray array = {
refspec_strings,
1,
};
git_reflog *log;
const git_reflog_entry *entry;
......@@ -352,9 +394,8 @@ void test_network_remote_local__fetch_default_reflog_message(void)
cl_git_pass(git_signature_now(&sig, "Foo Bar", "foo@example.com"));
connect_to_local_repository(cl_fixture("testrepo.git"));
cl_git_pass(git_remote_add_fetch(remote, refspec));
cl_git_pass(git_remote_fetch(remote, NULL, sig, NULL));
cl_git_pass(git_remote_fetch(remote, &array, sig, NULL));
cl_git_pass(git_reflog_read(&log, repo, "refs/remotes/sloppy/master"));
cl_assert_equal_i(1, git_reflog_entrycount(log));
......
......@@ -40,17 +40,19 @@ static void fetchhead_test_fetch(const char *fetchspec, const char *expected_fet
git_remote *remote;
git_buf fetchhead_buf = GIT_BUF_INIT;
int equals = 0;
git_strarray array, *active_refs = NULL;
cl_git_pass(git_remote_load(&remote, g_repo, "origin"));
git_remote_set_autotag(remote, GIT_REMOTE_DOWNLOAD_TAGS_AUTO);
if(fetchspec != NULL) {
git_remote_clear_refspecs(remote);
git_remote_add_fetch(remote, fetchspec);
array.count = 1;
array.strings = (char **) &fetchspec;
active_refs = &array;
}
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH));
cl_git_pass(git_remote_download(remote, NULL));
cl_git_pass(git_remote_download(remote, active_refs));
cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
git_remote_disconnect(remote);
git_remote_free(remote);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment