summaryrefslogtreecommitdiff
path: root/tests/path
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-05-30 12:18:04 +0200
committerPatrick Steinhardt <ps@pks.im>2018-06-01 12:49:09 +0200
commit92159bd46568870264d72741390e387ce5dbe271 (patch)
tree2a1765bd21179a84a3e1893220d996283ed4f028 /tests/path
parent771dfd1dd1c27a4693dfdfea521c07e72f456b29 (diff)
downloadlibgit2-92159bd46568870264d72741390e387ce5dbe271.tar.gz
path: unify `git_path_is_*` APIs
Right now, there's quite a lot of different function calls to determine whether a path component matches a specific name after normalization from the filesystem. We have a function for each of {gitattributes, gitmodules, gitignore} multiplicated with {generic, NTFS, HFS} checks. In the long time, this is unmaintainable in case there are e.g. new filesystems with specific semantics, blowing up the number of functions we need to implement. Replace all functions with a simple `git_path_is_gitfile` function, which accepts an enum pointing out the filename that is to be checked against as well as the filesystem normalizations to check for. This greatly simplifies implementation at the expense of the caller having to invoke a somewhat longer function call.
Diffstat (limited to 'tests/path')
-rw-r--r--tests/path/dotgit.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/path/dotgit.c b/tests/path/dotgit.c
index 20e585edb..309966945 100644
--- a/tests/path/dotgit.c
+++ b/tests/path/dotgit.c
@@ -94,21 +94,21 @@ static char *gitmodules_not_altnames[] = {
void test_path_dotgit__dotgit_modules(void)
{
size_t i;
- cl_assert_equal_i(1, git_path_is_dotgit_modules(".gitmodules", strlen(".gitmodules")));
- cl_assert_equal_i(1, git_path_is_dotgit_modules(".git\xe2\x80\x8cmodules", strlen(".git\xe2\x80\x8cmodules")));
+
+ cl_assert_equal_i(1, git_path_is_gitfile(".gitmodules", strlen(".gitmodules"), GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_GENERIC));
+ cl_assert_equal_i(1, git_path_is_gitfile(".git\xe2\x80\x8cmodules", strlen(".git\xe2\x80\x8cmodules"), GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_GENERIC));
for (i = 0; i < ARRAY_SIZE(gitmodules_altnames); i++) {
const char *name = gitmodules_altnames[i];
- if (!git_path_is_dotgit_modules(name, strlen(name)))
+ if (!git_path_is_gitfile(name, strlen(name), GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_GENERIC))
cl_fail(name);
}
for (i = 0; i < ARRAY_SIZE(gitmodules_not_altnames); i++) {
const char *name = gitmodules_not_altnames[i];
- if (git_path_is_dotgit_modules(name, strlen(name)))
+ if (git_path_is_gitfile(name, strlen(name), GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_GENERIC))
cl_fail(name);
}
-
}
void test_path_dotgit__dotgit_modules_symlink(void)