@@ -150,12 +150,27 @@ void test_submodule_modify__set_update(void)
150150 git_submodule_free (sm );
151151}
152152
153+ void test_submodule_modify__set_fetch_recurse_submodules (void )
154+ {
155+ git_submodule * sm ;
156+
157+ cl_git_pass (git_submodule_set_fetch_recurse_submodules (g_repo , "sm_changed_head" , GIT_SUBMODULE_RECURSE_YES ));
158+
159+ cl_git_pass (git_submodule_lookup (& sm , g_repo , "sm_changed_head" ));
160+ cl_assert_equal_i (GIT_SUBMODULE_RECURSE_YES , git_submodule_fetch_recurse_submodules (sm ));
161+ git_submodule_free (sm );
162+
163+ git_submodule_set_fetch_recurse_submodules (g_repo , "sm_changed_head" , GIT_SUBMODULE_RECURSE_ONDEMAND );
164+ cl_git_pass (git_submodule_lookup (& sm , g_repo , "sm_changed_head" ));
165+ cl_assert_equal_i (GIT_SUBMODULE_RECURSE_ONDEMAND , git_submodule_fetch_recurse_submodules (sm ));
166+ git_submodule_free (sm );
167+ }
168+
153169void test_submodule_modify__edit_and_save (void )
154170{
155171 git_submodule * sm1 , * sm2 ;
156172 char * old_url , * old_branch ;
157173 git_repository * r2 ;
158- git_submodule_recurse_t old_fetchrecurse ;
159174
160175 cl_git_pass (git_submodule_lookup (& sm1 , g_repo , "sm_changed_head" ));
161176
@@ -165,43 +180,29 @@ void test_submodule_modify__edit_and_save(void)
165180 /* modify properties of submodule */
166181 cl_git_pass (git_submodule_set_url (sm1 , SM_LIBGIT2_URL ));
167182 cl_git_pass (git_submodule_set_branch (sm1 , SM_LIBGIT2_BRANCH ));
168- old_fetchrecurse = git_submodule_set_fetch_recurse_submodules (
169- sm1 , GIT_SUBMODULE_RECURSE_YES );
170-
171183 cl_assert_equal_s (SM_LIBGIT2_URL , git_submodule_url (sm1 ));
172184 cl_assert_equal_s (SM_LIBGIT2_BRANCH , git_submodule_branch (sm1 ));
173- cl_assert_equal_i (
174- GIT_SUBMODULE_RECURSE_YES , git_submodule_fetch_recurse_submodules (sm1 ));
175185
176186 /* revert without saving (and confirm setters return old value) */
177187 cl_git_pass (git_submodule_set_url (sm1 , old_url ));
178188 cl_git_pass (git_submodule_set_branch (sm1 , old_branch ));
179- cl_assert_equal_i (
180- GIT_SUBMODULE_RECURSE_YES , git_submodule_set_fetch_recurse_submodules (
181- sm1 , GIT_SUBMODULE_RECURSE_RESET ));
182189
183190 /* check that revert was successful */
184191 cl_assert_equal_s (old_url , git_submodule_url (sm1 ));
185192 cl_assert_equal_s (old_branch , git_submodule_branch (sm1 ));
186- cl_assert_equal_i (
187- old_fetchrecurse , git_submodule_fetch_recurse_submodules (sm1 ));
188193
189194 /* modify properties of submodule (again) */
190195 cl_git_pass (git_submodule_set_url (sm1 , SM_LIBGIT2_URL ));
191196 cl_git_pass (git_submodule_set_branch (sm1 , SM_LIBGIT2_BRANCH ));
192- git_submodule_set_fetch_recurse_submodules (sm1 , GIT_SUBMODULE_RECURSE_YES );
193197
194198 /* call save */
195199 cl_git_pass (git_submodule_save (sm1 ));
196200
197- cl_assert_equal_i (GIT_SUBMODULE_RECURSE_YES , git_submodule_fetch_recurse_submodules (sm1 ));
198-
199201 /* call reload and check that the new values are loaded */
200202 cl_git_pass (git_submodule_reload (sm1 , 0 ));
201203
202204 cl_assert_equal_s (SM_LIBGIT2_URL , git_submodule_url (sm1 ));
203205 cl_assert_equal_s (SM_LIBGIT2_BRANCH , git_submodule_branch (sm1 ));
204- cl_assert_equal_i (GIT_SUBMODULE_RECURSE_YES , git_submodule_fetch_recurse_submodules (sm1 ));
205206
206207 /* unset branch again and verify that the property is deleted in config */
207208 cl_git_pass (git_submodule_set_branch (sm1 , NULL ));
@@ -214,19 +215,6 @@ void test_submodule_modify__edit_and_save(void)
214215 cl_git_pass (git_submodule_lookup (& sm2 , r2 , "sm_changed_head" ));
215216
216217 cl_assert_equal_s (SM_LIBGIT2_URL , git_submodule_url (sm2 ));
217- cl_assert_equal_i (
218- GIT_SUBMODULE_RECURSE_NO , git_submodule_fetch_recurse_submodules (sm2 ));
219-
220- /* set fetchRecurseSubmodules on-demand */
221- cl_git_pass (git_submodule_reload (sm1 , 0 ));
222- git_submodule_set_fetch_recurse_submodules (sm1 , GIT_SUBMODULE_RECURSE_ONDEMAND );
223- cl_assert_equal_i (
224- GIT_SUBMODULE_RECURSE_ONDEMAND , git_submodule_fetch_recurse_submodules (sm1 ));
225- /* call save */
226- cl_git_pass (git_submodule_save (sm1 ));
227- cl_git_pass (git_submodule_reload (sm1 , 0 ));
228- cl_assert_equal_i (
229- GIT_SUBMODULE_RECURSE_ONDEMAND , git_submodule_fetch_recurse_submodules (sm1 ));
230218
231219 git_submodule_free (sm1 );
232220 git_submodule_free (sm2 );
0 commit comments