@@ -33,34 +33,47 @@ static int dont_call_me_cb(const char *fetch_refspec, void *payload)
33
33
34
34
void test_network_remote_rename__renaming_a_remote_moves_related_configuration_section (void )
35
35
{
36
+ git_strarray problems = {0 };
37
+
36
38
assert_config_entry_existence (_repo , "remote.test.fetch" , true);
37
39
assert_config_entry_existence (_repo , "remote.just/renamed.fetch" , false);
38
40
39
- cl_git_pass (git_remote_rename (_remote , "just/renamed" , dont_call_me_cb , NULL ));
41
+ cl_git_pass (git_remote_rename (& problems , _remote , "just/renamed" ));
42
+ cl_assert_equal_i (0 , problems .count );
43
+ git_strarray_free (& problems );
40
44
41
45
assert_config_entry_existence (_repo , "remote.test.fetch" , false);
42
46
assert_config_entry_existence (_repo , "remote.just/renamed.fetch" , true);
43
47
}
44
48
45
49
void test_network_remote_rename__renaming_a_remote_updates_branch_related_configuration_entries (void )
46
50
{
51
+ git_strarray problems = {0 };
52
+
47
53
assert_config_entry_value (_repo , "branch.master.remote" , "test" );
48
54
49
- cl_git_pass (git_remote_rename (_remote , "just/renamed" , dont_call_me_cb , NULL ));
55
+ cl_git_pass (git_remote_rename (& problems , _remote , "just/renamed" ));
56
+ cl_assert_equal_i (0 , problems .count );
57
+ git_strarray_free (& problems );
50
58
51
59
assert_config_entry_value (_repo , "branch.master.remote" , "just/renamed" );
52
60
}
53
61
54
62
void test_network_remote_rename__renaming_a_remote_updates_default_fetchrefspec (void )
55
63
{
56
- cl_git_pass (git_remote_rename (_remote , "just/renamed" , dont_call_me_cb , NULL ));
64
+ git_strarray problems = {0 };
65
+
66
+ cl_git_pass (git_remote_rename (& problems , _remote , "just/renamed" ));
67
+ cl_assert_equal_i (0 , problems .count );
68
+ git_strarray_free (& problems );
57
69
58
70
assert_config_entry_value (_repo , "remote.just/renamed.fetch" , "+refs/heads/*:refs/remotes/just/renamed/*" );
59
71
}
60
72
61
73
void test_network_remote_rename__renaming_a_remote_without_a_fetchrefspec_doesnt_create_one (void )
62
74
{
63
75
git_config * config ;
76
+ git_strarray problems = {0 };
64
77
65
78
git_remote_free (_remote );
66
79
cl_git_pass (git_repository_config__weakptr (& config , _repo ));
@@ -70,70 +83,64 @@ void test_network_remote_rename__renaming_a_remote_without_a_fetchrefspec_doesnt
70
83
71
84
assert_config_entry_existence (_repo , "remote.test.fetch" , false);
72
85
73
- cl_git_pass (git_remote_rename (_remote , "just/renamed" , dont_call_me_cb , NULL ));
86
+ cl_git_pass (git_remote_rename (& problems , _remote , "just/renamed" ));
87
+ cl_assert_equal_i (0 , problems .count );
88
+ git_strarray_free (& problems );
74
89
75
90
assert_config_entry_existence (_repo , "remote.just/renamed.fetch" , false);
76
91
}
77
92
78
- static int ensure_refspecs (const char * refspec_name , void * payload )
79
- {
80
- int i = 0 ;
81
- bool found = false;
82
- const char * * exp = (const char * * )payload ;
83
-
84
- while (exp [i ]) {
85
- if (strcmp (exp [i ++ ], refspec_name ))
86
- continue ;
87
-
88
- found = true;
89
- break ;
90
- }
91
-
92
- cl_assert (found );
93
-
94
- return 0 ;
95
- }
96
-
97
93
void test_network_remote_rename__renaming_a_remote_notifies_of_non_default_fetchrefspec (void )
98
94
{
99
95
git_config * config ;
100
96
101
- char * expected_refspecs [] = {
102
- "+refs/*:refs/*" ,
103
- NULL
104
- };
97
+ git_strarray problems = {0 };
105
98
106
99
git_remote_free (_remote );
107
100
cl_git_pass (git_repository_config__weakptr (& config , _repo ));
108
101
cl_git_pass (git_config_set_string (config , "remote.test.fetch" , "+refs/*:refs/*" ));
109
102
cl_git_pass (git_remote_load (& _remote , _repo , "test" ));
110
103
111
- cl_git_pass (git_remote_rename (_remote , "just/renamed" , ensure_refspecs , & expected_refspecs ));
104
+ cl_git_pass (git_remote_rename (& problems , _remote , "just/renamed" ));
105
+ cl_assert_equal_i (1 , problems .count );
106
+ cl_assert_equal_s ("+refs/*:refs/*" , problems .strings [0 ]);
107
+ git_strarray_free (& problems );
112
108
113
109
assert_config_entry_value (_repo , "remote.just/renamed.fetch" , "+refs/*:refs/*" );
110
+
111
+ git_strarray_free (& problems );
114
112
}
115
113
116
114
void test_network_remote_rename__new_name_can_contain_dots (void )
117
115
{
118
- cl_git_pass (git_remote_rename (_remote , "just.renamed" , dont_call_me_cb , NULL ));
116
+ git_strarray problems = {0 };
117
+
118
+ cl_git_pass (git_remote_rename (& problems , _remote , "just.renamed" ));
119
+ cl_assert_equal_i (0 , problems .count );
120
+ git_strarray_free (& problems );
119
121
cl_assert_equal_s ("just.renamed" , git_remote_name (_remote ));
120
122
}
121
123
122
124
void test_network_remote_rename__new_name_must_conform_to_reference_naming_conventions (void )
123
125
{
126
+ git_strarray problems = {0 };
127
+
124
128
cl_assert_equal_i (
125
129
GIT_EINVALIDSPEC ,
126
- git_remote_rename (_remote , "new@{name" , dont_call_me_cb , NULL ));
130
+ git_remote_rename (& problems , _remote , "new@{name" ));
127
131
}
128
132
129
133
void test_network_remote_rename__renamed_name_is_persisted (void )
130
134
{
131
135
git_remote * renamed ;
132
136
git_repository * another_repo ;
137
+ git_strarray problems = {0 };
133
138
134
139
cl_git_fail (git_remote_load (& renamed , _repo , "just/renamed" ));
135
140
136
- cl_git_pass (git_remote_rename (_remote , "just/renamed" , dont_call_me_cb , NULL ));
141
+ cl_git_pass (git_remote_rename (& problems , _remote , "just/renamed" ));
142
+ cl_assert_equal_i (0 , problems .count );
143
+ git_strarray_free (& problems );
137
144
138
145
cl_git_pass (git_repository_open (& another_repo , "testrepo.git" ));
139
146
cl_git_pass (git_remote_load (& renamed , _repo , "just/renamed" ));
@@ -144,19 +151,24 @@ void test_network_remote_rename__renamed_name_is_persisted(void)
144
151
145
152
void test_network_remote_rename__cannot_overwrite_an_existing_remote (void )
146
153
{
147
- cl_assert_equal_i (GIT_EEXISTS , git_remote_rename (_remote , "test" , dont_call_me_cb , NULL ));
148
- cl_assert_equal_i (GIT_EEXISTS , git_remote_rename (_remote , "test_with_pushurl" , dont_call_me_cb , NULL ));
154
+ git_strarray problems = {0 };
155
+
156
+ cl_assert_equal_i (GIT_EEXISTS , git_remote_rename (& problems , _remote , "test" ));
157
+ cl_assert_equal_i (GIT_EEXISTS , git_remote_rename (& problems , _remote , "test_with_pushurl" ));
149
158
}
150
159
151
160
void test_network_remote_rename__renaming_a_remote_moves_the_underlying_reference (void )
152
161
{
153
162
git_reference * underlying ;
163
+ git_strarray problems = {0 };
154
164
155
165
cl_assert_equal_i (GIT_ENOTFOUND , git_reference_lookup (& underlying , _repo , "refs/remotes/just/renamed" ));
156
166
cl_git_pass (git_reference_lookup (& underlying , _repo , "refs/remotes/test/master" ));
157
167
git_reference_free (underlying );
158
168
159
- cl_git_pass (git_remote_rename (_remote , "just/renamed" , dont_call_me_cb , NULL ));
169
+ cl_git_pass (git_remote_rename (& problems , _remote , "just/renamed" ));
170
+ cl_assert_equal_i (0 , problems .count );
171
+ git_strarray_free (& problems );
160
172
161
173
cl_assert_equal_i (GIT_ENOTFOUND , git_reference_lookup (& underlying , _repo , "refs/remotes/test/master" ));
162
174
cl_git_pass (git_reference_lookup (& underlying , _repo , "refs/remotes/just/renamed/master" ));
@@ -166,10 +178,12 @@ void test_network_remote_rename__renaming_a_remote_moves_the_underlying_referenc
166
178
void test_network_remote_rename__cannot_rename_an_inmemory_remote (void )
167
179
{
168
180
git_remote * remote ;
181
+ git_strarray problems = {0 };
169
182
170
183
cl_git_pass (git_remote_create_anonymous (& remote , _repo , "file:///blah" , NULL ));
171
- cl_git_fail (git_remote_rename (remote , "newname" , NULL , NULL ));
184
+ cl_git_fail (git_remote_rename (& problems , remote , "newname" ));
172
185
186
+ git_strarray_free (& problems );
173
187
git_remote_free (remote );
174
188
}
175
189
@@ -181,15 +195,17 @@ void test_network_remote_rename__overwrite_ref_in_target(void)
181
195
git_reference * ref ;
182
196
git_branch_t btype ;
183
197
git_branch_iterator * iter ;
198
+ git_strarray problems = {0 };
184
199
185
200
cl_git_pass (git_oid_fromstr (& id , "a65fedf39aefe402d3bb6e24df4d4f5fe4547750" ));
186
201
cl_git_pass (git_reference_create (& ref , _repo , "refs/remotes/renamed/master" , & id , 1 , NULL , NULL ));
187
202
git_reference_free (ref );
188
203
189
204
cl_git_pass (git_remote_load (& remote , _repo , "test" ));
190
- cl_git_pass (git_remote_rename (remote , "renamed" , dont_call_me_cb , NULL ));
205
+ cl_git_pass (git_remote_rename (& problems , remote , "renamed" ));
191
206
git_remote_free (remote );
192
-
207
+ cl_assert_equal_i (0 , problems .count );
208
+ git_strarray_free (& problems );
193
209
194
210
/* make sure there's only one remote-tracking branch */
195
211
cl_git_pass (git_branch_iterator_new (& iter , _repo , GIT_BRANCH_REMOTE ));
0 commit comments