Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit 17b06f4d47bfd9fae8073c85d71751df94e50050 1 parent 0e9f2fc
@arrbee arrbee authored
View
29 include/git2/submodule.h
@@ -396,6 +396,35 @@ GIT_EXTERN(git_submodule_update_t) git_submodule_set_update(
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.
*
* Just like "git submodule init", this copies information about the
View
20 src/submodule.c
@@ -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;
View
11 tests-clar/submodule/modify.c
@@ -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);
Please sign in to comment.
Something went wrong with that request. Please try again.