mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-28 02:16:21 +00:00
Add missing accessor for fetchRecurseSubmodules
When `git_submodule` became an opaque structure, I forgot to add accessor functions for the fetchRecurseSubmodules config setting. This fixes that.
This commit is contained in:
parent
0e9f2fcef6
commit
17b06f4d47
@ -395,6 +395,35 @@ GIT_EXTERN(git_submodule_update_t) git_submodule_set_update(
|
||||
git_submodule *submodule,
|
||||
git_submodule_update_t update);
|
||||
|
||||
/**
|
||||
* Read the fetchRecurseSubmodules rule for a submodule.
|
||||
*
|
||||
* This accesses the submodule.<name>.fetchRecurseSubmodules value for
|
||||
* the submodule that controls fetching behavior for the submodule.
|
||||
*
|
||||
* Note that at this time, libgit2 does not honor this setting and the
|
||||
* fetch functionality current ignores submodules.
|
||||
*
|
||||
* @return 0 if fetchRecurseSubmodules is false, 1 if true
|
||||
*/
|
||||
GIT_EXTERN(int) git_submodule_fetch_recurse_submodules(
|
||||
git_submodule *submodule);
|
||||
|
||||
/**
|
||||
* Set the fetchRecurseSubmodules rule for a submodule.
|
||||
*
|
||||
* This sets the submodule.<name>.fetchRecurseSubmodules value for
|
||||
* the submodule. You should call `git_submodule_save()` if you want
|
||||
* to persist the new value.
|
||||
*
|
||||
* @param submodule The submodule to modify
|
||||
* @param fetch_recurse_submodules Boolean value
|
||||
* @return old value for fetchRecurseSubmodules
|
||||
*/
|
||||
GIT_EXTERN(int) git_submodule_set_fetch_recurse_submodules(
|
||||
git_submodule *submodule,
|
||||
int fetch_recurse_submodules);
|
||||
|
||||
/**
|
||||
* Copy submodule info into ".git/config" file.
|
||||
*
|
||||
|
@ -595,6 +595,26 @@ git_submodule_update_t git_submodule_set_update(
|
||||
return old;
|
||||
}
|
||||
|
||||
int git_submodule_fetch_recurse_submodules(
|
||||
git_submodule *submodule)
|
||||
{
|
||||
assert(submodule);
|
||||
return submodule->fetch_recurse;
|
||||
}
|
||||
|
||||
int git_submodule_set_fetch_recurse_submodules(
|
||||
git_submodule *submodule,
|
||||
int fetch_recurse_submodules)
|
||||
{
|
||||
int old;
|
||||
|
||||
assert(submodule);
|
||||
|
||||
old = submodule->fetch_recurse;
|
||||
submodule->fetch_recurse = (fetch_recurse_submodules != 0);
|
||||
return old;
|
||||
}
|
||||
|
||||
int git_submodule_init(git_submodule *submodule, int overwrite)
|
||||
{
|
||||
int error;
|
||||
|
@ -183,6 +183,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;
|
||||
|
||||
cl_git_pass(git_submodule_lookup(&sm1, g_repo, "sm_changed_head"));
|
||||
|
||||
@ -192,12 +193,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);
|
||||
|
||||
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));
|
||||
|
||||
/* revert without saving (and confirm setters return old value) */
|
||||
cl_git_pass(git_submodule_set_url(sm1, old_url));
|
||||
@ -207,16 +210,21 @@ void test_submodule_modify__edit_and_save(void)
|
||||
cl_assert_equal_i(
|
||||
(int)GIT_SUBMODULE_UPDATE_REBASE,
|
||||
(int)git_submodule_set_update(sm1, GIT_SUBMODULE_UPDATE_DEFAULT));
|
||||
cl_assert_equal_i(
|
||||
1, git_submodule_set_fetch_recurse_submodules(sm1, old_fetchrecurse));
|
||||
|
||||
/* check that revert was successful */
|
||||
cl_assert_equal_s(old_url, git_submodule_url(sm1));
|
||||
cl_assert_equal_i((int)old_ignore, (int)git_submodule_ignore(sm1));
|
||||
cl_assert_equal_i((int)old_update, (int)git_submodule_update(sm1));
|
||||
cl_assert_equal_i(
|
||||
old_fetchrecurse, git_submodule_fetch_recurse_submodules(sm1));
|
||||
|
||||
/* modify properties of submodule (again) */
|
||||
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);
|
||||
|
||||
/* call save */
|
||||
cl_git_pass(git_submodule_save(sm1));
|
||||
@ -232,6 +240,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));
|
||||
|
||||
/* call reload and check that the new values are loaded */
|
||||
cl_git_pass(git_submodule_reload(sm1));
|
||||
@ -241,6 +250,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));
|
||||
|
||||
/* open a second copy of the repo and compare submodule */
|
||||
cl_git_pass(git_repository_open(&r2, "submod2"));
|
||||
@ -251,6 +261,7 @@ 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));
|
||||
|
||||
git_repository_free(r2);
|
||||
git__free(old_url);
|
||||
|
Loading…
Reference in New Issue
Block a user