Commit ffd264d9 by Patrick Steinhardt

tests: repo: fix repo discovery tests on overlayfs

Debian and Ubuntu often use schroot to build their DEB packages in a
controlled environment. Depending on how schroot is configured, our
tests regarding repository discovery break due to not being able to find
the repositories anymore. It turns out that these errors occur when the
schroot is configured to use an overlayfs on the directory structures.

The reason for this failure is that we usually refrain from discovering
repositories across devices. But unfortunately, overlayfs does not have
consistent device identifiers for all its files but will instead use the
device number of the filesystem the file stems from. So whenever we
cross boundaries between the upper and lower layer of the overlay, we
will fail to properly detect the repository and bail out.

This commit fixes the issue by enabling cross-device discovery in our
tests. While it would be preferable to have this turned off, it probably
won't do much harm anyway as we set up our tests in a temporary location
outside of the parent repository.
parent 7849e467
...@@ -33,7 +33,7 @@ static void ensure_repository_discover(const char *start_path, ...@@ -33,7 +33,7 @@ static void ensure_repository_discover(const char *start_path,
git_buf_attach(&resolved, p_realpath(expected_path, NULL), 0); git_buf_attach(&resolved, p_realpath(expected_path, NULL), 0);
cl_assert(resolved.size > 0); cl_assert(resolved.size > 0);
cl_git_pass(git_path_to_dir(&resolved)); cl_git_pass(git_path_to_dir(&resolved));
cl_git_pass(git_repository_discover(&found_path, start_path, 0, ceiling_dirs)); cl_git_pass(git_repository_discover(&found_path, start_path, 1, ceiling_dirs));
cl_assert_equal_s(found_path.ptr, resolved.ptr); cl_assert_equal_s(found_path.ptr, resolved.ptr);
......
...@@ -398,7 +398,8 @@ void test_repo_open__force_bare(void) ...@@ -398,7 +398,8 @@ void test_repo_open__force_bare(void)
cl_git_fail(git_repository_open_bare(&barerepo, "alternate/subdir/sub2")); cl_git_fail(git_repository_open_bare(&barerepo, "alternate/subdir/sub2"));
cl_git_pass(git_repository_open_ext( cl_git_pass(git_repository_open_ext(
&barerepo, "alternate/subdir/sub2", GIT_REPOSITORY_OPEN_BARE, NULL)); &barerepo, "alternate/subdir/sub2",
GIT_REPOSITORY_OPEN_BARE|GIT_REPOSITORY_OPEN_CROSS_FS, NULL));
cl_assert(git_repository_is_bare(barerepo)); cl_assert(git_repository_is_bare(barerepo));
git_repository_free(barerepo); git_repository_free(barerepo);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment