tests: submodule: verify setup of relative URLs When setting up relative URLs for a submodule, then we resolve it to the actual location and write that into ".git/config" instead of writing the relative value. We do not yet have a test to nail down this behaviour, which is now being added by this commit.
diff --git a/tests/submodule/modify.c b/tests/submodule/modify.c
index f7a089e..654f677 100644
--- a/tests/submodule/modify.c
+++ b/tests/submodule/modify.c
@@ -210,3 +210,24 @@ void test_submodule_modify__set_url(void)
cl_assert_equal_s(SM_LIBGIT2_URL, git_submodule_url(sm));
git_submodule_free(sm);
}
+
+void test_submodule_modify__set_relative_url(void)
+{
+ git_buf path = GIT_BUF_INIT;
+ git_repository *repo;
+ git_submodule *sm;
+
+ cl_git_pass(git_submodule_set_url(g_repo, SM1, "../relative-url"));
+ cl_git_pass(git_submodule_lookup(&sm, g_repo, SM1));
+ cl_git_pass(git_submodule_sync(sm));
+ cl_git_pass(git_submodule_open(&repo, sm));
+
+ cl_git_pass(git_buf_joinpath(&path, clar_sandbox_path(), "relative-url"));
+
+ assert_config_entry_value(g_repo, "submodule."SM1".url", path.ptr);
+ assert_config_entry_value(repo, "remote.origin.url", path.ptr);
+
+ git_repository_free(repo);
+ git_submodule_free(sm);
+ git_buf_dispose(&path);
+}