@@ -151,13 +151,11 @@ void test_refs_create__propagate_eexists(void)
151151 cl_assert (error == GIT_EEXISTS );
152152}
153153
154- void test_refs_create__creating_a_reference_with_an_invalid_name_returns_EINVALIDSPEC ( void )
154+ static void test_invalid_name ( const char * name )
155155{
156156 git_reference * new_reference ;
157157 git_oid id ;
158158
159- const char * name = "refs/heads/inv@{id" ;
160-
161159 git_oid_fromstr (& id , current_master_tip );
162160
163161 cl_assert_equal_i (GIT_EINVALIDSPEC , git_reference_create (
@@ -166,3 +164,47 @@ void test_refs_create__creating_a_reference_with_an_invalid_name_returns_EINVALI
166164 cl_assert_equal_i (GIT_EINVALIDSPEC , git_reference_symbolic_create (
167165 & new_reference , g_repo , name , current_head_target , 0 , NULL , NULL ));
168166}
167+
168+ void test_refs_create__creating_a_reference_with_an_invalid_name_returns_EINVALIDSPEC (void )
169+ {
170+ test_invalid_name ("refs/heads/inv@{id" );
171+ test_invalid_name ("refs/heads/back\\slash" );
172+
173+ test_invalid_name ("refs/heads/foo " );
174+ test_invalid_name ("refs/heads/foo /bar" );
175+ test_invalid_name ("refs/heads/com1:bar/foo" );
176+
177+ test_invalid_name ("refs/heads/e:" );
178+ test_invalid_name ("refs/heads/c:/foo" );
179+
180+ test_invalid_name ("refs/heads/foo." );
181+ }
182+
183+ static void test_win32_name (const char * name )
184+ {
185+ git_reference * new_reference = NULL ;
186+ git_oid id ;
187+ int ret ;
188+
189+ git_oid_fromstr (& id , current_master_tip );
190+
191+ ret = git_reference_create (& new_reference , g_repo , name , & id , 0 , NULL , NULL );
192+
193+ #ifdef GIT_WIN32
194+ cl_assert_equal_i (GIT_EINVALIDSPEC , ret );
195+ #else
196+ cl_git_pass (ret );
197+ #endif
198+
199+ git_reference_free (new_reference );
200+ }
201+
202+ void test_refs_create__creating_a_loose_ref_with_invalid_windows_name (void )
203+ {
204+ test_win32_name ("refs/heads/foo./bar" );
205+
206+ test_win32_name ("refs/heads/aux" );
207+ test_win32_name ("refs/heads/aux.foo/bar" );
208+
209+ test_win32_name ("refs/heads/com1" );
210+ }
0 commit comments