44
55#define REPO_PATH "testrepo2/.gitted"
66#define REMOTE_ORIGIN "origin"
7- #define REMOTE_INSTEADOF "insteadof-test"
7+ #define REMOTE_INSTEADOF_URL_FETCH "insteadof-url-fetch"
8+ #define REMOTE_INSTEADOF_URL_PUSH "insteadof-url-push"
9+ #define REMOTE_INSTEADOF_URL_BOTH "insteadof-url-both"
10+ #define REMOTE_INSTEADOF_PUSHURL_FETCH "insteadof-pushurl-fetch"
11+ #define REMOTE_INSTEADOF_PUSHURL_PUSH "insteadof-pushurl-push"
12+ #define REMOTE_INSTEADOF_PUSHURL_BOTH "insteadof-pushurl-both"
813
914static git_repository * g_repo ;
1015static git_remote * g_remote ;
@@ -21,52 +26,129 @@ void test_remote_insteadof__cleanup(void)
2126 git_remote_free (g_remote );
2227}
2328
24- void test_remote_insteadof__url_insteadof_not_applicable (void )
29+ void test_remote_insteadof__not_applicable (void )
2530{
2631 cl_git_pass (git_repository_open (& g_repo , cl_fixture (REPO_PATH )));
2732 cl_git_pass (git_remote_lookup (& g_remote , g_repo , REMOTE_ORIGIN ));
2833
2934 cl_assert_equal_s (
3035 git_remote_url (g_remote ),
3136 "https://github.com/libgit2/false.git" );
37+ cl_assert_equal_p (git_remote_pushurl (g_remote ), NULL );
3238}
3339
34- void test_remote_insteadof__url_insteadof_applicable (void )
40+ void test_remote_insteadof__url_insteadof_fetch (void )
3541{
3642 cl_git_pass (git_repository_open (& g_repo , cl_fixture (REPO_PATH )));
37- cl_git_pass (git_remote_lookup (& g_remote , g_repo , REMOTE_INSTEADOF ));
43+ cl_git_pass (git_remote_lookup (& g_remote , g_repo , REMOTE_INSTEADOF_URL_FETCH ));
3844
3945 cl_assert_equal_s (
4046 git_remote_url (g_remote ),
41- "http://github.com/libgit2/libgit2" );
47+ "http://github.com/url/fetch/libgit2" );
48+ cl_assert_equal_p (git_remote_pushurl (g_remote ), NULL );
4249}
4350
44- void test_remote_insteadof__pushurl_insteadof_not_applicable (void )
51+ void test_remote_insteadof__url_insteadof_push (void )
4552{
4653 cl_git_pass (git_repository_open (& g_repo , cl_fixture (REPO_PATH )));
47- cl_git_pass (git_remote_lookup (& g_remote , g_repo , REMOTE_ORIGIN ));
54+ cl_git_pass (git_remote_lookup (& g_remote , g_repo , REMOTE_INSTEADOF_URL_PUSH ));
4855
49- cl_assert_equal_p (git_remote_pushurl (g_remote ), NULL );
56+ cl_assert_equal_s (
57+ git_remote_url (g_remote ),
58+ "http://example.com/url/push/libgit2" );
59+ cl_assert_equal_s (
60+ git_remote_pushurl (g_remote ),
61+ "git@github.com:url/push/libgit2" );
5062}
5163
52- void test_remote_insteadof__pushurl_insteadof_applicable (void )
64+ void test_remote_insteadof__url_insteadof_both (void )
5365{
5466 cl_git_pass (git_repository_open (& g_repo , cl_fixture (REPO_PATH )));
55- cl_git_pass (git_remote_lookup (& g_remote , g_repo , REMOTE_INSTEADOF ));
67+ cl_git_pass (git_remote_lookup (& g_remote , g_repo , REMOTE_INSTEADOF_URL_BOTH ));
5668
69+ cl_assert_equal_s (
70+ git_remote_url (g_remote ),
71+ "http://github.com/url/both/libgit2" );
5772 cl_assert_equal_s (
5873 git_remote_pushurl (g_remote ),
59- "git@github.com:libgit2 /libgit2" );
74+ "git@github.com:url/both /libgit2" );
6075}
6176
62- void test_remote_insteadof__anonymous_remote (void )
77+ void test_remote_insteadof__pushurl_insteadof_fetch (void )
78+ {
79+ cl_git_pass (git_repository_open (& g_repo , cl_fixture (REPO_PATH )));
80+ cl_git_pass (git_remote_lookup (& g_remote , g_repo , REMOTE_INSTEADOF_PUSHURL_FETCH ));
81+
82+ cl_assert_equal_s (
83+ git_remote_url (g_remote ),
84+ "http://github.com/url/fetch/libgit2" );
85+ cl_assert_equal_s (
86+ git_remote_pushurl (g_remote ),
87+ "http://github.com/url/fetch/libgit2-push" );
88+ }
89+
90+ void test_remote_insteadof__pushurl_insteadof_push (void )
91+ {
92+ cl_git_pass (git_repository_open (& g_repo , cl_fixture (REPO_PATH )));
93+ cl_git_pass (git_remote_lookup (& g_remote , g_repo , REMOTE_INSTEADOF_PUSHURL_PUSH ));
94+
95+ cl_assert_equal_s (
96+ git_remote_url (g_remote ),
97+ "http://example.com/url/push/libgit2" );
98+ cl_assert_equal_s (
99+ git_remote_pushurl (g_remote ),
100+ "http://example.com/url/push/libgit2-push" );
101+ }
102+
103+ void test_remote_insteadof__pushurl_insteadof_both (void )
104+ {
105+ cl_git_pass (git_repository_open (& g_repo , cl_fixture (REPO_PATH )));
106+ cl_git_pass (git_remote_lookup (& g_remote , g_repo , REMOTE_INSTEADOF_PUSHURL_BOTH ));
107+
108+ cl_assert_equal_s (
109+ git_remote_url (g_remote ),
110+ "http://github.com/url/both/libgit2" );
111+ cl_assert_equal_s (
112+ git_remote_pushurl (g_remote ),
113+ "http://github.com/url/both/libgit2-push" );
114+ }
115+
116+ void test_remote_insteadof__anonymous_remote_fetch (void )
63117{
64118 cl_git_pass (git_repository_open (& g_repo , cl_fixture (REPO_PATH )));
65119 cl_git_pass (git_remote_create_anonymous (& g_remote , g_repo ,
66- "http://example.com/libgit2 /libgit2" ));
120+ "http://example.com/url/fetch /libgit2" ));
67121
68122 cl_assert_equal_s (
69123 git_remote_url (g_remote ),
70- "http://github.com/libgit2 /libgit2" );
124+ "http://github.com/url/fetch /libgit2" );
71125 cl_assert_equal_p (git_remote_pushurl (g_remote ), NULL );
72126}
127+
128+ void test_remote_insteadof__anonymous_remote_push (void )
129+ {
130+ cl_git_pass (git_repository_open (& g_repo , cl_fixture (REPO_PATH )));
131+ cl_git_pass (git_remote_create_anonymous (& g_remote , g_repo ,
132+ "http://example.com/url/push/libgit2" ));
133+
134+ cl_assert_equal_s (
135+ git_remote_url (g_remote ),
136+ "http://example.com/url/push/libgit2" );
137+ cl_assert_equal_s (
138+ git_remote_pushurl (g_remote ),
139+ "git@github.com:url/push/libgit2" );
140+ }
141+
142+ void test_remote_insteadof__anonymous_remote_both (void )
143+ {
144+ cl_git_pass (git_repository_open (& g_repo , cl_fixture (REPO_PATH )));
145+ cl_git_pass (git_remote_create_anonymous (& g_remote , g_repo ,
146+ "http://example.com/url/both/libgit2" ));
147+
148+ cl_assert_equal_s (
149+ git_remote_url (g_remote ),
150+ "http://github.com/url/both/libgit2" );
151+ cl_assert_equal_s (
152+ git_remote_pushurl (g_remote ),
153+ "git@github.com:url/both/libgit2" );
154+ }
0 commit comments