diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2018-10-19 13:14:35 +0300 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2018-10-20 15:51:46 +0300 |
commit | 628dae8b1c87da412db2a7714fa6b0f3a4b1eea9 (patch) | |
tree | 6f7dcc80d039b52254ac45f7496733b8aeafe2d1 /tests/repo | |
parent | df1733deb9eb7b4125bd994ea7b441712788e181 (diff) |
tests: provide symlink support helper function
Diffstat (limited to 'tests/repo')
-rw-r--r-- | tests/repo/init.c | 9 | ||||
-rw-r--r-- | tests/repo/repo_helpers.c | 12 | ||||
-rw-r--r-- | tests/repo/repo_helpers.h | 1 |
3 files changed, 14 insertions, 8 deletions
diff --git a/tests/repo/init.c b/tests/repo/init.c index 52cf1577b..677c23891 100644 --- a/tests/repo/init.c +++ b/tests/repo/init.c @@ -249,15 +249,8 @@ void test_repo_init__detect_ignorecase(void) void test_repo_init__detect_symlinks(void) { - struct stat st; - bool no_symlinks; - - no_symlinks = (p_symlink("target", "link") < 0 || - p_lstat("link", &st) < 0 || - ! (S_ISLNK(st.st_mode))); - assert_config_entry_on_init( - "core.symlinks", no_symlinks ? false : GIT_ENOTFOUND); + "core.symlinks", filesystem_supports_symlinks("link") ? GIT_ENOTFOUND : false); } void test_repo_init__detect_precompose_unicode_required(void) diff --git a/tests/repo/repo_helpers.c b/tests/repo/repo_helpers.c index 4dc5bfc6f..50a201e86 100644 --- a/tests/repo/repo_helpers.c +++ b/tests/repo/repo_helpers.c @@ -20,3 +20,15 @@ void delete_head(git_repository* repo) git_buf_dispose(&head_path); } + +int filesystem_supports_symlinks(const char *path) +{ + struct stat st; + + if (p_symlink("target", path) < 0 || + p_lstat(path, &st) < 0 || + !(S_ISLNK(st.st_mode))) + return 0; + + return 1; +} diff --git a/tests/repo/repo_helpers.h b/tests/repo/repo_helpers.h index 6783d5701..f184865ce 100644 --- a/tests/repo/repo_helpers.h +++ b/tests/repo/repo_helpers.h @@ -4,3 +4,4 @@ extern void make_head_unborn(git_repository* repo, const char *target); extern void delete_head(git_repository* repo); +extern int filesystem_supports_symlinks(const char *path); |