Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-04-23 22:58:53 +0300
committerEdward Thomson <ethomson@edwardthomson.com>2015-05-04 15:18:30 +0300
commitcd79d99a4cd81b37f681c6f4eb6756cd8d42618c (patch)
treeb7a4b7a35524feb6b4977aaab67556441926d7d5 /tests/checkout
parentf286e2715d98e695462ca059de7a0206384ccbf1 (diff)
checkout test: better case-insensitive test on Mac
On Mac OS, `realpath` is deficient in determining the actual filename on-disk as it will simply provide the string you gave it if that file exists, instead of returning the filename as it exists. Instead we must read the directory entries for the parent directory to get the canonical filename.
Diffstat (limited to 'tests/checkout')
-rw-r--r--tests/checkout/icase.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/tests/checkout/icase.c b/tests/checkout/icase.c
index 82ad01e2a..510f5424d 100644
--- a/tests/checkout/icase.c
+++ b/tests/checkout/icase.c
@@ -6,6 +6,8 @@
#ifdef GIT_WIN32
# include <windows.h>
+#else
+# include <dirent.h>
#endif
static git_repository *repo;
@@ -40,7 +42,7 @@ void test_checkout_icase__cleanup(void)
cl_git_sandbox_cleanup();
}
-static char *test_realpath(const char *in)
+static char *get_filename(const char *in)
{
#ifdef GIT_WIN32
HANDLE fh;
@@ -65,7 +67,31 @@ static char *test_realpath(const char *in)
return filename;
#else
- return realpath(in, NULL);
+ char *search_dirname, *search_filename, *filename = NULL;
+ git_buf out = GIT_BUF_INIT;
+ DIR *dir;
+ struct dirent *de;
+
+ cl_assert(search_dirname = git_path_dirname(in));
+ cl_assert(search_filename = git_path_basename(in));
+
+ cl_assert(dir = opendir(search_dirname));
+
+ while ((de = readdir(dir))) {
+ if (strcasecmp(de->d_name, search_filename) == 0) {
+ git_buf_join(&out, '/', search_dirname, de->d_name);
+ filename = git_buf_detach(&out);
+ break;
+ }
+ }
+
+ closedir(dir);
+
+ git__free(search_dirname);
+ git__free(search_filename);
+ git_buf_free(&out);
+
+ return filename;
#endif
}
@@ -74,7 +100,7 @@ static void assert_name_is(const char *expected)
char *actual;
size_t actual_len, expected_len, start;
- cl_assert(actual = test_realpath(expected));
+ cl_assert(actual = get_filename(expected));
expected_len = strlen(expected);
actual_len = strlen(actual);