Commit 76bed9b2 by Vicent Martí

Merge pull request #930 from nulltoken/fix/tracking-without-fetch-refspec

refspec: No remote tracking ref from a fetchspec-less remote
parents 9be2261e e16fc07f
......@@ -248,9 +248,11 @@ int git_branch_tracking(
goto cleanup;
refspec = git_remote_fetchspec(remote);
if (refspec == NULL) {
error = GIT_ENOTFOUND;
goto cleanup;
if (refspec == NULL
|| refspec->src == NULL
|| refspec->dst == NULL) {
error = GIT_ENOTFOUND;
goto cleanup;
}
if (git_refspec_transform_r(&buf, refspec, merge_name) < 0)
......
......@@ -107,7 +107,7 @@ void test_network_remotelocal__retrieve_advertised_references(void)
cl_git_pass(git_remote_ls(remote, &count_ref__cb, &how_many_refs));
cl_assert_equal_i(how_many_refs, 25);
cl_assert_equal_i(how_many_refs, 26);
}
void test_network_remotelocal__retrieve_advertised_references_from_spaced_repository(void)
......@@ -121,7 +121,7 @@ void test_network_remotelocal__retrieve_advertised_references_from_spaced_reposi
cl_git_pass(git_remote_ls(remote, &count_ref__cb, &how_many_refs));
cl_assert_equal_i(how_many_refs, 25);
cl_assert_equal_i(how_many_refs, 26);
git_remote_free(remote); /* Disconnect from the "spaced repo" before the cleanup */
remote = NULL;
......
......@@ -186,13 +186,13 @@ void test_network_remotes__list(void)
git_config *cfg;
cl_git_pass(git_remote_list(&list, _repo));
cl_assert(list.count == 2);
cl_assert(list.count == 3);
git_strarray_free(&list);
cl_git_pass(git_repository_config(&cfg, _repo));
cl_git_pass(git_config_set_string(cfg, "remote.specless.url", "http://example.com"));
cl_git_pass(git_remote_list(&list, _repo));
cl_assert(list.count == 3);
cl_assert(list.count == 4);
git_strarray_free(&list);
git_config_free(cfg);
......
......@@ -47,7 +47,7 @@ static void assert_retrieval(unsigned int flags, unsigned int expected_count)
void test_refs_branches_foreach__retrieve_all_branches(void)
{
assert_retrieval(GIT_BRANCH_LOCAL | GIT_BRANCH_REMOTE, 13);
assert_retrieval(GIT_BRANCH_LOCAL | GIT_BRANCH_REMOTE, 14);
}
void test_refs_branches_foreach__retrieve_remote_branches(void)
......@@ -57,7 +57,7 @@ void test_refs_branches_foreach__retrieve_remote_branches(void)
void test_refs_branches_foreach__retrieve_local_branches(void)
{
assert_retrieval(GIT_BRANCH_LOCAL, 11);
assert_retrieval(GIT_BRANCH_LOCAL, 12);
}
struct expectations {
......
......@@ -67,3 +67,14 @@ void test_refs_branches_tracking__trying_to_retrieve_a_remote_tracking_reference
git_reference_free(branch);
}
void test_refs_branches_tracking__trying_to_retrieve_a_remote_tracking_reference_from_a_branch_with_no_fetchspec_returns_GIT_ENOTFOUND(void)
{
git_reference *branch, *tracking;
cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/cannot-fetch"));
cl_assert_equal_i(GIT_ENOTFOUND, git_branch_tracking(&tracking, branch));
git_reference_free(branch);
}
......@@ -46,7 +46,7 @@ static void assert_retrieval(const char *glob, unsigned int flags, int expected_
void test_refs_foreachglob__retrieve_all_refs(void)
{
/* 8 heads (including one packed head) + 1 note + 2 remotes + 6 tags */
assert_retrieval("*", GIT_REF_LISTALL, 20);
assert_retrieval("*", GIT_REF_LISTALL, 21);
}
void test_refs_foreachglob__retrieve_remote_branches(void)
......@@ -56,7 +56,7 @@ void test_refs_foreachglob__retrieve_remote_branches(void)
void test_refs_foreachglob__retrieve_local_branches(void)
{
assert_retrieval("refs/heads/*", GIT_REF_LISTALL, 11);
assert_retrieval("refs/heads/*", GIT_REF_LISTALL, 12);
}
void test_refs_foreachglob__retrieve_partially_named_references(void)
......
......@@ -6,6 +6,8 @@
[remote "test"]
url = git://github.com/libgit2/libgit2
fetch = +refs/heads/*:refs/remotes/test/*
[remote "joshaber"]
url = git://github.com/libgit2/libgit2
[remote "test_with_pushurl"]
url = git://github.com/libgit2/fetchlibgit2
......@@ -18,3 +20,6 @@
[branch "track-local"]
remote = .
merge = refs/heads/master
[branch "cannot-fetch"]
remote = joshaber
merge = refs/heads/cannot-fetch
a4a7dce85cf63874e984719f4fdd239f5145052f
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