Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-04-03 22:29:08 +0400
committerRussell Belfer <rb@github.com>2014-04-03 22:29:08 +0400
commit18cc7d28c4c5ad4c9ecf7bfeab98a035500fd9d7 (patch)
tree4358522f777e6e0a8e8942f66ec24a4c6d5cd6f1 /tests/submodule
parentf2fb4bac68e7ab38cf6082655b2da153866a012d (diff)
Minor code cleanup
Diffstat (limited to 'tests/submodule')
-rw-r--r--tests/submodule/add.c62
1 files changed, 32 insertions, 30 deletions
diff --git a/tests/submodule/add.c b/tests/submodule/add.c
index 2d51b3d7e..af81713f1 100644
--- a/tests/submodule/add.c
+++ b/tests/submodule/add.c
@@ -5,20 +5,35 @@
static git_repository *g_repo = NULL;
-static void assert_submodule_url(const char* name, const char *url);
-
void test_submodule_add__cleanup(void)
{
cl_git_sandbox_cleanup();
}
+static void assert_submodule_url(const char* name, const char *url)
+{
+ git_config *cfg;
+ const char *s;
+ git_buf key = GIT_BUF_INIT;
+
+ cl_git_pass(git_repository_config(&cfg, g_repo));
+
+ cl_git_pass(git_buf_printf(&key, "submodule.%s.url", name));
+ cl_git_pass(git_config_get_string(&s, cfg, git_buf_cstr(&key)));
+ cl_assert_equal_s(s, url);
+
+ git_config_free(cfg);
+ git_buf_free(&key);
+}
+
void test_submodule_add__url_absolute(void)
{
- g_repo = setup_fixture_submod2();
git_submodule *sm;
+ g_repo = setup_fixture_submod2();
+
/* re-add existing submodule */
- cl_assert_equal_i(
+ cl_git_fail_with(
GIT_EEXISTS,
git_submodule_add_setup(NULL, g_repo, "whatever", "sm_unchanged", 1));
@@ -49,14 +64,15 @@ void test_submodule_add__url_absolute(void)
assert_submodule_url("sm_libgit2b", "https://github.com/libgit2/libgit2.git");
}
-void test_submodule_add__url_relative(void) {
+void test_submodule_add__url_relative(void)
+{
git_submodule *sm;
git_remote *remote;
-
+
/* default remote url is https://github.com/libgit2/false.git */
g_repo = cl_git_sandbox_init("testrepo2");
-
- /* make sure we're not defaulting to origin - rename origin -> test_remote */
+
+ /* make sure we don't default to origin - rename origin -> test_remote */
cl_git_pass(git_remote_load(&remote, g_repo, "origin"));
cl_git_pass(git_remote_rename(remote, "test_remote", NULL, NULL));
cl_git_fail(git_remote_load(&remote, g_repo, "origin"));
@@ -66,13 +82,14 @@ void test_submodule_add__url_relative(void) {
git_submodule_add_setup(&sm, g_repo, "../TestGitRepository", "TestGitRepository", 1)
);
git_submodule_free(sm);
-
+
assert_submodule_url("TestGitRepository", "https://github.com/libgit2/TestGitRepository");
}
-void test_submodule_add__url_relative_to_origin(void) {
+void test_submodule_add__url_relative_to_origin(void)
+{
git_submodule *sm;
-
+
/* default remote url is https://github.com/libgit2/false.git */
g_repo = cl_git_sandbox_init("testrepo2");
@@ -80,11 +97,12 @@ void test_submodule_add__url_relative_to_origin(void) {
git_submodule_add_setup(&sm, g_repo, "../TestGitRepository", "TestGitRepository", 1)
);
git_submodule_free(sm);
-
+
assert_submodule_url("TestGitRepository", "https://github.com/libgit2/TestGitRepository");
}
-void test_submodule_add__url_relative_to_workdir(void) {
+void test_submodule_add__url_relative_to_workdir(void)
+{
git_submodule *sm;
/* In this repo, HEAD (master) has no remote tracking branc h*/
@@ -94,22 +112,6 @@ void test_submodule_add__url_relative_to_workdir(void) {
git_submodule_add_setup(&sm, g_repo, "./", "TestGitRepository", 1)
);
git_submodule_free(sm);
-
- assert_submodule_url("TestGitRepository", git_repository_workdir(g_repo));
-}
-
-static void assert_submodule_url(const char* name, const char *url)
-{
- git_config *cfg;
- const char *s;
- git_buf key = GIT_BUF_INIT;
-
- cl_git_pass(git_repository_config(&cfg, g_repo));
- cl_git_pass(git_buf_printf(&key, "submodule.%s.url", name));
- cl_git_pass(git_config_get_string(&s, cfg, git_buf_cstr(&key)));
- cl_assert_equal_s(s, url);
-
- git_config_free(cfg);
- git_buf_free(&key);
+ assert_submodule_url("TestGitRepository", git_repository_workdir(g_repo));
}