summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/git2/checkout.h22
-rw-r--r--include/git2/errors.h1
-rw-r--r--include/git2/refs.h20
-rw-r--r--include/git2/submodule.h29
-rw-r--r--src/blob.c4
-rw-r--r--src/cache.c9
-rw-r--r--src/checkout.c6
-rw-r--r--src/clone.c7
-rw-r--r--src/index.c2
-rw-r--r--src/iterator.c7
-rw-r--r--src/refs.c47
-rw-r--r--src/repository.h15
-rw-r--r--src/reset.c5
-rw-r--r--src/submodule.c20
-rw-r--r--tests-clar/object/peel.c35
-rw-r--r--tests-clar/refs/peel.c91
-rw-r--r--tests-clar/reset/mixed.c2
-rw-r--r--tests-clar/submodule/modify.c11
18 files changed, 286 insertions, 47 deletions
diff --git a/include/git2/checkout.h b/include/git2/checkout.h
index ac31b3462..deb828722 100644
--- a/include/git2/checkout.h
+++ b/include/git2/checkout.h
@@ -40,13 +40,13 @@ typedef struct git_checkout_opts {
* @param repo repository to check out (must be non-bare)
* @param opts specifies checkout options (may be NULL)
* @param stats structure through which progress information is reported
- * @return 0 on success, GIT_ERROR otherwise (use giterr_last for information about the error)
+ * @return 0 on success, GIT_ERROR otherwise (use giterr_last for information
+ * about the error)
*/
-GIT_EXTERN(int) git_checkout_head(git_repository *repo,
- git_checkout_opts *opts,
- git_indexer_stats *stats);
-
-
+GIT_EXTERN(int) git_checkout_head(
+ git_repository *repo,
+ git_checkout_opts *opts,
+ git_indexer_stats *stats);
/**
* Updates files in the working tree to match a commit pointed to by a ref.
@@ -54,11 +54,13 @@ GIT_EXTERN(int) git_checkout_head(git_repository *repo,
* @param ref reference to follow to a commit
* @param opts specifies checkout options (may be NULL)
* @param stats structure through which progress information is reported
- * @return 0 on success, GIT_ERROR otherwise (use giterr_last for information about the error)
+ * @return 0 on success, GIT_ERROR otherwise (use giterr_last for information
+ * about the error)
*/
-GIT_EXTERN(int) git_checkout_reference(git_reference *ref,
- git_checkout_opts *opts,
- git_indexer_stats *stats);
+GIT_EXTERN(int) git_checkout_reference(
+ git_reference *ref,
+ git_checkout_opts *opts,
+ git_indexer_stats *stats);
/** @} */
diff --git a/include/git2/errors.h b/include/git2/errors.h
index f6671c49d..e5f435926 100644
--- a/include/git2/errors.h
+++ b/include/git2/errors.h
@@ -26,6 +26,7 @@ enum {
GIT_EAMBIGUOUS = -5,
GIT_EBUFS = -6,
GIT_EUSER = -7,
+ GIT_EBAREREPO = -8,
GIT_PASSTHROUGH = -30,
GIT_ITEROVER = -31,
diff --git a/include/git2/refs.h b/include/git2/refs.h
index 660b48b5f..73b32a9e2 100644
--- a/include/git2/refs.h
+++ b/include/git2/refs.h
@@ -434,6 +434,26 @@ GIT_EXTERN(int) git_reference_normalize_name(
const char *name,
unsigned int flags);
+/**
+ * Recursively peel an reference until an object of the
+ * specified type is met.
+ *
+ * The retrieved `peeled` object is owned by the repository
+ * and should be closed with the `git_object_free` method.
+ *
+ * If you pass `GIT_OBJ_ANY` as the target type, then the object
+ * will be peeled until a non-tag object is met.
+ *
+ * @param peeled Pointer to the peeled git_object
+ * @param ref The reference to be processed
+ * @param target_type The type of the requested object
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_reference_peel(
+ git_object **out,
+ git_reference *ref,
+ git_otype type);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/submodule.h b/include/git2/submodule.h
index fe7f26cfe..28057d26f 100644
--- a/include/git2/submodule.h
+++ b/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
diff --git a/src/blob.c b/src/blob.c
index 6267ae7b2..a5a0b6dde 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -211,8 +211,10 @@ int git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *pat
const char *workdir;
int error;
+ if ((error = git_repository__ensure_not_bare(repo, "create blob from file")) < 0)
+ return error;
+
workdir = git_repository_workdir(repo);
- assert(workdir); /* error to call this on bare repo */
if (git_buf_joinpath(&full_path, workdir, path) < 0) {
git_buf_free(&full_path);
diff --git a/src/cache.c b/src/cache.c
index 3aa14f012..1f5b8872c 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -89,12 +89,13 @@ void *git_cache_try_store(git_cache *cache, void *_entry)
git_cached_obj_decref(node, cache->free_obj);
cache->nodes[hash & cache->size_mask] = entry;
}
+
+ /* increase the refcount again, because we are
+ * returning it to the user */
+ git_cached_obj_incref(entry);
+
}
git_mutex_unlock(&cache->lock);
- /* increase the refcount again, because we are
- * returning it to the user */
- git_cached_obj_incref(entry);
-
return entry;
}
diff --git a/src/checkout.c b/src/checkout.c
index 88df2128d..d1720fcf3 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -22,9 +22,6 @@
#include "filter.h"
#include "blob.h"
-GIT_BEGIN_DECL
-
-
typedef struct tree_walk_data
{
git_indexer_stats *stats;
@@ -226,6 +223,3 @@ int git_checkout_reference(git_reference *ref,
git_reference_free(head);
return retcode;
}
-
-
-GIT_END_DECL
diff --git a/src/clone.c b/src/clone.c
index 33953d7a0..e06e9ada8 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -26,8 +26,6 @@
#include "refs.h"
#include "path.h"
-GIT_BEGIN_DECL
-
struct HeadInfo {
git_repository *repo;
git_oid remote_head_oid;
@@ -247,8 +245,3 @@ int git_clone(git_repository **out,
return retcode;
}
-
-
-
-
-GIT_END_DECL
diff --git a/src/index.c b/src/index.c
index a1042b723..3a92c360b 100644
--- a/src/index.c
+++ b/src/index.c
@@ -247,7 +247,7 @@ int git_index_set_caps(git_index *index, unsigned int caps)
if (git_config_get_bool(&val, cfg, "core.filemode") == 0)
index->distrust_filemode = (val == 0);
if (git_config_get_bool(&val, cfg, "core.symlinks") == 0)
- index->no_symlinks = (val != 0);
+ index->no_symlinks = (val == 0);
}
else {
index->ignore_case = ((caps & GIT_INDEXCAP_IGNORE_CASE) != 0);
diff --git a/src/iterator.c b/src/iterator.c
index 92fe67134..e30e11220 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -659,11 +659,8 @@ int git_iterator_for_workdir_range(
assert(iter && repo);
- if (git_repository_is_bare(repo)) {
- giterr_set(GITERR_INVALID,
- "Cannot scan working directory for bare repo");
- return -1;
- }
+ if ((error = git_repository__ensure_not_bare(repo, "scan working directory")) < 0)
+ return error;
ITERATOR_BASE_INIT(wi, workdir, WORKDIR);
diff --git a/src/refs.c b/src/refs.c
index 211a5870c..cdf3cb96e 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -1844,3 +1844,50 @@ int git_reference_is_remote(git_reference *ref)
assert(ref);
return git__prefixcmp(ref->name, GIT_REFS_REMOTES_DIR) == 0;
}
+
+static int peel_error(int error, git_reference *ref, const char* msg)
+{
+ giterr_set(
+ GITERR_INVALID,
+ "The reference '%s' cannot be peeled - %s", git_reference_name(ref), msg);
+ return error;
+}
+
+static int reference_target(git_object **object, git_reference *ref)
+{
+ const git_oid *oid;
+
+ oid = git_reference_oid(ref);
+
+ return git_object_lookup(object, git_reference_owner(ref), oid, GIT_OBJ_ANY);
+}
+
+int git_reference_peel(
+ git_object **peeled,
+ git_reference *ref,
+ git_otype target_type)
+{
+ git_reference *resolved = NULL;
+ git_object *target = NULL;
+ int error;
+
+ assert(ref);
+
+ if ((error = git_reference_resolve(&resolved, ref)) < 0)
+ return peel_error(error, ref, "Cannot resolve reference");
+
+ if ((error = reference_target(&target, resolved)) < 0) {
+ peel_error(error, ref, "Cannot retrieve reference target");
+ goto cleanup;
+ }
+
+ if (target_type == GIT_OBJ_ANY && git_object_type(target) != GIT_OBJ_TAG)
+ error = git_object__dup(peeled, target);
+ else
+ error = git_object_peel(peeled, target, target_type);
+
+cleanup:
+ git_object_free(target);
+ git_reference_free(resolved);
+ return error;
+}
diff --git a/src/repository.h b/src/repository.h
index 82988ba0a..b919fd814 100644
--- a/src/repository.h
+++ b/src/repository.h
@@ -128,4 +128,19 @@ void git_repository__cvar_cache_clear(git_repository *repo);
*/
extern void git_submodule_config_free(git_repository *repo);
+GIT_INLINE(int) git_repository__ensure_not_bare(
+ git_repository *repo,
+ const char *operation_name)
+{
+ if (!git_repository_is_bare(repo))
+ return 0;
+
+ giterr_set(
+ GITERR_REPOSITORY,
+ "Cannot %s. This operation is not allowed against bare repositories.",
+ operation_name);
+
+ return GIT_EBAREREPO;
+}
+
#endif
diff --git a/src/reset.c b/src/reset.c
index f9e16f7c6..5aaf94840 100644
--- a/src/reset.c
+++ b/src/reset.c
@@ -34,8 +34,9 @@ int git_reset(
if (git_object_owner(target) != repo)
return reset_error_invalid("The given target does not belong to this repository.");
- if (reset_type == GIT_RESET_MIXED && git_repository_is_bare(repo))
- return reset_error_invalid("Mixed reset is not allowed in a bare repository.");
+ if (reset_type == GIT_RESET_MIXED
+ && git_repository__ensure_not_bare(repo, "reset mixed") < 0)
+ return GIT_EBAREREPO;
if (git_object_peel(&commit, target, GIT_OBJ_COMMIT) < 0) {
reset_error_invalid("The given target does not resolve to a commit");
diff --git a/src/submodule.c b/src/submodule.c
index 66f1f84b4..5ae38bccd 100644
--- a/src/submodule.c
+++ b/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;
diff --git a/tests-clar/object/peel.c b/tests-clar/object/peel.c
index f4ea1eb0f..f748be7f4 100644
--- a/tests-clar/object/peel.c
+++ b/tests-clar/object/peel.c
@@ -12,7 +12,11 @@ void test_object_peel__cleanup(void)
git_repository_free(g_repo);
}
-static void assert_peel(const char* expected_sha, const char *sha, git_otype requested_type)
+static void assert_peel(
+ const char *sha,
+ git_otype requested_type,
+ const char* expected_sha,
+ git_otype expected_type)
{
git_oid oid, expected_oid;
git_object *obj;
@@ -26,6 +30,8 @@ static void assert_peel(const char* expected_sha, const char *sha, git_otype req
cl_git_pass(git_oid_fromstr(&expected_oid, expected_sha));
cl_assert_equal_i(0, git_oid_cmp(&expected_oid, git_object_id(peeled)));
+ cl_assert_equal_i(expected_type, git_object_type(peeled));
+
git_object_free(peeled);
git_object_free(obj);
}
@@ -46,21 +52,28 @@ static void assert_peel_error(int error, const char *sha, git_otype requested_ty
void test_object_peel__peeling_an_object_into_its_own_type_returns_another_instance_of_it(void)
{
- assert_peel("e90810b8df3e80c413d903f631643c716887138d", "e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_COMMIT);
- assert_peel("7b4384978d2493e851f9cca7858815fac9b10980", "7b4384978d2493e851f9cca7858815fac9b10980", GIT_OBJ_TAG);
- assert_peel("53fc32d17276939fc79ed05badaef2db09990016", "53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_TREE);
- assert_peel("0266163a49e280c4f5ed1e08facd36a2bd716bcf", "0266163a49e280c4f5ed1e08facd36a2bd716bcf", GIT_OBJ_BLOB);
+ assert_peel("e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_COMMIT,
+ "e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_COMMIT);
+ assert_peel("7b4384978d2493e851f9cca7858815fac9b10980", GIT_OBJ_TAG,
+ "7b4384978d2493e851f9cca7858815fac9b10980", GIT_OBJ_TAG);
+ assert_peel("53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_TREE,
+ "53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_TREE);
+ assert_peel("0266163a49e280c4f5ed1e08facd36a2bd716bcf", GIT_OBJ_BLOB,
+ "0266163a49e280c4f5ed1e08facd36a2bd716bcf", GIT_OBJ_BLOB);
}
void test_object_peel__can_peel_a_tag(void)
{
- assert_peel("e90810b8df3e80c413d903f631643c716887138d", "7b4384978d2493e851f9cca7858815fac9b10980", GIT_OBJ_COMMIT);
- assert_peel("53fc32d17276939fc79ed05badaef2db09990016", "7b4384978d2493e851f9cca7858815fac9b10980", GIT_OBJ_TREE);
+ assert_peel("7b4384978d2493e851f9cca7858815fac9b10980", GIT_OBJ_COMMIT,
+ "e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_COMMIT);
+ assert_peel("7b4384978d2493e851f9cca7858815fac9b10980", GIT_OBJ_TREE,
+ "53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_TREE);
}
void test_object_peel__can_peel_a_commit(void)
{
- assert_peel("53fc32d17276939fc79ed05badaef2db09990016", "e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_TREE);
+ assert_peel("e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_TREE,
+ "53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_TREE);
}
void test_object_peel__cannot_peel_a_tree(void)
@@ -76,10 +89,12 @@ void test_object_peel__cannot_peel_a_blob(void)
void test_object_peel__target_any_object_for_type_change(void)
{
/* tag to commit */
- assert_peel("e90810b8df3e80c413d903f631643c716887138d", "7b4384978d2493e851f9cca7858815fac9b10980", GIT_OBJ_ANY);
+ assert_peel("7b4384978d2493e851f9cca7858815fac9b10980", GIT_OBJ_ANY,
+ "e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_COMMIT);
/* commit to tree */
- assert_peel("53fc32d17276939fc79ed05badaef2db09990016", "e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_ANY);
+ assert_peel("e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_ANY,
+ "53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_TREE);
/* fail to peel tree */
assert_peel_error(GIT_ERROR, "53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_ANY);
diff --git a/tests-clar/refs/peel.c b/tests-clar/refs/peel.c
new file mode 100644
index 000000000..35a290b2e
--- /dev/null
+++ b/tests-clar/refs/peel.c
@@ -0,0 +1,91 @@
+#include "clar_libgit2.h"
+
+static git_repository *g_repo;
+
+void test_refs_peel__initialize(void)
+{
+ cl_git_pass(git_repository_open(&g_repo, cl_fixture("testrepo.git")));
+}
+
+void test_refs_peel__cleanup(void)
+{
+ git_repository_free(g_repo);
+}
+
+static void assert_peel(
+ const char *ref_name,
+ git_otype requested_type,
+ const char* expected_sha,
+ git_otype expected_type)
+{
+ git_oid expected_oid;
+ git_reference *ref;
+ git_object *peeled;
+
+ cl_git_pass(git_reference_lookup(&ref, g_repo, ref_name));
+
+ cl_git_pass(git_reference_peel(&peeled, ref, requested_type));
+
+ cl_git_pass(git_oid_fromstr(&expected_oid, expected_sha));
+ cl_assert_equal_i(0, git_oid_cmp(&expected_oid, git_object_id(peeled)));
+
+ cl_assert_equal_i(expected_type, git_object_type(peeled));
+
+ git_object_free(peeled);
+ git_reference_free(ref);
+}
+
+static void assert_peel_error(int error, const char *ref_name, git_otype requested_type)
+{
+ git_reference *ref;
+ git_object *peeled;
+
+ cl_git_pass(git_reference_lookup(&ref, g_repo, ref_name));
+
+ cl_assert_equal_i(error, git_reference_peel(&peeled, ref, requested_type));
+
+ git_reference_free(ref);
+}
+
+void test_refs_peel__can_peel_a_tag(void)
+{
+ assert_peel("refs/tags/test", GIT_OBJ_TAG,
+ "b25fa35b38051e4ae45d4222e795f9df2e43f1d1", GIT_OBJ_TAG);
+ assert_peel("refs/tags/test", GIT_OBJ_COMMIT,
+ "e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_COMMIT);
+ assert_peel("refs/tags/test", GIT_OBJ_TREE,
+ "53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJ_TREE);
+ assert_peel("refs/tags/point_to_blob", GIT_OBJ_BLOB,
+ "1385f264afb75a56a5bec74243be9b367ba4ca08", GIT_OBJ_BLOB);
+}
+
+void test_refs_peel__can_peel_a_branch(void)
+{
+ assert_peel("refs/heads/master", GIT_OBJ_COMMIT,
+ "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", GIT_OBJ_COMMIT);
+ assert_peel("refs/heads/master", GIT_OBJ_TREE,
+ "944c0f6e4dfa41595e6eb3ceecdb14f50fe18162", GIT_OBJ_TREE);
+}
+
+void test_refs_peel__can_peel_a_symbolic_reference(void)
+{
+ assert_peel("HEAD", GIT_OBJ_COMMIT,
+ "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", GIT_OBJ_COMMIT);
+ assert_peel("HEAD", GIT_OBJ_TREE,
+ "944c0f6e4dfa41595e6eb3ceecdb14f50fe18162", GIT_OBJ_TREE);
+}
+
+void test_refs_peel__cannot_peel_into_a_non_existing_target(void)
+{
+ assert_peel_error(GIT_ERROR, "refs/tags/point_to_blob", GIT_OBJ_TAG);
+}
+
+void test_refs_peel__can_peel_into_any_non_tag_object(void)
+{
+ assert_peel("refs/heads/master", GIT_OBJ_ANY,
+ "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", GIT_OBJ_COMMIT);
+ assert_peel("refs/tags/point_to_blob", GIT_OBJ_ANY,
+ "1385f264afb75a56a5bec74243be9b367ba4ca08", GIT_OBJ_BLOB);
+ assert_peel("refs/tags/test", GIT_OBJ_ANY,
+ "e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_COMMIT);
+}
diff --git a/tests-clar/reset/mixed.c b/tests-clar/reset/mixed.c
index 7cfff65d4..d5f8e10c5 100644
--- a/tests-clar/reset/mixed.c
+++ b/tests-clar/reset/mixed.c
@@ -27,7 +27,7 @@ void test_reset_mixed__cannot_reset_in_a_bare_repository(void)
retrieve_target_from_oid(&target, bare, KNOWN_COMMIT_IN_BARE_REPO);
- cl_git_fail(git_reset(bare, target, GIT_RESET_MIXED));
+ cl_assert_equal_i(GIT_EBAREREPO, git_reset(bare, target, GIT_RESET_MIXED));
git_repository_free(bare);
}
diff --git a/tests-clar/submodule/modify.c b/tests-clar/submodule/modify.c
index ffbbe891c..0fd732cc3 100644
--- a/tests-clar/submodule/modify.c
+++ b/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);