summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2015-05-28 10:13:07 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2015-05-28 10:13:07 -0400
commitfb92b48d541edde845e8cde176152f13592db71b (patch)
tree3fe5e8316c6bb9ffa33bfee48372ee11a1b8196d /tests
parent2b92283221114843c36e4e6372b5b793b2d5ffff (diff)
parent5014fe95f5691ec9c48e1bb33fa03d925a4159f0 (diff)
downloadlibgit2-fb92b48d541edde845e8cde176152f13592db71b.tar.gz
Merge pull request #3149 from libgit2/cmn/upstream-matching-push
Fill the pointers for matching refspecs
Diffstat (limited to 'tests')
-rw-r--r--tests/network/refspecs.c10
-rw-r--r--tests/refs/branches/upstream.c32
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/network/refspecs.c b/tests/network/refspecs.c
index c6bcb10e8..614d91d07 100644
--- a/tests/network/refspecs.c
+++ b/tests/network/refspecs.c
@@ -146,3 +146,13 @@ void test_network_refspecs__invalid_reverse(void)
assert_invalid_rtransform("refs/heads/*:refs/remotes/origin/*", "master");
assert_invalid_rtransform("refs/heads/*:refs/remotes/origin/*", "refs/remotes/o/master");
}
+
+void test_network_refspecs__matching(void)
+{
+ git_refspec spec;
+
+ cl_git_pass(git_refspec__parse(&spec, ":", false));
+ cl_assert_equal_s(":", spec.string);
+ cl_assert_equal_s("", spec.src);
+ cl_assert_equal_s("", spec.dst);
+}
diff --git a/tests/refs/branches/upstream.c b/tests/refs/branches/upstream.c
index 351449416..8f2e7a2ca 100644
--- a/tests/refs/branches/upstream.c
+++ b/tests/refs/branches/upstream.c
@@ -159,3 +159,35 @@ void test_refs_branches_upstream__set_unset_upstream(void)
cl_git_sandbox_cleanup();
}
+
+void test_refs_branches_upstream__no_fetch_refspec(void)
+{
+ git_reference *ref, *branch;
+ git_repository *repo;
+ git_remote *remote;
+ git_config *cfg;
+
+ repo = cl_git_sandbox_init("testrepo.git");
+
+ cl_git_pass(git_remote_create_with_fetchspec(&remote, repo, "matching", ".", NULL));
+ cl_git_pass(git_remote_add_push(repo, "matching", ":"));
+
+ cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/test"));
+ cl_git_pass(git_reference_create(&ref, repo, "refs/remotes/matching/master", git_reference_target(branch), 1, "fetch"));
+ cl_git_fail(git_branch_set_upstream(branch, "matching/master"));
+ cl_assert_equal_s("Could not determine remote for 'refs/remotes/matching/master'",
+ giterr_last()->message);
+
+ /* we can't set it automatically, so let's test the user setting it by hand */
+ cl_git_pass(git_repository_config(&cfg, repo));
+ cl_git_pass(git_config_set_string(cfg, "branch.test.remote", "matching"));
+ cl_git_pass(git_config_set_string(cfg, "branch.test.merge", "refs/heads/master"));
+ /* we still can't find it because there is no rule for that reference */
+ cl_git_fail_with(GIT_ENOTFOUND, git_branch_upstream(&ref, branch));
+
+ git_reference_free(ref);
+ git_reference_free(branch);
+ git_remote_free(remote);
+
+ cl_git_sandbox_cleanup();
+}