@@ -135,31 +135,22 @@ void test_submodule_add__path_exists_in_index(void)
135135 git_submodule * sm ;
136136 git_buf dirname = GIT_BUF_INIT ;
137137 git_buf filename = GIT_BUF_INIT ;
138- FILE * fd ;
139138
140139 /* In this repo, HEAD (master) has no remote tracking branc h*/
141140 g_repo = cl_git_sandbox_init ("testrepo" );
142141
143- git_buf_joinpath (& dirname , git_repository_workdir (g_repo ), "TestGitRepository" );
144- git_buf_joinpath (& filename , dirname .ptr , "test.txt" );
142+ cl_git_pass ( git_buf_joinpath (& dirname , git_repository_workdir (g_repo ), "TestGitRepository" ) );
143+ cl_git_pass ( git_buf_joinpath (& filename , dirname .ptr , "test.txt" ) );
145144
146- p_mkdir (dirname .ptr , 0700 );
147- fd = fopen (filename .ptr , "w" );
148- fclose (fd );
145+ cl_git_pass (p_mkdir (dirname .ptr , 0700 ));
146+ cl_git_mkfile (filename .ptr , "This is some content" );
149147
150- cl_git_pass (
151- git_repository_index__weakptr (& index , g_repo )
152- );
148+ cl_git_pass (git_repository_index__weakptr (& index , g_repo ));
149+ cl_git_pass (git_index_add_bypath (index , "TestGitRepository/test.txt" ));
153150
154- cl_git_pass (
155- git_index_add_bypath (index , "TestGitRepository/test.txt" )
156- );
157-
158- cl_git_fail_with (
159- git_submodule_add_setup (& sm , g_repo , "./" , "TestGitRepository" , 1 ),
160- GIT_EEXISTS
161- );
151+ cl_git_fail_with (git_submodule_add_setup (& sm , g_repo , "./" , "TestGitRepository" , 1 ), GIT_EEXISTS );
162152
153+ git_submodule_free (sm );
163154 git_buf_free (& dirname );
164155 git_buf_free (& filename );
165156}
@@ -169,28 +160,19 @@ void test_submodule_add__file_exists_in_index(void)
169160 git_index * index ;
170161 git_submodule * sm ;
171162 git_buf name = GIT_BUF_INIT ;
172- FILE * fd ;
173163
174164 /* In this repo, HEAD (master) has no remote tracking branc h*/
175165 g_repo = cl_git_sandbox_init ("testrepo" );
176166
177- git_buf_joinpath (& name , git_repository_workdir (g_repo ), "TestGitRepository" );
167+ cl_git_pass ( git_buf_joinpath (& name , git_repository_workdir (g_repo ), "TestGitRepository" ) );
178168
179- fd = fopen (name .ptr , "w" );
180- fclose (fd );
169+ cl_git_mkfile (name .ptr , "Test content" );
181170
182- cl_git_pass (
183- git_repository_index__weakptr (& index , g_repo )
184- );
171+ cl_git_pass (git_repository_index__weakptr (& index , g_repo ));
172+ cl_git_pass (git_index_add_bypath (index , "TestGitRepository" ));
185173
186- cl_git_pass (
187- git_index_add_bypath (index , "TestGitRepository" )
188- );
189-
190- cl_git_fail_with (
191- git_submodule_add_setup (& sm , g_repo , "./" , "TestGitRepository" , 1 ),
192- GIT_EEXISTS
193- );
174+ cl_git_fail_with (git_submodule_add_setup (& sm , g_repo , "./" , "TestGitRepository" , 1 ), GIT_EEXISTS );
194175
176+ git_submodule_free (sm );
195177 git_buf_free (& name );
196178}
0 commit comments