Test git_submodule_add_setup with relative url
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
diff --git a/tests/submodule/modify.c b/tests/submodule/modify.c
index 1aaa563..7cd44e2 100644
--- a/tests/submodule/modify.c
+++ b/tests/submodule/modify.c
@@ -9,6 +9,10 @@ static git_repository *g_repo = NULL;
#define SM_LIBGIT2 "sm_libgit2"
#define SM_LIBGIT2B "sm_libgit2b"
+#define SM_RELATIVE_URL "../TestGitRepository"
+#define SM_RELATIVE_RESOLVED_URL "https://github.com/libgit2/TestGitRepository"
+#define SM_RELATIVE "TestGitRepository"
+
void test_submodule_modify__initialize(void)
{
g_repo = setup_fixture_submod2();
@@ -62,6 +66,26 @@ void test_submodule_modify__add(void)
git_config_free(cfg);
}
+void test_submodule_modify__add_with_relative_url(void) {
+ git_submodule *sm;
+ git_config *cfg;
+ const char *s;
+
+ git_repository* repo;
+ /* setup_fixture_submod2 does not work here because it does not set up origin configuration */
+ cl_git_pass(git_clone(&repo, SM_LIBGIT2_URL, "./sandbox/submodules_cloned", NULL));
+
+ cl_git_pass(
+ git_submodule_add_setup(&sm, repo, SM_RELATIVE_URL, SM_RELATIVE, 1)
+ );
+
+ cl_git_pass(git_repository_config(&cfg, repo));
+ cl_git_pass(
+ git_config_get_string(&s, cfg, "submodule." SM_RELATIVE ".url"));
+ cl_assert_equal_s(s, SM_RELATIVE_RESOLVED_URL);
+ git_config_free(cfg);
+}
+
static int delete_one_config(const git_config_entry *entry, void *payload)
{
git_config *cfg = payload;