Skip to content

Commit

Permalink
tests: submodule: verify setup of relative URLs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pks-t committed Jan 6, 2020
1 parent ff35577 commit 11e8ee1
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/submodule/modify.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 11e8ee1

Please sign in to comment.