summaryrefslogtreecommitdiff
path: root/tests/submodule/submodule_helpers.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-03-25 09:14:48 -0700
committerRussell Belfer <rb@github.com>2014-03-25 09:14:48 -0700
commita15c7802c86cf995fa658ef0624c46d352ce9a81 (patch)
tree25bebc086059abc13e74a3a8b4e461c0cf06dc64 /tests/submodule/submodule_helpers.c
parentf210cb5b1442f82e2f930909d8430f7cc6661c5f (diff)
downloadlibgit2-a15c7802c86cf995fa658ef0624c46d352ce9a81.tar.gz
Make submodules externally refcounted
`git_submodule` objects were already refcounted internally in case the submodule name was different from the path at which it was stored. This makes that refcounting externally used as well, so `git_submodule_lookup` and `git_submodule_add_setup` return an object that requires a `git_submodule_free` when done.
Diffstat (limited to 'tests/submodule/submodule_helpers.c')
-rw-r--r--tests/submodule/submodule_helpers.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/submodule/submodule_helpers.c b/tests/submodule/submodule_helpers.c
index d5750675c..546f0913a 100644
--- a/tests/submodule/submodule_helpers.c
+++ b/tests/submodule/submodule_helpers.c
@@ -125,3 +125,32 @@ git_repository *setup_fixture_submod2(void)
return repo;
}
+
+void assert_submodule_exists(git_repository *repo, const char *name)
+{
+ git_submodule *sm;
+ cl_git_pass(git_submodule_lookup(&sm, repo, name));
+ cl_assert(sm);
+ git_submodule_free(sm);
+}
+
+void refute_submodule_exists(
+ git_repository *repo, const char *name, int expected_error)
+{
+ git_submodule *sm;
+ cl_assert_equal_i(
+ expected_error, git_submodule_lookup(&sm, repo, name));
+}
+
+unsigned int get_submodule_status(git_repository *repo, const char *name)
+{
+ git_submodule *sm = NULL;
+ unsigned int status = 0;
+
+ cl_git_pass(git_submodule_lookup(&sm, repo, name));
+ cl_assert(sm);
+ cl_git_pass(git_submodule_status(&status, sm));
+ git_submodule_free(sm);
+
+ return status;
+}