summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/network/refspecs.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/network/refspecs.c b/tests/network/refspecs.c
index 676a1fa99..aa9b36e58 100644
--- a/tests/network/refspecs.c
+++ b/tests/network/refspecs.c
@@ -84,4 +84,27 @@ void test_network_refspecs__parsing(void)
assert_refspec(GIT_DIRECTION_FETCH, "master", true);
assert_refspec(GIT_DIRECTION_PUSH, "master", true);
+
+ assert_refspec(GIT_DIRECTION_FETCH, "refs/pull/*/head:refs/remotes/origin/pr/*", true);
+}
+
+void assert_transform(const char *refspec, const char *name, const char *result)
+{
+ git_refspec spec;
+ git_buf buf = GIT_BUF_INIT;
+
+ git_refspec__parse(&spec, refspec, true);
+ cl_git_pass(git_refspec_transform(&buf, &spec, name));
+ cl_assert_equal_s(result, buf.ptr);
+
+ git_buf_free(&buf);
+ git_refspec__free(&spec);
+}
+
+void test_network_refspecs__transform_mid_star(void)
+{
+ assert_transform("refs/pull/*/head:refs/remotes/origin/pr/*", "refs/pull/23/head", "refs/remotes/origin/pr/23");
+ assert_transform("refs/heads/*:refs/remotes/origin/*", "refs/heads/master", "refs/remotes/origin/master");
+ assert_transform("refs/heads/*:refs/heads/*", "refs/heads/master", "refs/heads/master");
+ assert_transform("refs/*:refs/*", "refs/heads/master", "refs/heads/master");
}