Update test related to fetchRecurseSubmodules
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
diff --git a/tests/submodule/modify.c b/tests/submodule/modify.c
index e326287..8ec9fce 100644
--- a/tests/submodule/modify.c
+++ b/tests/submodule/modify.c
@@ -168,7 +168,7 @@ void test_submodule_modify__edit_and_save(void)
git_submodule_ignore_t old_ignore;
git_submodule_update_t old_update;
git_repository *r2;
- int old_fetchrecurse;
+ git_submodule_recurse_t old_fetchrecurse;
cl_git_pass(git_submodule_lookup(&sm1, g_repo, "sm_changed_head"));
@@ -178,14 +178,14 @@ void test_submodule_modify__edit_and_save(void)
cl_git_pass(git_submodule_set_url(sm1, SM_LIBGIT2_URL));
old_ignore = git_submodule_set_ignore(sm1, GIT_SUBMODULE_IGNORE_UNTRACKED);
old_update = git_submodule_set_update(sm1, GIT_SUBMODULE_UPDATE_REBASE);
- old_fetchrecurse = git_submodule_set_fetch_recurse_submodules(sm1, 1);
+ old_fetchrecurse = git_submodule_set_fetch_recurse_submodules(sm1, GIT_SUBMODULE_RECURSE_YES);
cl_assert_equal_s(SM_LIBGIT2_URL, git_submodule_url(sm1));
cl_assert_equal_i(
(int)GIT_SUBMODULE_IGNORE_UNTRACKED, (int)git_submodule_ignore(sm1));
cl_assert_equal_i(
(int)GIT_SUBMODULE_UPDATE_REBASE, (int)git_submodule_update(sm1));
- cl_assert_equal_i(1, git_submodule_fetch_recurse_submodules(sm1));
+ cl_assert_equal_i(GIT_SUBMODULE_RECURSE_YES, git_submodule_fetch_recurse_submodules(sm1));
/* revert without saving (and confirm setters return old value) */
cl_git_pass(git_submodule_set_url(sm1, old_url));
@@ -196,7 +196,7 @@ void test_submodule_modify__edit_and_save(void)
(int)GIT_SUBMODULE_UPDATE_REBASE,
(int)git_submodule_set_update(sm1, GIT_SUBMODULE_UPDATE_RESET));
cl_assert_equal_i(
- 1, git_submodule_set_fetch_recurse_submodules(sm1, old_fetchrecurse));
+ GIT_SUBMODULE_RECURSE_YES, git_submodule_set_fetch_recurse_submodules(sm1, old_fetchrecurse));
/* check that revert was successful */
cl_assert_equal_s(old_url, git_submodule_url(sm1));
@@ -209,7 +209,7 @@ void test_submodule_modify__edit_and_save(void)
cl_git_pass(git_submodule_set_url(sm1, SM_LIBGIT2_URL));
git_submodule_set_ignore(sm1, GIT_SUBMODULE_IGNORE_UNTRACKED);
git_submodule_set_update(sm1, GIT_SUBMODULE_UPDATE_REBASE);
- git_submodule_set_fetch_recurse_submodules(sm1, 1);
+ git_submodule_set_fetch_recurse_submodules(sm1, GIT_SUBMODULE_RECURSE_YES);
/* call save */
cl_git_pass(git_submodule_save(sm1));
@@ -225,7 +225,7 @@ void test_submodule_modify__edit_and_save(void)
(int)GIT_SUBMODULE_IGNORE_UNTRACKED, (int)git_submodule_ignore(sm1));
cl_assert_equal_i(
(int)GIT_SUBMODULE_UPDATE_REBASE, (int)git_submodule_update(sm1));
- cl_assert_equal_i(1, git_submodule_fetch_recurse_submodules(sm1));
+ cl_assert_equal_i(GIT_SUBMODULE_RECURSE_YES, git_submodule_fetch_recurse_submodules(sm1));
/* call reload and check that the new values are loaded */
cl_git_pass(git_submodule_reload(sm1));
@@ -235,7 +235,7 @@ void test_submodule_modify__edit_and_save(void)
(int)GIT_SUBMODULE_IGNORE_UNTRACKED, (int)git_submodule_ignore(sm1));
cl_assert_equal_i(
(int)GIT_SUBMODULE_UPDATE_REBASE, (int)git_submodule_update(sm1));
- cl_assert_equal_i(1, git_submodule_fetch_recurse_submodules(sm1));
+ cl_assert_equal_i(GIT_SUBMODULE_RECURSE_YES, git_submodule_fetch_recurse_submodules(sm1));
/* open a second copy of the repo and compare submodule */
cl_git_pass(git_repository_open(&r2, "submod2"));
@@ -246,7 +246,16 @@ void test_submodule_modify__edit_and_save(void)
(int)GIT_SUBMODULE_IGNORE_UNTRACKED, (int)git_submodule_ignore(sm2));
cl_assert_equal_i(
(int)GIT_SUBMODULE_UPDATE_REBASE, (int)git_submodule_update(sm2));
- cl_assert_equal_i(1, git_submodule_fetch_recurse_submodules(sm2));
+ cl_assert_equal_i(GIT_SUBMODULE_RECURSE_YES, git_submodule_fetch_recurse_submodules(sm2));
+
+ /* set fetchRecurseSubmodules on-demand */
+ cl_git_pass(git_submodule_reload(sm1));
+ git_submodule_set_fetch_recurse_submodules(sm1, GIT_SUBMODULE_RECURSE_ONDEMAND);
+ cl_assert_equal_i(GIT_SUBMODULE_RECURSE_ONDEMAND, git_submodule_fetch_recurse_submodules(sm1));
+ /* call save */
+ cl_git_pass(git_submodule_save(sm1));
+ cl_git_pass(git_submodule_reload(sm1));
+ cl_assert_equal_i(GIT_SUBMODULE_RECURSE_ONDEMAND, git_submodule_fetch_recurse_submodules(sm1));
git_repository_free(r2);
git__free(old_url);