summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt39
-rw-r--r--tests/README.md8
-rw-r--r--tests/attr/repo.c2
-rw-r--r--tests/checkout/conflict.c24
-rw-r--r--tests/checkout/crlf.c18
-rw-r--r--tests/checkout/head.c24
-rw-r--r--tests/checkout/icase.c22
-rw-r--r--tests/checkout/index.c62
-rw-r--r--tests/checkout/nasty.c6
-rw-r--r--tests/checkout/tree.c202
-rw-r--r--tests/checkout/typechange.c34
-rw-r--r--tests/cherrypick/workdir.c18
-rw-r--r--tests/clar.h6
-rw-r--r--tests/clar/summary.h10
-rw-r--r--tests/clar_libgit2.c20
-rw-r--r--tests/clar_libgit2_trace.c2
-rw-r--r--tests/clone/nonetwork.c18
-rw-r--r--tests/commit/commit.c4
-rw-r--r--tests/config/global.c8
-rw-r--r--tests/config/read.c8
-rw-r--r--tests/config/readonly.c10
-rw-r--r--tests/config/stress.c8
-rw-r--r--tests/core/copy.c84
-rw-r--r--tests/core/dirent.c48
-rw-r--r--tests/core/env.c6
-rw-r--r--tests/core/filebuf.c24
-rw-r--r--tests/core/futils.c6
-rw-r--r--tests/core/iconv.c20
-rw-r--r--tests/core/init.c2
-rw-r--r--tests/core/mkdir.c108
-rw-r--r--tests/core/path.c98
-rw-r--r--tests/core/posix.c12
-rw-r--r--tests/core/rmdir.c26
-rw-r--r--tests/core/stat.c2
-rw-r--r--tests/date/date.c10
-rw-r--r--tests/date/rfc2822.c33
-rw-r--r--tests/diff/binary.c2
-rw-r--r--tests/diff/drivers.c2
-rw-r--r--tests/diff/rename.c2
-rw-r--r--tests/diff/tree.c2
-rw-r--r--tests/diff/workdir.c10
-rw-r--r--tests/email/create.c.bak386
-rw-r--r--tests/fetchhead/nonetwork.c12
-rw-r--r--tests/filter/custom_helpers.c3
-rw-r--r--tests/filter/file.c6
-rw-r--r--tests/generate.py75
-rw-r--r--tests/headertest.c13
-rw-r--r--tests/ignore/path.c4
-rw-r--r--tests/index/crlf.c16
-rw-r--r--tests/index/tests.c4
-rw-r--r--tests/iterator/index.c2
-rw-r--r--tests/iterator/workdir.c2
-rw-r--r--tests/merge/merge_helpers.c4
-rw-r--r--tests/merge/merge_helpers.h4
-rw-r--r--tests/merge/workdir/setup.c178
-rw-r--r--tests/merge/workdir/simple.c2
-rw-r--r--tests/network/fetchlocal.c4
-rw-r--r--tests/network/remote/push.c4
-rw-r--r--tests/notes/notes.c2
-rw-r--r--tests/object/blob/write.c4
-rw-r--r--tests/object/raw/write.c4
-rw-r--r--tests/object/tag/write.c2
-rw-r--r--tests/odb/alternates.c2
-rw-r--r--tests/odb/backend/backend_helpers.c17
-rw-r--r--tests/odb/backend/backend_helpers.h4
-rw-r--r--tests/odb/backend/multiple.c4
-rw-r--r--tests/odb/backend/nonrefreshing.c2
-rw-r--r--tests/odb/backend/refreshing.c176
-rw-r--r--tests/odb/backend/simple.c2
-rw-r--r--tests/odb/emptyobjects.c2
-rw-r--r--tests/odb/loose.c4
-rw-r--r--tests/online/clone.c10
-rw-r--r--tests/online/customcert.c4
-rw-r--r--tests/online/push_util.c2
-rw-r--r--tests/pack/filelimit.c2
-rw-r--r--tests/pack/indexer.c2
-rw-r--r--tests/pack/packbuilder.c4
-rw-r--r--tests/patch/print.c2
-rw-r--r--tests/path/core.c427
-rw-r--r--tests/path/dotgit.c94
-rw-r--r--tests/path/win32.c16
-rw-r--r--tests/rebase/iterator.c2
-rw-r--r--tests/rebase/merge.c2
-rw-r--r--tests/rebase/sign.c2
-rw-r--r--tests/refs/branches/create.c2
-rw-r--r--tests/refs/branches/delete.c8
-rw-r--r--tests/refs/branches/name.c2
-rw-r--r--tests/refs/delete.c4
-rw-r--r--tests/refs/pack.c4
-rw-r--r--tests/refs/ref_helpers.c3
-rw-r--r--tests/refs/reflog/reflog.c18
-rw-r--r--tests/refs/reflog/reflog_helpers.c3
-rw-r--r--tests/refs/reflog/reflog_helpers.h8
-rw-r--r--tests/refs/rename.c12
-rw-r--r--tests/refs/revparse.c4
-rw-r--r--tests/refs/shorthand.c2
-rw-r--r--tests/refs/tags/name.c2
-rw-r--r--tests/remote/fetch.c2
-rw-r--r--tests/remote/httpproxy.c6
-rw-r--r--tests/repo/config.c22
-rw-r--r--tests/repo/discover.c6
-rw-r--r--tests/repo/env.c10
-rw-r--r--tests/repo/init.c26
-rw-r--r--tests/repo/open.c10
-rw-r--r--tests/repo/setters.c2
-rw-r--r--tests/repo/template.c16
-rw-r--r--tests/reset/hard.c12
-rw-r--r--tests/revert/workdir.c10
-rw-r--r--tests/stash/apply.c6
-rw-r--r--tests/stash/drop.c16
-rw-r--r--tests/stash/save.c20
-rw-r--r--tests/status/submodules.c12
-rw-r--r--tests/status/worktree.c12
-rw-r--r--tests/submodule/add.c16
-rw-r--r--tests/submodule/init.c6
-rw-r--r--tests/submodule/modify.c6
-rw-r--r--tests/submodule/open.c10
-rw-r--r--tests/submodule/repository_init.c8
-rw-r--r--tests/submodule/submodule_helpers.c2
-rw-r--r--tests/worktree/merge.c2
-rw-r--r--tests/worktree/refs.c4
-rw-r--r--tests/worktree/submodule.c2
-rw-r--r--tests/worktree/worktree.c14
123 files changed, 1807 insertions, 1086 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index b85cd6ed3..84df92a45 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -16,7 +16,7 @@ add_definitions(-D_FILE_OFFSET_BITS=64)
# Ensure that we do not use deprecated functions internally
add_definitions(-DGIT_DEPRECATE_HARD)
-include_directories(${CLAR_PATH} ${libgit2_BINARY_DIR}/src)
+set(TEST_INCLUDES "${CLAR_PATH}" "${CMAKE_CURRENT_BINARY_DIR}")
file(GLOB_RECURSE SRC_TEST ${CLAR_PATH}/*/*.c ${CLAR_PATH}/*/*.h)
set(SRC_CLAR "main.c" "clar_libgit2.c" "clar_libgit2_trace.c" "clar_libgit2_timer.c" "clar.c")
@@ -25,29 +25,35 @@ if(MSVC_IDE)
endif()
add_custom_command(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite ${CMAKE_CURRENT_BINARY_DIR}/clar_suite.h
COMMAND ${PYTHON_EXECUTABLE} generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f -xonline -xstress -xperf .
DEPENDS ${SRC_TEST}
WORKING_DIRECTORY ${CLAR_PATH}
)
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
set_source_files_properties(
${CLAR_PATH}/clar.c
PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clar.suite)
-include_directories(${LIBGIT2_INCLUDES})
-include_directories(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
-
add_executable(libgit2_tests ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS})
set_target_properties(libgit2_tests PROPERTIES C_STANDARD 90)
set_target_properties(libgit2_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
-target_include_directories(libgit2_tests PRIVATE ../src PUBLIC ../include)
-target_link_libraries(libgit2_tests ${LIBGIT2_LIBS})
+target_include_directories(libgit2_tests PRIVATE ${TEST_INCLUDES} ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES})
+target_include_directories(libgit2_tests SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
+target_link_libraries(libgit2_tests ${LIBGIT2_SYSTEM_LIBS})
+
ide_split_sources(libgit2_tests)
+#
+# Old versions of gcc require us to declare our test functions; don't do
+# this on newer compilers to avoid unnecessary recompilation.
+#
+if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
+ target_compile_options(libgit2_tests PRIVATE -include "clar_suite.h")
+endif()
+
if(MSVC_IDE)
# Precompiled headers
set_target_properties(libgit2_tests PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
@@ -71,3 +77,20 @@ add_clar_test(ssh -v -sonline::push -sonline::clone::ssh_cert -s
add_clar_test(proxy -v -sonline::clone::proxy)
add_clar_test(auth_clone -v -sonline::clone::cred)
add_clar_test(auth_clone_and_push -v -sonline::clone::push -sonline::push)
+
+#
+# Header file validation project: ensure that we do not publish any sloppy
+# definitions in our headers and that a consumer can include <git2.dll>
+# even when they have aggressive C90 warnings enabled.
+#
+
+add_executable(headertest headertest.c)
+set_target_properties(headertest PROPERTIES C_STANDARD 90)
+set_target_properties(headertest PROPERTIES C_EXTENSIONS OFF)
+target_include_directories(headertest PRIVATE ${LIBGIT2_INCLUDES})
+
+if (MSVC)
+ target_compile_options(headertest PUBLIC /W4 /WX)
+else()
+ target_compile_options(headertest PUBLIC -Wall -Wextra -pedantic -Werror)
+endif()
diff --git a/tests/README.md b/tests/README.md
index 7684a6e64..4369a8f33 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -15,7 +15,7 @@ https://github.com/vmg/clar
* Test:
- ./build/libgit2_clar
+ ./build/libgit2_tests
* Make sure everything is fine.
@@ -34,8 +34,8 @@ Uses [`valgrind`](http://www.valgrind.org/):
```console
$ cmake -DBUILD_TESTS=ON -DVALGRIND=ON ..
$ cmake --build .
-$ valgrind --leak-check=full --show-reachable=yes --num-callers=50 --suppressions=../libgit2_clar.supp \
- ./libgit2_clar
+$ valgrind --leak-check=full --show-reachable=yes --num-callers=50 --suppressions=../libgit2_tests.supp \
+ ./libgit2_tests
```
#### macOS
@@ -44,5 +44,5 @@ Uses [`leaks`](https://developer.apple.com/library/archive/documentation/Perform
```console
$ MallocStackLogging=1 MallocScribble=1 MallocLogFile=/dev/null CLAR_AT_EXIT="leaks -quiet \$PPID" \
- ./libgit2_clar
+ ./libgit2_tests
```
diff --git a/tests/attr/repo.c b/tests/attr/repo.c
index e7b975290..abd238154 100644
--- a/tests/attr/repo.c
+++ b/tests/attr/repo.c
@@ -283,7 +283,7 @@ void test_attr_repo__bare_repo_with_index(void)
git_index_free(index);
cl_must_pass(p_unlink("attr/.gitattributes"));
- cl_assert(!git_path_exists("attr/.gitattributes"));
+ cl_assert(!git_fs_path_exists("attr/.gitattributes"));
cl_git_pass(git_repository_set_bare(g_repo));
diff --git a/tests/checkout/conflict.c b/tests/checkout/conflict.c
index 3f5e7162d..4a9e4b9fa 100644
--- a/tests/checkout/conflict.c
+++ b/tests/checkout/conflict.c
@@ -227,7 +227,7 @@ void test_checkout_conflict__ignored(void)
cl_git_pass(git_checkout_index(g_repo, g_index, &opts));
- cl_assert(!git_path_exists(TEST_REPO_PATH "/conflicting.txt"));
+ cl_assert(!git_fs_path_exists(TEST_REPO_PATH "/conflicting.txt"));
}
void test_checkout_conflict__ours(void)
@@ -1030,15 +1030,15 @@ void test_checkout_conflict__update_only(void)
ensure_workdir_contents("automergeable.txt", AUTOMERGEABLE_MERGED_FILE);
ensure_workdir("directory_file-two/file", 0100644, CONFLICTING_OURS_OID);
- cl_assert(!git_path_exists("merge-resolve/modify-delete"));
- cl_assert(!git_path_exists("merge-resolve/test-one.txt"));
- cl_assert(!git_path_exists("merge-resolve/test-one-side-one.txt"));
- cl_assert(!git_path_exists("merge-resolve/test-one-side-two.txt"));
- cl_assert(!git_path_exists("merge-resolve/test-one.txt~ours"));
- cl_assert(!git_path_exists("merge-resolve/test-one.txt~theirs"));
- cl_assert(!git_path_exists("merge-resolve/directory_file-one/file"));
- cl_assert(!git_path_exists("merge-resolve/directory_file-one~ours"));
- cl_assert(!git_path_exists("merge-resolve/directory_file-two~theirs"));
+ cl_assert(!git_fs_path_exists("merge-resolve/modify-delete"));
+ cl_assert(!git_fs_path_exists("merge-resolve/test-one.txt"));
+ cl_assert(!git_fs_path_exists("merge-resolve/test-one-side-one.txt"));
+ cl_assert(!git_fs_path_exists("merge-resolve/test-one-side-two.txt"));
+ cl_assert(!git_fs_path_exists("merge-resolve/test-one.txt~ours"));
+ cl_assert(!git_fs_path_exists("merge-resolve/test-one.txt~theirs"));
+ cl_assert(!git_fs_path_exists("merge-resolve/directory_file-one/file"));
+ cl_assert(!git_fs_path_exists("merge-resolve/directory_file-one~ours"));
+ cl_assert(!git_fs_path_exists("merge-resolve/directory_file-two~theirs"));
}
void test_checkout_conflict__path_filters(void)
@@ -1076,9 +1076,9 @@ void test_checkout_conflict__path_filters(void)
cl_git_pass(git_checkout_index(g_repo, g_index, &opts));
ensure_workdir_contents("conflicting-1.txt", CONFLICTING_DIFF3_FILE);
- cl_assert(!git_path_exists("merge-resolve/conflicting-2.txt"));
+ cl_assert(!git_fs_path_exists("merge-resolve/conflicting-2.txt"));
ensure_workdir_contents("conflicting-3.txt", AUTOMERGEABLE_MERGED_FILE);
- cl_assert(!git_path_exists("merge-resolve/conflicting-4.txt"));
+ cl_assert(!git_fs_path_exists("merge-resolve/conflicting-4.txt"));
}
static void collect_progress(
diff --git a/tests/checkout/crlf.c b/tests/checkout/crlf.c
index eb4c61f39..8fd16a004 100644
--- a/tests/checkout/crlf.c
+++ b/tests/checkout/crlf.c
@@ -17,7 +17,7 @@ static int unlink_file(void *payload, git_str *path)
{
char *fn;
- cl_assert(fn = git_path_basename(path->ptr));
+ cl_assert(fn = git_fs_path_basename(path->ptr));
GIT_UNUSED(payload);
@@ -39,7 +39,7 @@ void test_checkout_crlf__initialize(void)
* check out over it.
*/
cl_git_pass(git_str_puts(&reponame, "crlf"));
- cl_git_pass(git_path_direach(&reponame, 0, unlink_file, NULL));
+ cl_git_pass(git_fs_path_direach(&reponame, 0, unlink_file, NULL));
if (GIT_EOL_NATIVE == GIT_EOL_CRLF)
systype = "windows";
@@ -76,7 +76,7 @@ static int compare_file(void *payload, git_str *actual_path)
int cmp_git, cmp_gitattributes;
char *basename;
- basename = git_path_basename(actual_path->ptr);
+ basename = git_fs_path_basename(actual_path->ptr);
cmp_git = strcmp(basename, ".git");
cmp_gitattributes = strcmp(basename, ".gitattributes");
@@ -87,8 +87,8 @@ static int compare_file(void *payload, git_str *actual_path)
cl_git_pass(git_str_joinpath(&expected_path, cd->dirname, basename));
- if (!git_path_isfile(expected_path.ptr) ||
- !git_path_isfile(actual_path->ptr))
+ if (!git_fs_path_isfile(expected_path.ptr) ||
+ !git_fs_path_isfile(actual_path->ptr))
goto done;
if (git_futils_readbuffer(&actual_contents, actual_path->ptr) < 0 ||
@@ -107,7 +107,7 @@ done:
if (failed) {
git_str details = GIT_STR_INIT;
git_str_printf(&details, "filename=%s, system=%s, autocrlf=%s, attrs={%s}",
- git_path_basename(actual_path->ptr), systype, cd->autocrlf, cd->attrs);
+ git_fs_path_basename(actual_path->ptr), systype, cd->autocrlf, cd->attrs);
clar__fail(__FILE__, __func__, __LINE__,
"checked out contents did not match expected", details.ptr, 0);
git_str_dispose(&details);
@@ -166,7 +166,7 @@ static void test_checkout(const char *autocrlf, const char *attrs)
cl_git_pass(git_checkout_head(g_repo, &opts));
compare_data.dirname = sandboxname.ptr;
- cl_git_pass(git_path_direach(&reponame, 0, compare_file, &compare_data));
+ cl_git_pass(git_fs_path_direach(&reponame, 0, compare_file, &compare_data));
cl_fixture_cleanup(expected_fixture.ptr);
git_str_dispose(&expected_fixture);
@@ -187,9 +187,9 @@ static void empty_workdir(const char *name)
size_t i;
const char *fn;
- cl_git_pass(git_path_dirload(&contents, name, 0, 0));
+ cl_git_pass(git_fs_path_dirload(&contents, name, 0, 0));
git_vector_foreach(&contents, i, fn) {
- cl_assert(basename = git_path_basename(fn));
+ cl_assert(basename = git_fs_path_basename(fn));
cmp = strncasecmp(basename, ".git", 4);
git__free(basename);
diff --git a/tests/checkout/head.c b/tests/checkout/head.c
index 5b3a034e7..3b0bf4729 100644
--- a/tests/checkout/head.c
+++ b/tests/checkout/head.c
@@ -43,7 +43,7 @@ void test_checkout_head__with_index_only_tree(void)
cl_git_pass(git_index_add_bypath(index, "newdir/newfile.txt"));
cl_git_pass(git_index_write(index));
- cl_assert(git_path_isfile("testrepo/newdir/newfile.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/newdir/newfile.txt"));
cl_assert(git_index_get_bypath(index, "newdir/newfile.txt", 0) != NULL);
git_index_free(index);
@@ -55,7 +55,7 @@ void test_checkout_head__with_index_only_tree(void)
cl_git_pass(git_repository_index(&index, g_repo));
- cl_assert(!git_path_isfile("testrepo/newdir/newfile.txt"));
+ cl_assert(!git_fs_path_isfile("testrepo/newdir/newfile.txt"));
cl_assert(git_index_get_bypath(index, "newdir/newfile.txt", 0) == NULL);
git_index_free(index);
@@ -79,8 +79,8 @@ void test_checkout_head__do_not_remove_untracked_file(void)
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
cl_git_pass(git_checkout_head(g_repo, &opts));
- cl_assert(!git_path_isfile("testrepo/tracked/tracked"));
- cl_assert(git_path_isfile("testrepo/tracked/untracked"));
+ cl_assert(!git_fs_path_isfile("testrepo/tracked/tracked"));
+ cl_assert(git_fs_path_isfile("testrepo/tracked/untracked"));
}
void test_checkout_head__do_not_remove_untracked_file_in_subdir(void)
@@ -104,9 +104,9 @@ void test_checkout_head__do_not_remove_untracked_file_in_subdir(void)
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
cl_git_pass(git_checkout_head(g_repo, &opts));
- cl_assert(!git_path_isfile("testrepo/tracked/tracked"));
- cl_assert(!git_path_isfile("testrepo/tracked/subdir/tracked"));
- cl_assert(git_path_isfile("testrepo/tracked/subdir/untracked"));
+ cl_assert(!git_fs_path_isfile("testrepo/tracked/tracked"));
+ cl_assert(!git_fs_path_isfile("testrepo/tracked/subdir/tracked"));
+ cl_assert(git_fs_path_isfile("testrepo/tracked/subdir/untracked"));
}
void test_checkout_head__do_remove_untracked_paths(void)
@@ -131,8 +131,8 @@ void test_checkout_head__do_remove_untracked_paths(void)
opts.paths.count = 1;
cl_git_pass(git_checkout_head(g_repo, &opts));
- cl_assert(git_path_isfile("testrepo/tracked/tracked"));
- cl_assert(!git_path_isfile("testrepo/tracked/untracked"));
+ cl_assert(git_fs_path_isfile("testrepo/tracked/tracked"));
+ cl_assert(!git_fs_path_isfile("testrepo/tracked/untracked"));
}
void test_checkout_head__do_remove_tracked_subdir(void)
@@ -158,9 +158,9 @@ void test_checkout_head__do_remove_tracked_subdir(void)
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
cl_git_pass(git_checkout_head(g_repo, &opts));
- cl_assert(!git_path_isdir("testrepo/subdir/tracked"));
- cl_assert(!git_path_isfile("testrepo/subdir/tracked-file"));
- cl_assert(git_path_isfile("testrepo/subdir/untracked-file"));
+ cl_assert(!git_fs_path_isdir("testrepo/subdir/tracked"));
+ cl_assert(!git_fs_path_isfile("testrepo/subdir/tracked-file"));
+ cl_assert(git_fs_path_isfile("testrepo/subdir/untracked-file"));
}
void test_checkout_head__typechange_workdir(void)
diff --git a/tests/checkout/icase.c b/tests/checkout/icase.c
index 6c30765a3..d77c7abd5 100644
--- a/tests/checkout/icase.c
+++ b/tests/checkout/icase.c
@@ -50,8 +50,8 @@ static char *get_filename(const char *in)
DIR *dir;
struct dirent *de;
- cl_assert(search_dirname = git_path_dirname(in));
- cl_assert(search_filename = git_path_basename(in));
+ cl_assert(search_dirname = git_fs_path_dirname(in));
+ cl_assert(search_filename = git_fs_path_basename(in));
cl_assert(dir = opendir(search_dirname));
@@ -134,7 +134,7 @@ void test_checkout_icase__refuses_to_overwrite_links_for_files(void)
cl_git_fail(git_checkout_tree(repo, obj, &checkout_opts));
- cl_assert(!git_path_exists("tmp"));
+ cl_assert(!git_fs_path_exists("tmp"));
assert_name_is("testrepo/BRANCH_FILE.txt");
}
@@ -146,7 +146,7 @@ void test_checkout_icase__overwrites_links_for_files_when_forced(void)
cl_git_pass(git_checkout_tree(repo, obj, &checkout_opts));
- cl_assert(!git_path_exists("tmp"));
+ cl_assert(!git_fs_path_exists("tmp"));
assert_name_is("testrepo/new.txt");
}
@@ -159,7 +159,7 @@ void test_checkout_icase__overwrites_empty_folders_for_files(void)
cl_git_pass(git_checkout_tree(repo, obj, &checkout_opts));
assert_name_is("testrepo/new.txt");
- cl_assert(!git_path_isdir("testrepo/new.txt"));
+ cl_assert(!git_fs_path_isdir("testrepo/new.txt"));
}
void test_checkout_icase__refuses_to_overwrite_populated_folders_for_files(void)
@@ -173,7 +173,7 @@ void test_checkout_icase__refuses_to_overwrite_populated_folders_for_files(void)
cl_git_fail(git_checkout_tree(repo, obj, &checkout_opts));
assert_name_is("testrepo/BRANCH_FILE.txt");
- cl_assert(git_path_isdir("testrepo/BRANCH_FILE.txt"));
+ cl_assert(git_fs_path_isdir("testrepo/BRANCH_FILE.txt"));
}
void test_checkout_icase__overwrites_folders_for_files_when_forced(void)
@@ -187,7 +187,7 @@ void test_checkout_icase__overwrites_folders_for_files_when_forced(void)
cl_git_pass(git_checkout_tree(repo, obj, &checkout_opts));
assert_name_is("testrepo/new.txt");
- cl_assert(!git_path_isdir("testrepo/new.txt"));
+ cl_assert(!git_fs_path_isdir("testrepo/new.txt"));
}
void test_checkout_icase__refuses_to_overwrite_files_for_folders(void)
@@ -199,7 +199,7 @@ void test_checkout_icase__refuses_to_overwrite_files_for_folders(void)
cl_git_fail(git_checkout_tree(repo, obj, &checkout_opts));
assert_name_is("testrepo/A");
- cl_assert(!git_path_isdir("testrepo/A"));
+ cl_assert(!git_fs_path_isdir("testrepo/A"));
}
void test_checkout_icase__overwrites_files_for_folders_when_forced(void)
@@ -211,7 +211,7 @@ void test_checkout_icase__overwrites_files_for_folders_when_forced(void)
cl_git_pass(git_checkout_tree(repo, obj, &checkout_opts));
assert_name_is("testrepo/a");
- cl_assert(git_path_isdir("testrepo/a"));
+ cl_assert(git_fs_path_isdir("testrepo/a"));
}
void test_checkout_icase__refuses_to_overwrite_links_for_folders(void)
@@ -222,7 +222,7 @@ void test_checkout_icase__refuses_to_overwrite_links_for_folders(void)
cl_git_fail(git_checkout_tree(repo, obj, &checkout_opts));
- cl_assert(!git_path_exists("b.txt"));
+ cl_assert(!git_fs_path_exists("b.txt"));
assert_name_is("testrepo/A");
}
@@ -234,7 +234,7 @@ void test_checkout_icase__overwrites_links_for_folders_when_forced(void)
cl_git_pass(git_checkout_tree(repo, obj, &checkout_opts));
- cl_assert(!git_path_exists("b.txt"));
+ cl_assert(!git_fs_path_exists("b.txt"));
assert_name_is("testrepo/a");
}
diff --git a/tests/checkout/index.c b/tests/checkout/index.c
index 13eecc984..6a80d22c5 100644
--- a/tests/checkout/index.c
+++ b/tests/checkout/index.c
@@ -56,9 +56,9 @@ void test_checkout_index__can_create_missing_files(void)
{
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
- cl_assert_equal_i(false, git_path_isfile("./testrepo/README"));
- cl_assert_equal_i(false, git_path_isfile("./testrepo/branch_file.txt"));
- cl_assert_equal_i(false, git_path_isfile("./testrepo/new.txt"));
+ cl_assert_equal_i(false, git_fs_path_isfile("./testrepo/README"));
+ cl_assert_equal_i(false, git_fs_path_isfile("./testrepo/branch_file.txt"));
+ cl_assert_equal_i(false, git_fs_path_isfile("./testrepo/new.txt"));
opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_RECREATE_MISSING;
@@ -77,7 +77,7 @@ void test_checkout_index__can_remove_untracked_files(void)
cl_git_mkfile("./testrepo/dir/one", "one\n");
cl_git_mkfile("./testrepo/dir/subdir/two", "two\n");
- cl_assert_equal_i(true, git_path_isdir("./testrepo/dir/subdir/subsubdir"));
+ cl_assert_equal_i(true, git_fs_path_isdir("./testrepo/dir/subdir/subsubdir"));
opts.checkout_strategy =
GIT_CHECKOUT_SAFE |
@@ -86,7 +86,7 @@ void test_checkout_index__can_remove_untracked_files(void)
cl_git_pass(git_checkout_index(g_repo, NULL, &opts));
- cl_assert_equal_i(false, git_path_isdir("./testrepo/dir"));
+ cl_assert_equal_i(false, git_fs_path_isdir("./testrepo/dir"));
}
void test_checkout_index__can_disable_pathspec_match(void)
@@ -152,15 +152,15 @@ void test_checkout_index__honor_the_specified_pathspecs(void)
opts.paths.strings = entries;
opts.paths.count = 1;
- cl_assert_equal_i(false, git_path_isfile("./testrepo/README"));
- cl_assert_equal_i(false, git_path_isfile("./testrepo/branch_file.txt"));
- cl_assert_equal_i(false, git_path_isfile("./testrepo/new.txt"));
+ cl_assert_equal_i(false, git_fs_path_isfile("./testrepo/README"));
+ cl_assert_equal_i(false, git_fs_path_isfile("./testrepo/branch_file.txt"));
+ cl_assert_equal_i(false, git_fs_path_isfile("./testrepo/new.txt"));
opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_RECREATE_MISSING;
cl_git_pass(git_checkout_index(g_repo, NULL, &opts));
- cl_assert_equal_i(false, git_path_isfile("./testrepo/README"));
+ cl_assert_equal_i(false, git_fs_path_isfile("./testrepo/README"));
check_file_contents("./testrepo/branch_file.txt", "hi\nbye!\n");
check_file_contents("./testrepo/new.txt", "my new file\n");
}
@@ -236,7 +236,7 @@ void test_checkout_index__honor_coresymlinks_default_true(void)
cl_must_pass(p_mkdir("symlink", 0777));
- if (!git_path_supports_symlinks("symlink/test"))
+ if (!git_fs_path_supports_symlinks("symlink/test"))
cl_skip();
#ifdef GIT_WIN32
@@ -269,7 +269,7 @@ void test_checkout_index__honor_coresymlinks_default_false(void)
* supports symlinks. Bail entirely on POSIX platforms that
* do support symlinks.
*/
- if (git_path_supports_symlinks("symlink/test"))
+ if (git_fs_path_supports_symlinks("symlink/test"))
cl_skip();
#endif
@@ -281,7 +281,7 @@ void test_checkout_index__coresymlinks_set_to_true_fails_when_unsupported(void)
{
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
- if (git_path_supports_symlinks("testrepo/test")) {
+ if (git_fs_path_supports_symlinks("testrepo/test")) {
cl_skip();
}
@@ -297,7 +297,7 @@ void test_checkout_index__honor_coresymlinks_setting_set_to_true(void)
char link_data[GIT_PATH_MAX];
size_t link_size = GIT_PATH_MAX;
- if (!git_path_supports_symlinks("testrepo/test")) {
+ if (!git_fs_path_supports_symlinks("testrepo/test")) {
cl_skip();
}
@@ -578,8 +578,8 @@ void test_checkout_index__can_overcome_name_clashes(void)
cl_git_pass(p_mkdir("./testrepo/path0", 0777));
cl_git_mkfile("./testrepo/path0/file0", "content\r\n");
- cl_assert(git_path_isfile("./testrepo/path1"));
- cl_assert(git_path_isfile("./testrepo/path0/file0"));
+ cl_assert(git_fs_path_isfile("./testrepo/path1"));
+ cl_assert(git_fs_path_isfile("./testrepo/path0/file0"));
opts.checkout_strategy =
GIT_CHECKOUT_SAFE |
@@ -587,14 +587,14 @@ void test_checkout_index__can_overcome_name_clashes(void)
GIT_CHECKOUT_ALLOW_CONFLICTS;
cl_git_pass(git_checkout_index(g_repo, index, &opts));
- cl_assert(git_path_isfile("./testrepo/path1"));
- cl_assert(git_path_isfile("./testrepo/path0/file0"));
+ cl_assert(git_fs_path_isfile("./testrepo/path1"));
+ cl_assert(git_fs_path_isfile("./testrepo/path0/file0"));
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
cl_git_pass(git_checkout_index(g_repo, index, &opts));
- cl_assert(git_path_isfile("./testrepo/path0"));
- cl_assert(git_path_isfile("./testrepo/path1/file1"));
+ cl_assert(git_fs_path_isfile("./testrepo/path0"));
+ cl_assert(git_fs_path_isfile("./testrepo/path1/file1"));
git_index_free(index);
}
@@ -622,9 +622,9 @@ void test_checkout_index__can_update_prefixed_files(void)
{
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
- cl_assert_equal_i(false, git_path_isfile("./testrepo/README"));
- cl_assert_equal_i(false, git_path_isfile("./testrepo/branch_file.txt"));
- cl_assert_equal_i(false, git_path_isfile("./testrepo/new.txt"));
+ cl_assert_equal_i(false, git_fs_path_isfile("./testrepo/README"));
+ cl_assert_equal_i(false, git_fs_path_isfile("./testrepo/branch_file.txt"));
+ cl_assert_equal_i(false, git_fs_path_isfile("./testrepo/new.txt"));
cl_git_mkfile("./testrepo/READ", "content\n");
cl_git_mkfile("./testrepo/README.after", "content\n");
@@ -647,10 +647,10 @@ void test_checkout_index__can_update_prefixed_files(void)
check_file_contents_nocr("./testrepo/branch_file.txt", "hi\nbye!\n");
check_file_contents_nocr("./testrepo/new.txt", "my new file\n");
- cl_assert(!git_path_exists("testrepo/READ"));
- cl_assert(!git_path_exists("testrepo/README.after"));
- cl_assert(!git_path_exists("testrepo/branch_file"));
- cl_assert(!git_path_exists("testrepo/branch_file.txt.after"));
+ cl_assert(!git_fs_path_exists("testrepo/READ"));
+ cl_assert(!git_fs_path_exists("testrepo/README.after"));
+ cl_assert(!git_fs_path_exists("testrepo/branch_file"));
+ cl_assert(!git_fs_path_exists("testrepo/branch_file.txt.after"));
}
void test_checkout_index__can_checkout_a_newly_initialized_repository(void)
@@ -688,7 +688,7 @@ void test_checkout_index__target_directory(void)
opts.checkout_strategy = GIT_CHECKOUT_SAFE |
GIT_CHECKOUT_RECREATE_MISSING;
opts.target_directory = "alternative";
- cl_assert(!git_path_isdir("alternative"));
+ cl_assert(!git_fs_path_isdir("alternative"));
opts.notify_flags = GIT_CHECKOUT_NOTIFY_ALL;
opts.notify_cb = checkout_count_callback;
@@ -741,7 +741,7 @@ void test_checkout_index__target_directory_from_bare(void)
cl_git_fail(git_checkout_index(g_repo, NULL, &opts));
opts.target_directory = "alternative";
- cl_assert(!git_path_isdir("alternative"));
+ cl_assert(!git_fs_path_isdir("alternative"));
cl_git_pass(git_checkout_index(g_repo, NULL, &opts));
@@ -765,9 +765,9 @@ void test_checkout_index__can_get_repo_from_index(void)
git_index *index;
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
- cl_assert_equal_i(false, git_path_isfile("./testrepo/README"));
- cl_assert_equal_i(false, git_path_isfile("./testrepo/branch_file.txt"));
- cl_assert_equal_i(false, git_path_isfile("./testrepo/new.txt"));
+ cl_assert_equal_i(false, git_fs_path_isfile("./testrepo/README"));
+ cl_assert_equal_i(false, git_fs_path_isfile("./testrepo/branch_file.txt"));
+ cl_assert_equal_i(false, git_fs_path_isfile("./testrepo/new.txt"));
opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_RECREATE_MISSING;
diff --git a/tests/checkout/nasty.c b/tests/checkout/nasty.c
index a1b3164be..732f1d5e8 100644
--- a/tests/checkout/nasty.c
+++ b/tests/checkout/nasty.c
@@ -38,7 +38,7 @@ static void test_checkout_passes(const char *refname, const char *filename)
GIT_CHECKOUT_DONT_UPDATE_INDEX;
cl_git_pass(git_checkout_tree(repo, (const git_object *)commit, &opts));
- cl_assert(!git_path_exists(path.ptr));
+ cl_assert(!git_fs_path_exists(path.ptr));
git_commit_free(commit);
git_str_dispose(&path);
@@ -59,7 +59,7 @@ static void test_checkout_fails(const char *refname, const char *filename)
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
cl_git_fail(git_checkout_tree(repo, (const git_object *)commit, &opts));
- cl_assert(!git_path_exists(path.ptr));
+ cl_assert(!git_fs_path_exists(path.ptr));
git_commit_free(commit);
git_str_dispose(&path);
@@ -246,7 +246,7 @@ void test_checkout_nasty__only_looks_like_a_git_shortname(void)
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
cl_git_pass(git_checkout_tree(repo, (const git_object *)commit, &opts));
- cl_assert(git_path_exists("nasty/git~3/foobar"));
+ cl_assert(git_fs_path_exists("nasty/git~3/foobar"));
git_commit_free(commit);
#endif
diff --git a/tests/checkout/tree.c b/tests/checkout/tree.c
index cdfb456b7..de7dd7d9a 100644
--- a/tests/checkout/tree.c
+++ b/tests/checkout/tree.c
@@ -34,7 +34,7 @@ void test_checkout_tree__cleanup(void)
cl_git_sandbox_cleanup();
- if (git_path_isdir("alternative"))
+ if (git_fs_path_isdir("alternative"))
git_futils_rmdir_r("alternative", NULL, GIT_RMDIR_REMOVE_FILES);
}
@@ -54,17 +54,17 @@ void test_checkout_tree__can_checkout_a_subdirectory_from_a_commit(void)
cl_git_pass(git_revparse_single(&g_object, g_repo, "subtrees"));
- cl_assert_equal_i(false, git_path_isdir("./testrepo/ab/"));
+ cl_assert_equal_i(false, git_fs_path_isdir("./testrepo/ab/"));
cl_git_pass(git_checkout_tree(g_repo, g_object, &g_opts));
- cl_assert_equal_i(true, git_path_isfile("./testrepo/ab/de/2.txt"));
- cl_assert_equal_i(true, git_path_isfile("./testrepo/ab/de/fgh/1.txt"));
+ cl_assert_equal_i(true, git_fs_path_isfile("./testrepo/ab/de/2.txt"));
+ cl_assert_equal_i(true, git_fs_path_isfile("./testrepo/ab/de/fgh/1.txt"));
}
void test_checkout_tree__can_checkout_and_remove_directory(void)
{
- cl_assert_equal_i(false, git_path_isdir("./testrepo/ab/"));
+ cl_assert_equal_i(false, git_fs_path_isdir("./testrepo/ab/"));
/* Checkout brach "subtrees" and update HEAD, so that HEAD matches the
* current working tree
@@ -74,9 +74,9 @@ void test_checkout_tree__can_checkout_and_remove_directory(void)
cl_git_pass(git_repository_set_head(g_repo, "refs/heads/subtrees"));
- cl_assert_equal_i(true, git_path_isdir("./testrepo/ab/"));
- cl_assert_equal_i(true, git_path_isfile("./testrepo/ab/de/2.txt"));
- cl_assert_equal_i(true, git_path_isfile("./testrepo/ab/de/fgh/1.txt"));
+ cl_assert_equal_i(true, git_fs_path_isdir("./testrepo/ab/"));
+ cl_assert_equal_i(true, git_fs_path_isfile("./testrepo/ab/de/2.txt"));
+ cl_assert_equal_i(true, git_fs_path_isfile("./testrepo/ab/de/fgh/1.txt"));
git_object_free(g_object);
g_object = NULL;
@@ -90,7 +90,7 @@ void test_checkout_tree__can_checkout_and_remove_directory(void)
cl_git_pass(git_repository_set_head(g_repo, "refs/heads/master"));
/* This directory should no longer exist */
- cl_assert_equal_i(false, git_path_isdir("./testrepo/ab/"));
+ cl_assert_equal_i(false, git_fs_path_isdir("./testrepo/ab/"));
}
void test_checkout_tree__can_checkout_a_subdirectory_from_a_subtree(void)
@@ -102,12 +102,12 @@ void test_checkout_tree__can_checkout_a_subdirectory_from_a_subtree(void)
cl_git_pass(git_revparse_single(&g_object, g_repo, "subtrees:ab"));
- cl_assert_equal_i(false, git_path_isdir("./testrepo/de/"));
+ cl_assert_equal_i(false, git_fs_path_isdir("./testrepo/de/"));
cl_git_pass(git_checkout_tree(g_repo, g_object, &g_opts));
- cl_assert_equal_i(true, git_path_isfile("./testrepo/de/2.txt"));
- cl_assert_equal_i(true, git_path_isfile("./testrepo/de/fgh/1.txt"));
+ cl_assert_equal_i(true, git_fs_path_isfile("./testrepo/de/2.txt"));
+ cl_assert_equal_i(true, git_fs_path_isfile("./testrepo/de/fgh/1.txt"));
}
static void progress(const char *path, size_t cur, size_t tot, void *payload)
@@ -149,7 +149,7 @@ void test_checkout_tree__doesnt_write_unrequested_files_to_worktree(void)
*/
opts.checkout_strategy = GIT_CHECKOUT_NONE;
git_checkout_tree(g_repo, (git_object*)p_chomped_commit, &opts);
- cl_assert_equal_i(false, git_path_isfile("testrepo/readme.txt"));
+ cl_assert_equal_i(false, git_fs_path_isfile("testrepo/readme.txt"));
git_commit_free(p_master_commit);
git_commit_free(p_chomped_commit);
@@ -174,12 +174,12 @@ void test_checkout_tree__can_switch_branches(void)
cl_git_pass(git_checkout_tree(g_repo, obj, &opts));
cl_git_pass(git_repository_set_head(g_repo, "refs/heads/dir"));
- cl_assert(git_path_isfile("testrepo/README"));
- cl_assert(git_path_isfile("testrepo/branch_file.txt"));
- cl_assert(git_path_isfile("testrepo/new.txt"));
- cl_assert(git_path_isfile("testrepo/a/b.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/README"));
+ cl_assert(git_fs_path_isfile("testrepo/branch_file.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/new.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/a/b.txt"));
- cl_assert(!git_path_isdir("testrepo/ab"));
+ cl_assert(!git_fs_path_isdir("testrepo/ab"));
assert_on_branch(g_repo, "dir");
@@ -194,15 +194,15 @@ void test_checkout_tree__can_switch_branches(void)
cl_git_pass(git_checkout_tree(g_repo, obj, &opts));
cl_git_pass(git_repository_set_head(g_repo, "refs/heads/subtrees"));
- cl_assert(git_path_isfile("testrepo/README"));
- cl_assert(git_path_isfile("testrepo/branch_file.txt"));
- cl_assert(git_path_isfile("testrepo/new.txt"));
- cl_assert(git_path_isfile("testrepo/ab/4.txt"));
- cl_assert(git_path_isfile("testrepo/ab/c/3.txt"));
- cl_assert(git_path_isfile("testrepo/ab/de/2.txt"));
- cl_assert(git_path_isfile("testrepo/ab/de/fgh/1.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/README"));
+ cl_assert(git_fs_path_isfile("testrepo/branch_file.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/new.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/ab/4.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/ab/c/3.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/ab/de/2.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/ab/de/fgh/1.txt"));
- cl_assert(!git_path_isdir("testrepo/a"));
+ cl_assert(!git_fs_path_isdir("testrepo/a"));
assert_on_branch(g_repo, "subtrees");
@@ -216,11 +216,11 @@ void test_checkout_tree__can_remove_untracked(void)
opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_REMOVE_UNTRACKED;
cl_git_mkfile("testrepo/untracked_file", "as you wish");
- cl_assert(git_path_isfile("testrepo/untracked_file"));
+ cl_assert(git_fs_path_isfile("testrepo/untracked_file"));
cl_git_pass(git_checkout_head(g_repo, &opts));
- cl_assert(!git_path_isfile("testrepo/untracked_file"));
+ cl_assert(!git_fs_path_isfile("testrepo/untracked_file"));
}
void test_checkout_tree__can_remove_ignored(void)
@@ -237,11 +237,11 @@ void test_checkout_tree__can_remove_ignored(void)
cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "ignored_file"));
cl_assert_equal_i(1, ignored);
- cl_assert(git_path_isfile("testrepo/ignored_file"));
+ cl_assert(git_fs_path_isfile("testrepo/ignored_file"));
cl_git_pass(git_checkout_head(g_repo, &opts));
- cl_assert(!git_path_isfile("testrepo/ignored_file"));
+ cl_assert(!git_fs_path_isfile("testrepo/ignored_file"));
}
static int checkout_tree_with_blob_ignored_in_workdir(int strategy, bool isdir)
@@ -264,12 +264,12 @@ static int checkout_tree_with_blob_ignored_in_workdir(int strategy, bool isdir)
cl_git_pass(git_checkout_tree(g_repo, obj, &opts));
cl_git_pass(git_repository_set_head(g_repo, "refs/heads/dir"));
- cl_assert(git_path_isfile("testrepo/README"));
- cl_assert(git_path_isfile("testrepo/branch_file.txt"));
- cl_assert(git_path_isfile("testrepo/new.txt"));
- cl_assert(git_path_isfile("testrepo/a/b.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/README"));
+ cl_assert(git_fs_path_isfile("testrepo/branch_file.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/new.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/a/b.txt"));
- cl_assert(!git_path_isdir("testrepo/ab"));
+ cl_assert(!git_fs_path_isdir("testrepo/ab"));
assert_on_branch(g_repo, "dir");
@@ -285,12 +285,12 @@ static int checkout_tree_with_blob_ignored_in_workdir(int strategy, bool isdir)
cl_git_mkfile("testrepo/ab/4.txt/file2.txt", "foo bar foo");
cl_git_mkfile("testrepo/ab/4.txt/file3.txt", "inky blinky pinky clyde");
- cl_assert(git_path_isdir("testrepo/ab/4.txt"));
+ cl_assert(git_fs_path_isdir("testrepo/ab/4.txt"));
} else {
cl_must_pass(p_mkdir("testrepo/ab", 0777));
cl_git_mkfile("testrepo/ab/4.txt", "as you wish");
- cl_assert(git_path_isfile("testrepo/ab/4.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/ab/4.txt"));
}
cl_git_pass(git_ignore_add_rule(g_repo, "ab/4.txt\n"));
@@ -324,7 +324,7 @@ void test_checkout_tree__can_overwrite_ignored_by_default(void)
cl_git_pass(git_repository_set_head(g_repo, "refs/heads/subtrees"));
- cl_assert(git_path_isfile("testrepo/ab/4.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/ab/4.txt"));
assert_on_branch(g_repo, "subtrees");
}
@@ -345,7 +345,7 @@ void test_checkout_tree__can_overwrite_ignored_folder_by_default(void)
cl_git_pass(git_repository_set_head(g_repo, "refs/heads/subtrees"));
- cl_assert(git_path_isfile("testrepo/ab/4.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/ab/4.txt"));
assert_on_branch(g_repo, "subtrees");
@@ -364,7 +364,7 @@ void test_checkout_tree__can_update_only(void)
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
cl_git_pass(git_checkout_head(g_repo, &opts));
- cl_assert(!git_path_isdir("testrepo/a"));
+ cl_assert(!git_fs_path_isdir("testrepo/a"));
check_file_contents_nocr("testrepo/branch_file.txt", "hi\nbye!\n");
@@ -384,7 +384,7 @@ void test_checkout_tree__can_update_only(void)
* the test_checkout_tree__can_switch_branches test), but with
* UPDATE_ONLY it will not have been created.
*/
- cl_assert(!git_path_isdir("testrepo/a"));
+ cl_assert(!git_fs_path_isdir("testrepo/a"));
/* but this file still should have been updated */
check_file_contents_nocr("testrepo/branch_file.txt", "hi\n");
@@ -410,10 +410,10 @@ void test_checkout_tree__can_checkout_with_pattern(void)
git_object_free(g_object);
g_object = NULL;
- cl_assert(git_path_exists("testrepo/README"));
- cl_assert(!git_path_exists("testrepo/branch_file.txt"));
- cl_assert(!git_path_exists("testrepo/link_to_new.txt"));
- cl_assert(!git_path_exists("testrepo/new.txt"));
+ cl_assert(git_fs_path_exists("testrepo/README"));
+ cl_assert(!git_fs_path_exists("testrepo/branch_file.txt"));
+ cl_assert(!git_fs_path_exists("testrepo/link_to_new.txt"));
+ cl_assert(!git_fs_path_exists("testrepo/new.txt"));
/* now to a narrow patterned checkout */
@@ -425,10 +425,10 @@ void test_checkout_tree__can_checkout_with_pattern(void)
cl_git_pass(git_checkout_tree(g_repo, g_object, &g_opts));
- cl_assert(git_path_exists("testrepo/README"));
- cl_assert(!git_path_exists("testrepo/branch_file.txt"));
- cl_assert(git_path_exists("testrepo/link_to_new.txt"));
- cl_assert(git_path_exists("testrepo/new.txt"));
+ cl_assert(git_fs_path_exists("testrepo/README"));
+ cl_assert(!git_fs_path_exists("testrepo/branch_file.txt"));
+ cl_assert(git_fs_path_exists("testrepo/link_to_new.txt"));
+ cl_assert(git_fs_path_exists("testrepo/new.txt"));
}
void test_checkout_tree__pathlist_checkout_ignores_non_matches(void)
@@ -445,10 +445,10 @@ void test_checkout_tree__pathlist_checkout_ignores_non_matches(void)
cl_git_pass(git_checkout_tree(g_repo, g_object, &g_opts));
cl_git_pass(git_repository_set_head(g_repo, "refs/heads/master"));
- cl_assert(git_path_exists("testrepo/README"));
- cl_assert(git_path_exists("testrepo/branch_file.txt"));
- cl_assert(git_path_exists("testrepo/link_to_new.txt"));
- cl_assert(git_path_exists("testrepo/new.txt"));
+ cl_assert(git_fs_path_exists("testrepo/README"));
+ cl_assert(git_fs_path_exists("testrepo/branch_file.txt"));
+ cl_assert(git_fs_path_exists("testrepo/link_to_new.txt"));
+ cl_assert(git_fs_path_exists("testrepo/new.txt"));
git_object_free(g_object);
cl_git_pass(git_revparse_single(&g_object, g_repo, "8496071c1b46c854b31185ea97743be6a8774479"));
@@ -460,10 +460,10 @@ void test_checkout_tree__pathlist_checkout_ignores_non_matches(void)
cl_git_pass(git_checkout_tree(g_repo, g_object, &g_opts));
- cl_assert(git_path_exists("testrepo/README"));
- cl_assert(!git_path_exists("testrepo/branch_file.txt"));
- cl_assert(!git_path_exists("testrepo/link_to_new.txt"));
- cl_assert(git_path_exists("testrepo/new.txt"));
+ cl_assert(git_fs_path_exists("testrepo/README"));
+ cl_assert(!git_fs_path_exists("testrepo/branch_file.txt"));
+ cl_assert(!git_fs_path_exists("testrepo/link_to_new.txt"));
+ cl_assert(git_fs_path_exists("testrepo/new.txt"));
}
void test_checkout_tree__can_disable_pattern_match(void)
@@ -484,7 +484,7 @@ void test_checkout_tree__can_disable_pattern_match(void)
git_object_free(g_object);
g_object = NULL;
- cl_assert(!git_path_isfile("testrepo/branch_file.txt"));
+ cl_assert(!git_fs_path_isfile("testrepo/branch_file.txt"));
/* now to a narrow patterned checkout, but disable pattern */
@@ -498,7 +498,7 @@ void test_checkout_tree__can_disable_pattern_match(void)
cl_git_pass(git_checkout_tree(g_repo, g_object, &g_opts));
- cl_assert(!git_path_isfile("testrepo/branch_file.txt"));
+ cl_assert(!git_fs_path_isfile("testrepo/branch_file.txt"));
/* let's try that again, but allow the pattern match */
@@ -506,10 +506,10 @@ void test_checkout_tree__can_disable_pattern_match(void)
cl_git_pass(git_checkout_tree(g_repo, g_object, &g_opts));
- cl_assert(git_path_isfile("testrepo/branch_file.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/branch_file.txt"));
}
-void assert_conflict(
+static void assert_conflict(
const char *entry_path,
const char *new_content,
const char *parent_sha,
@@ -623,7 +623,7 @@ void test_checkout_tree__donot_update_deleted_file_by_default(void)
cl_git_pass(git_index_remove_bypath(index ,"branch_file.txt"));
cl_git_pass(git_index_write(index));
- cl_assert(!git_path_exists("testrepo/branch_file.txt"));
+ cl_assert(!git_fs_path_exists("testrepo/branch_file.txt"));
cl_git_pass(git_oid_fromstr(&new_id, "099fabac3a9ea935598528c27f866e34089c2eff"));
cl_git_pass(git_commit_lookup(&new_commit, g_repo, &new_id));
@@ -686,16 +686,16 @@ void test_checkout_tree__can_cancel_checkout_from_notify(void)
opts.notify_payload = &ca;
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
- cl_assert(!git_path_exists("testrepo/new.txt"));
+ cl_assert(!git_fs_path_exists("testrepo/new.txt"));
cl_git_fail_with(git_checkout_tree(g_repo, obj, &opts), -5555);
- cl_assert(!git_path_exists("testrepo/new.txt"));
+ cl_assert(!git_fs_path_exists("testrepo/new.txt"));
/* on case-insensitive FS = a/b.txt, branch_file.txt, new.txt */
/* on case-sensitive FS = README, then above */
- if (git_path_exists("testrepo/.git/CoNfIg")) /* case insensitive */
+ if (git_fs_path_exists("testrepo/.git/CoNfIg")) /* case insensitive */
cl_assert_equal_i(3, ca.count);
else
cl_assert_equal_i(4, ca.count);
@@ -707,9 +707,9 @@ void test_checkout_tree__can_cancel_checkout_from_notify(void)
cl_git_fail_with(git_checkout_tree(g_repo, obj, &opts), 123);
- cl_assert(!git_path_exists("testrepo/new.txt"));
+ cl_assert(!git_fs_path_exists("testrepo/new.txt"));
- if (git_path_exists("testrepo/.git/CoNfIg")) /* case insensitive */
+ if (git_fs_path_exists("testrepo/.git/CoNfIg")) /* case insensitive */
cl_assert_equal_i(4, ca.count);
else
cl_assert_equal_i(1, ca.count);
@@ -799,7 +799,7 @@ void test_checkout_tree__can_write_to_empty_dirs(void)
cl_git_pass(git_checkout_tree(g_repo, obj, &opts));
- cl_assert(git_path_isfile("testrepo/a/b.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/a/b.txt"));
git_object_free(obj);
}
@@ -818,7 +818,7 @@ void test_checkout_tree__fails_when_dir_in_use(void)
cl_git_pass(git_checkout_tree(g_repo, obj, &opts));
- cl_assert(git_path_isfile("testrepo/a/b.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/a/b.txt"));
git_object_free(obj);
@@ -831,7 +831,7 @@ void test_checkout_tree__fails_when_dir_in_use(void)
cl_git_pass(p_chdir("../.."));
- cl_assert(git_path_is_empty_dir("testrepo/a"));
+ cl_assert(git_fs_path_is_empty_dir("testrepo/a"));
git_object_free(obj);
#endif
@@ -852,7 +852,7 @@ void test_checkout_tree__can_continue_when_dir_in_use(void)
cl_git_pass(git_checkout_tree(g_repo, obj, &opts));
- cl_assert(git_path_isfile("testrepo/a/b.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/a/b.txt"));
git_object_free(obj);
@@ -865,7 +865,7 @@ void test_checkout_tree__can_continue_when_dir_in_use(void)
cl_git_pass(p_chdir("../.."));
- cl_assert(git_path_is_empty_dir("testrepo/a"));
+ cl_assert(git_fs_path_is_empty_dir("testrepo/a"));
git_object_free(obj);
#endif
@@ -896,7 +896,7 @@ void test_checkout_tree__target_directory_from_bare(void)
cl_git_fail(git_checkout_tree(g_repo, g_object, &opts));
opts.target_directory = "alternative";
- cl_assert(!git_path_isdir("alternative"));
+ cl_assert(!git_fs_path_isdir("alternative"));
cl_git_pass(git_checkout_tree(g_repo, g_object, &opts));
@@ -923,12 +923,12 @@ void test_checkout_tree__extremely_long_file_name(void)
cl_git_pass(git_checkout_tree(g_repo, g_object, &g_opts));
sprintf(path, "testrepo/%s.txt", longname);
- cl_assert(git_path_exists(path));
+ cl_assert(git_fs_path_exists(path));
git_object_free(g_object);
cl_git_pass(git_revparse_single(&g_object, g_repo, "master"));
cl_git_pass(git_checkout_tree(g_repo, g_object, &g_opts));
- cl_assert(!git_path_exists(path));
+ cl_assert(!git_fs_path_exists(path));
}
static void create_conflict(const char *path)
@@ -1034,7 +1034,8 @@ void test_checkout_tree__filemode_preserved_in_index(void)
git_index_free(index);
}
-mode_t read_filemode(const char *path)
+#ifndef GIT_WIN32
+static mode_t read_filemode(const char *path)
{
git_str fullpath = GIT_STR_INIT;
struct stat st;
@@ -1050,6 +1051,7 @@ mode_t read_filemode(const char *path)
return result;
}
+#endif
void test_checkout_tree__filemode_preserved_in_workdir(void)
{
@@ -1138,7 +1140,7 @@ void test_checkout_tree__removes_conflicts(void)
cl_assert_equal_p(NULL, git_index_get_bypath(index, "other.txt", 2));
cl_assert_equal_p(NULL, git_index_get_bypath(index, "other.txt", 3));
- cl_assert(!git_path_exists("testrepo/other.txt"));
+ cl_assert(!git_fs_path_exists("testrepo/other.txt"));
git_commit_free(commit);
git_index_free(index);
@@ -1183,7 +1185,7 @@ void test_checkout_tree__removes_conflicts_only_by_pathscope(void)
cl_assert(git_index_get_bypath(index, "other.txt", 2) != NULL);
cl_assert(git_index_get_bypath(index, "other.txt", 3) != NULL);
- cl_assert(git_path_exists("testrepo/other.txt"));
+ cl_assert(git_fs_path_exists("testrepo/other.txt"));
git_commit_free(commit);
git_index_free(index);
@@ -1214,8 +1216,8 @@ void test_checkout_tree__case_changing_rename(void)
cl_git_pass(git_checkout_tree(g_repo, (git_object *)dir_commit, &opts));
cl_git_pass(git_repository_set_head(g_repo, "refs/heads/dir"));
- cl_assert(git_path_isfile("testrepo/README"));
- case_sensitive = !git_path_isfile("testrepo/readme");
+ cl_assert(git_fs_path_isfile("testrepo/README"));
+ case_sensitive = !git_fs_path_isfile("testrepo/readme");
cl_assert(index_entry = git_index_get_bypath(index, "README", 0));
cl_assert_equal_s("README", index_entry->path);
@@ -1235,9 +1237,9 @@ void test_checkout_tree__case_changing_rename(void)
cl_git_pass(git_commit_create(&commit_id, g_repo, "refs/heads/dir", signature, signature, NULL, "case-changing rename", tree, 1, (const git_commit **)&dir_commit));
- cl_assert(git_path_isfile("testrepo/readme"));
+ cl_assert(git_fs_path_isfile("testrepo/readme"));
if (case_sensitive)
- cl_assert(!git_path_isfile("testrepo/README"));
+ cl_assert(!git_fs_path_isfile("testrepo/README"));
cl_assert(index_entry = git_index_get_bypath(index, "readme", 0));
cl_assert_equal_s("readme", index_entry->path);
@@ -1253,9 +1255,9 @@ void test_checkout_tree__case_changing_rename(void)
assert_on_branch(g_repo, "master");
- cl_assert(git_path_isfile("testrepo/README"));
+ cl_assert(git_fs_path_isfile("testrepo/README"));
if (case_sensitive)
- cl_assert(!git_path_isfile("testrepo/readme"));
+ cl_assert(!git_fs_path_isfile("testrepo/readme"));
cl_assert(index_entry = git_index_get_bypath(index, "README", 0));
cl_assert_equal_s("README", index_entry->path);
@@ -1267,7 +1269,7 @@ void test_checkout_tree__case_changing_rename(void)
git_commit_free(master_commit);
}
-void perfdata_cb(const git_checkout_perfdata *in, void *payload)
+static void perfdata_cb(const git_checkout_perfdata *in, void *payload)
{
memcpy(payload, in, sizeof(git_checkout_perfdata));
}
@@ -1296,7 +1298,7 @@ void test_checkout_tree__can_collect_perfdata(void)
git_object_free(obj);
}
-void update_attr_callback(
+static void update_attr_callback(
const char *path,
size_t completed_steps,
size_t total_steps,
@@ -1366,13 +1368,13 @@ void test_checkout_tree__can_not_update_index(void)
cl_git_pass(git_reset(g_repo, head, GIT_RESET_HARD, &g_opts));
- cl_assert_equal_i(false, git_path_isdir("./testrepo/ab/"));
+ cl_assert_equal_i(false, git_fs_path_isdir("./testrepo/ab/"));
cl_git_pass(git_revparse_single(&g_object, g_repo, "subtrees"));
cl_git_pass(git_checkout_tree(g_repo, g_object, &opts));
- cl_assert_equal_i(true, git_path_isfile("./testrepo/ab/de/2.txt"));
+ cl_assert_equal_i(true, git_fs_path_isfile("./testrepo/ab/de/2.txt"));
cl_git_pass(git_status_file(&status, g_repo, "ab/de/2.txt"));
cl_assert_equal_i(GIT_STATUS_WT_NEW, status);
@@ -1403,13 +1405,13 @@ void test_checkout_tree__can_update_but_not_write_index(void)
cl_git_pass(git_reset(g_repo, head, GIT_RESET_HARD, &g_opts));
- cl_assert_equal_i(false, git_path_isdir("./testrepo/ab/"));
+ cl_assert_equal_i(false, git_fs_path_isdir("./testrepo/ab/"));
cl_git_pass(git_revparse_single(&g_object, g_repo, "subtrees"));
cl_git_pass(git_checkout_tree(g_repo, g_object, &opts));
- cl_assert_equal_i(true, git_path_isfile("./testrepo/ab/de/2.txt"));
+ cl_assert_equal_i(true, git_fs_path_isfile("./testrepo/ab/de/2.txt"));
cl_git_pass(git_status_file(&status, g_repo, "ab/de/2.txt"));
cl_assert_equal_i(GIT_STATUS_INDEX_NEW, status);
@@ -1450,15 +1452,15 @@ void test_checkout_tree__safe_proceeds_if_no_index(void)
cl_git_pass(git_checkout_tree(g_repo, obj, &opts));
cl_git_pass(git_repository_set_head(g_repo, "refs/heads/subtrees"));
- cl_assert(git_path_isfile("testrepo/README"));
- cl_assert(git_path_isfile("testrepo/branch_file.txt"));
- cl_assert(git_path_isfile("testrepo/new.txt"));
- cl_assert(git_path_isfile("testrepo/ab/4.txt"));
- cl_assert(git_path_isfile("testrepo/ab/c/3.txt"));
- cl_assert(git_path_isfile("testrepo/ab/de/2.txt"));
- cl_assert(git_path_isfile("testrepo/ab/de/fgh/1.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/README"));
+ cl_assert(git_fs_path_isfile("testrepo/branch_file.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/new.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/ab/4.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/ab/c/3.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/ab/de/2.txt"));
+ cl_assert(git_fs_path_isfile("testrepo/ab/de/fgh/1.txt"));
- cl_assert(!git_path_isdir("testrepo/a"));
+ cl_assert(!git_fs_path_isdir("testrepo/a"));
assert_on_branch(g_repo, "subtrees");
@@ -1650,7 +1652,7 @@ void test_checkout_tree__dry_run(void)
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
cl_git_pass(git_checkout_head(g_repo, &opts));
- cl_assert(!git_path_isdir("testrepo/a"));
+ cl_assert(!git_fs_path_isdir("testrepo/a"));
check_file_contents_nocr("testrepo/branch_file.txt", "hi\nbye!\n");
@@ -1673,7 +1675,7 @@ void test_checkout_tree__dry_run(void)
/* these normally would have been created and updated, but with
* DRY_RUN they will be unchanged.
*/
- cl_assert(!git_path_isdir("testrepo/a"));
+ cl_assert(!git_fs_path_isdir("testrepo/a"));
check_file_contents_nocr("testrepo/branch_file.txt", "hi\nbye!\n");
/* check that notify callback was invoked */
diff --git a/tests/checkout/typechange.c b/tests/checkout/typechange.c
index 205ce657f..b888843f0 100644
--- a/tests/checkout/typechange.c
+++ b/tests/checkout/typechange.c
@@ -76,12 +76,12 @@ void test_checkout_typechange__cleanup(void)
static void assert_file_exists(const char *path)
{
- cl_assert_(git_path_isfile(path), path);
+ cl_assert_(git_fs_path_isfile(path), path);
}
static void assert_dir_exists(const char *path)
{
- cl_assert_(git_path_isdir(path), path);
+ cl_assert_(git_fs_path_isdir(path), path);
}
static void assert_workdir_matches_tree(
@@ -126,7 +126,7 @@ static void assert_workdir_matches_tree(
/* because of cross-platform, don't confirm exec bit yet */
break;
case GIT_FILEMODE_LINK:
- cl_assert_(git_path_exists(path.ptr), path.ptr);
+ cl_assert_(git_fs_path_exists(path.ptr), path.ptr);
/* because of cross-platform, don't confirm link yet */
break;
default:
@@ -163,19 +163,19 @@ void test_checkout_typechange__checkout_typechanges_safe(void)
git_object_free(obj);
if (!g_typechange_empty[i]) {
- cl_assert(git_path_isdir("typechanges"));
- cl_assert(git_path_exists("typechanges/a"));
- cl_assert(git_path_exists("typechanges/b"));
- cl_assert(git_path_exists("typechanges/c"));
- cl_assert(git_path_exists("typechanges/d"));
- cl_assert(git_path_exists("typechanges/e"));
+ cl_assert(git_fs_path_isdir("typechanges"));
+ cl_assert(git_fs_path_exists("typechanges/a"));
+ cl_assert(git_fs_path_exists("typechanges/b"));
+ cl_assert(git_fs_path_exists("typechanges/c"));
+ cl_assert(git_fs_path_exists("typechanges/d"));
+ cl_assert(git_fs_path_exists("typechanges/e"));
} else {
- cl_assert(git_path_isdir("typechanges"));
- cl_assert(!git_path_exists("typechanges/a"));
- cl_assert(!git_path_exists("typechanges/b"));
- cl_assert(!git_path_exists("typechanges/c"));
- cl_assert(!git_path_exists("typechanges/d"));
- cl_assert(!git_path_exists("typechanges/e"));
+ cl_assert(git_fs_path_isdir("typechanges"));
+ cl_assert(!git_fs_path_exists("typechanges/a"));
+ cl_assert(!git_fs_path_exists("typechanges/b"));
+ cl_assert(!git_fs_path_exists("typechanges/c"));
+ cl_assert(!git_fs_path_exists("typechanges/d"));
+ cl_assert(!git_fs_path_exists("typechanges/e"));
}
}
}
@@ -293,12 +293,12 @@ void test_checkout_typechange__checkout_with_conflicts(void)
GIT_CHECKOUT_FORCE | GIT_CHECKOUT_REMOVE_UNTRACKED;
memset(&cts, 0, sizeof(cts));
- cl_assert(git_path_exists("typechanges/untracked"));
+ cl_assert(git_fs_path_exists("typechanges/untracked"));
cl_git_pass(git_checkout_tree(g_repo, obj, &opts));
cl_assert_equal_i(0, cts.conflicts);
- cl_assert(!git_path_exists("typechanges/untracked"));
+ cl_assert(!git_fs_path_exists("typechanges/untracked"));
cl_git_pass(
git_repository_set_head_detached(g_repo, git_object_id(obj)));
diff --git a/tests/cherrypick/workdir.c b/tests/cherrypick/workdir.c
index f7765f2c2..868b9d5ff 100644
--- a/tests/cherrypick/workdir.c
+++ b/tests/cherrypick/workdir.c
@@ -71,8 +71,8 @@ void test_cherrypick_workdir__automerge(void)
cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid));
cl_git_pass(git_cherrypick(repo, commit, NULL));
- cl_assert(git_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD"));
- cl_assert(git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
+ cl_assert(git_fs_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD"));
+ cl_assert(git_fs_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
cl_git_pass(git_index_write_tree(&cherrypicked_tree_oid, repo_index));
cl_git_pass(git_tree_lookup(&cherrypicked_tree, repo, &cherrypicked_tree_oid));
@@ -114,7 +114,7 @@ void test_cherrypick_workdir__empty_result(void)
/* Create an untracked file that should not conflict */
cl_git_mkfile(TEST_REPO_PATH "/file4.txt", "");
- cl_assert(git_path_exists(TEST_REPO_PATH "/file4.txt"));
+ cl_assert(git_fs_path_exists(TEST_REPO_PATH "/file4.txt"));
cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL));
@@ -160,8 +160,8 @@ void test_cherrypick_workdir__conflicts(void)
cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid));
cl_git_pass(git_cherrypick(repo, commit, NULL));
- cl_assert(git_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD"));
- cl_assert(git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
+ cl_assert(git_fs_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD"));
+ cl_assert(git_fs_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
cl_assert(merge_test_index(repo_index, merge_index_entries, 7));
@@ -373,8 +373,8 @@ void test_cherrypick_workdir__nonmerge_fails_mainline_specified(void)
opts.mainline = 1;
cl_must_fail(git_cherrypick(repo, commit, &opts));
- cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD"));
- cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
+ cl_assert(!git_fs_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD"));
+ cl_assert(!git_fs_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
git_reference_free(head);
git_commit_free(commit);
@@ -396,8 +396,8 @@ void test_cherrypick_workdir__merge_fails_without_mainline_specified(void)
cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid));
cl_must_fail(git_cherrypick(repo, commit, NULL));
- cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD"));
- cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
+ cl_assert(!git_fs_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD"));
+ cl_assert(!git_fs_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
git_commit_free(commit);
git_commit_free(head);
diff --git a/tests/clar.h b/tests/clar.h
index 8c22382bd..3f659c2f6 100644
--- a/tests/clar.h
+++ b/tests/clar.h
@@ -13,12 +13,12 @@ enum cl_test_status {
CL_TEST_OK,
CL_TEST_FAILURE,
CL_TEST_SKIP,
- CL_TEST_NOTRUN,
+ CL_TEST_NOTRUN
};
enum cl_output_format {
CL_OUTPUT_CLAP,
- CL_OUTPUT_TAP,
+ CL_OUTPUT_TAP
};
/** Setup clar environment */
@@ -60,7 +60,7 @@ typedef enum cl_trace_event {
CL_TRACE__TEST__END,
CL_TRACE__TEST__RUN_BEGIN,
CL_TRACE__TEST__RUN_END,
- CL_TRACE__TEST__LONGJMP,
+ CL_TRACE__TEST__LONGJMP
} cl_trace_event;
typedef void (cl_trace_cb)(
diff --git a/tests/clar/summary.h b/tests/clar/summary.h
index 1af110efa..6279f5057 100644
--- a/tests/clar/summary.h
+++ b/tests/clar/summary.h
@@ -2,7 +2,7 @@
#include <stdio.h>
#include <time.h>
-int clar_summary_close_tag(
+static int clar_summary_close_tag(
struct clar_summary *summary, const char *tag, int indent)
{
const char *indt;
@@ -14,12 +14,12 @@ int clar_summary_close_tag(
return fprintf(summary->fp, "%s</%s>\n", indt, tag);
}
-int clar_summary_testsuites(struct clar_summary *summary)
+static int clar_summary_testsuites(struct clar_summary *summary)
{
return fprintf(summary->fp, "<testsuites>\n");
}
-int clar_summary_testsuite(struct clar_summary *summary,
+static int clar_summary_testsuite(struct clar_summary *summary,
int idn, const char *name, const char *pkg, time_t timestamp,
double elapsed, int test_count, int fail_count, int error_count)
{
@@ -42,7 +42,7 @@ int clar_summary_testsuite(struct clar_summary *summary,
idn, name, pkg, iso_dt, elapsed, test_count, fail_count, error_count);
}
-int clar_summary_testcase(struct clar_summary *summary,
+static int clar_summary_testcase(struct clar_summary *summary,
const char *name, const char *classname, double elapsed)
{
return fprintf(summary->fp,
@@ -50,7 +50,7 @@ int clar_summary_testcase(struct clar_summary *summary,
name, classname, elapsed);
}
-int clar_summary_failure(struct clar_summary *summary,
+static int clar_summary_failure(struct clar_summary *summary,
const char *type, const char *message, const char *desc)
{
return fprintf(summary->fp,
diff --git a/tests/clar_libgit2.c b/tests/clar_libgit2.c
index adea597e3..55a09d111 100644
--- a/tests/clar_libgit2.c
+++ b/tests/clar_libgit2.c
@@ -1,6 +1,6 @@
#include "clar_libgit2.h"
#include "posix.h"
-#include "path.h"
+#include "fs_path.h"
#include "git2/sys/repository.h"
void cl_git_report_failure(
@@ -281,7 +281,7 @@ const char* cl_git_path_url(const char *path)
git_str path_buf = GIT_STR_INIT;
git_str url_buf = GIT_STR_INIT;
- cl_git_pass(git_path_prettify_dir(&path_buf, path, NULL));
+ cl_git_pass(git_fs_path_prettify_dir(&path_buf, path, NULL));
cl_git_pass(git_str_puts(&url_buf, "file://"));
#ifdef GIT_WIN32
@@ -336,9 +336,9 @@ const char *cl_git_sandbox_path(int is_dir, ...)
}
va_end(arg);
- cl_git_pass(git_path_prettify(&buf, buf.ptr, NULL));
+ cl_git_pass(git_fs_path_prettify(&buf, buf.ptr, NULL));
if (is_dir)
- git_path_to_dir(&buf);
+ git_fs_path_to_dir(&buf);
/* make sure we won't truncate */
cl_assert(git_str_len(&buf) < sizeof(_temp));
@@ -359,8 +359,8 @@ static int remove_placeholders_recurs(void *_data, git_str *path)
remove_data *data = (remove_data *)_data;
size_t pathlen;
- if (git_path_isdir(path->ptr) == true)
- return git_path_direach(path, 0, remove_placeholders_recurs, data);
+ if (git_fs_path_isdir(path->ptr) == true)
+ return git_fs_path_direach(path, 0, remove_placeholders_recurs, data);
pathlen = path->size;
@@ -382,7 +382,7 @@ int cl_git_remove_placeholders(const char *directory_path, const char *filename)
remove_data data;
git_str buffer = GIT_STR_INIT;
- if (git_path_isdir(directory_path) == false)
+ if (git_fs_path_isdir(directory_path) == false)
return -1;
if (git_str_sets(&buffer, directory_path) < 0)
@@ -570,9 +570,9 @@ void cl_fake_home(void)
cl_set_cleanup(cl_fake_home_cleanup, NULL);
- if (!git_path_exists("home"))
+ if (!git_fs_path_exists("home"))
cl_must_pass(p_mkdir("home", 0777));
- cl_git_pass(git_path_prettify(&path, "home", NULL));
+ cl_git_pass(git_fs_path_prettify(&path, "home", NULL));
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, path.ptr));
git_str_dispose(&path);
@@ -584,7 +584,7 @@ void cl_sandbox_set_search_path_defaults(void)
git_str_joinpath(&path, clar_sandbox_path(), "__config");
- if (!git_path_exists(path.ptr))
+ if (!git_fs_path_exists(path.ptr))
cl_must_pass(p_mkdir(path.ptr, 0777));
git_libgit2_opts(
diff --git a/tests/clar_libgit2_trace.c b/tests/clar_libgit2_trace.c
index 8eb6d4e8d..ebb0f41dd 100644
--- a/tests/clar_libgit2_trace.c
+++ b/tests/clar_libgit2_trace.c
@@ -150,7 +150,7 @@ static cl_perf_timer s_timer_run = CL_PERF_TIMER_INIT;
*/
static cl_perf_timer s_timer_test = CL_PERF_TIMER_INIT;
-void _cl_trace_cb__event_handler(
+static void _cl_trace_cb__event_handler(
cl_trace_event ev,
const char *suite_name,
const char *test_name,
diff --git a/tests/clone/nonetwork.c b/tests/clone/nonetwork.c
index 7625a2183..eab633635 100644
--- a/tests/clone/nonetwork.c
+++ b/tests/clone/nonetwork.c
@@ -51,10 +51,10 @@ void test_clone_nonetwork__bad_urls(void)
{
/* Clone should clean up the mess if the URL isn't a git repository */
cl_git_fail(git_clone(&g_repo, "not_a_repo", "./foo", &g_options));
- cl_assert(!git_path_exists("./foo"));
+ cl_assert(!git_fs_path_exists("./foo"));
g_options.bare = true;
cl_git_fail(git_clone(&g_repo, "not_a_repo", "./foo", &g_options));
- cl_assert(!git_path_exists("./foo"));
+ cl_assert(!git_fs_path_exists("./foo"));
cl_git_fail(git_clone(&g_repo, "git://example.com:asdf", "./foo", &g_options));
cl_git_fail(git_clone(&g_repo, "https://example.com:asdf/foo", "./foo", &g_options));
@@ -70,12 +70,12 @@ void test_clone_nonetwork__do_not_clean_existing_directory(void)
* Should clean up entries it creates. */
p_mkdir("./foo", GIT_DIR_MODE);
cl_git_fail(git_clone(&g_repo, "not_a_repo", "./foo", &g_options));
- cl_assert(git_path_is_empty_dir("./foo"));
+ cl_assert(git_fs_path_is_empty_dir("./foo"));
/* Try again with a bare repository. */
g_options.bare = true;
cl_git_fail(git_clone(&g_repo, "not_a_repo", "./foo", &g_options));
- cl_assert(git_path_is_empty_dir("./foo"));
+ cl_assert(git_fs_path_is_empty_dir("./foo"));
}
void test_clone_nonetwork__local(void)
@@ -109,7 +109,7 @@ void test_clone_nonetwork__fail_with_already_existing_but_non_empty_directory(vo
cl_git_fail(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options));
}
-int custom_origin_name_remote_create(
+static int custom_origin_name_remote_create(
git_remote **out,
git_repository *repo,
const char *name,
@@ -151,7 +151,7 @@ void test_clone_nonetwork__can_prevent_the_checkout_of_a_standard_repo(void)
cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options));
cl_git_pass(git_str_joinpath(&path, git_repository_workdir(g_repo), "master.txt"));
- cl_assert_equal_i(false, git_path_isfile(git_str_cstr(&path)));
+ cl_assert_equal_i(false, git_fs_path_isfile(git_str_cstr(&path)));
git_str_dispose(&path);
}
@@ -168,7 +168,7 @@ void test_clone_nonetwork__can_checkout_given_branch(void)
cl_git_pass(git_repository_head(&g_ref, g_repo));
cl_assert_equal_s(git_reference_name(g_ref), "refs/heads/test");
- cl_assert(git_path_exists("foo/readme.txt"));
+ cl_assert(git_fs_path_exists("foo/readme.txt"));
cl_git_pass(git_reference_lookup(&remote_head, g_repo, "refs/remotes/origin/HEAD"));
cl_assert_equal_i(GIT_REFERENCE_SYMBOLIC, git_reference_type(remote_head));
@@ -196,7 +196,7 @@ void test_clone_nonetwork__can_cancel_clone_in_fetch(void)
-54321);
cl_assert(!g_repo);
- cl_assert(!git_path_exists("foo/readme.txt"));
+ cl_assert(!git_fs_path_exists("foo/readme.txt"));
}
static int clone_cancel_checkout_cb(
@@ -227,7 +227,7 @@ void test_clone_nonetwork__can_cancel_clone_in_checkout(void)
-12345);
cl_assert(!g_repo);
- cl_assert(!git_path_exists("foo/readme.txt"));
+ cl_assert(!git_fs_path_exists("foo/readme.txt"));
}
void test_clone_nonetwork__can_detached_head(void)
diff --git a/tests/commit/commit.c b/tests/commit/commit.c
index b03169bc8..d4e333b6a 100644
--- a/tests/commit/commit.c
+++ b/tests/commit/commit.c
@@ -111,7 +111,7 @@ void test_commit_commit__create_initial_commit_parent_not_current(void)
git_signature_free(s);
}
-void assert_commit_summary(const char *expected, const char *given)
+static void assert_commit_summary(const char *expected, const char *given)
{
git_commit *dummy;
@@ -123,7 +123,7 @@ void assert_commit_summary(const char *expected, const char *given)
git_commit__free(dummy);
}
-void assert_commit_body(const char *expected, const char *given)
+static void assert_commit_body(const char *expected, const char *given)
{
git_commit *dummy;
diff --git a/tests/config/global.c b/tests/config/global.c
index d59c39fa2..5aba4eec6 100644
--- a/tests/config/global.c
+++ b/tests/config/global.c
@@ -6,17 +6,17 @@ void test_config_global__initialize(void)
git_str path = GIT_STR_INIT;
cl_git_pass(git_futils_mkdir_r("home", 0777));
- cl_git_pass(git_path_prettify(&path, "home", NULL));
+ cl_git_pass(git_fs_path_prettify(&path, "home", NULL));
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, path.ptr));
cl_git_pass(git_futils_mkdir_r("xdg/git", 0777));
- cl_git_pass(git_path_prettify(&path, "xdg/git", NULL));
+ cl_git_pass(git_fs_path_prettify(&path, "xdg/git", NULL));
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_XDG, path.ptr));
cl_git_pass(git_futils_mkdir_r("etc", 0777));
- cl_git_pass(git_path_prettify(&path, "etc", NULL));
+ cl_git_pass(git_fs_path_prettify(&path, "etc", NULL));
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, path.ptr));
@@ -141,7 +141,7 @@ void test_config_global__open_programdata(void)
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH,
GIT_CONFIG_LEVEL_PROGRAMDATA, &dir_path));
- if (!git_path_isdir(dir_path.ptr))
+ if (!git_fs_path_isdir(dir_path.ptr))
cl_git_pass(p_mkdir(dir_path.ptr, 0777));
cl_git_pass(git_str_joinpath(&config_path, dir_path.ptr, "config"));
diff --git a/tests/config/read.c b/tests/config/read.c
index 77f8a1262..3c96f8519 100644
--- a/tests/config/read.c
+++ b/tests/config/read.c
@@ -1,5 +1,5 @@
#include "clar_libgit2.h"
-#include "path.h"
+#include "fs_path.h"
static git_buf buf = GIT_BUF_INIT;
@@ -705,11 +705,11 @@ void test_config_read__path(void)
git_str expected_path = GIT_STR_INIT;
cl_git_pass(p_mkdir("fakehome", 0777));
- cl_git_pass(git_path_prettify(&home_path, "fakehome", NULL));
+ cl_git_pass(git_fs_path_prettify(&home_path, "fakehome", NULL));
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, &old_path));
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, home_path.ptr));
cl_git_mkfile("./testconfig", "[some]\n path = ~/somefile");
- cl_git_pass(git_path_join_unrooted(&expected_path, "somefile", home_path.ptr, NULL));
+ cl_git_pass(git_fs_path_join_unrooted(&expected_path, "somefile", home_path.ptr, NULL));
cl_git_pass(git_config_open_ondisk(&cfg, "./testconfig"));
cl_git_pass(git_config_get_path(&path, cfg, "some.path"));
@@ -717,7 +717,7 @@ void test_config_read__path(void)
git_buf_dispose(&path);
cl_git_mkfile("./testconfig", "[some]\n path = ~/");
- cl_git_pass(git_path_join_unrooted(&expected_path, "", home_path.ptr, NULL));
+ cl_git_pass(git_fs_path_join_unrooted(&expected_path, "", home_path.ptr, NULL));
cl_git_pass(git_config_get_path(&path, cfg, "some.path"));
cl_assert_equal_s(expected_path.ptr, path.ptr);
diff --git a/tests/config/readonly.c b/tests/config/readonly.c
index 5d544b8cb..a8901e394 100644
--- a/tests/config/readonly.c
+++ b/tests/config/readonly.c
@@ -25,7 +25,7 @@ void test_config_readonly__writing_to_readonly_fails(void)
cl_git_pass(git_config_add_backend(cfg, backend, GIT_CONFIG_LEVEL_GLOBAL, NULL, 0));
cl_git_fail_with(GIT_ENOTFOUND, git_config_set_string(cfg, "foo.bar", "baz"));
- cl_assert(!git_path_exists("global"));
+ cl_assert(!git_fs_path_exists("global"));
}
void test_config_readonly__writing_to_cfg_with_rw_precedence_succeeds(void)
@@ -41,8 +41,8 @@ void test_config_readonly__writing_to_cfg_with_rw_precedence_succeeds(void)
cl_git_pass(git_config_set_string(cfg, "foo.bar", "baz"));
- cl_assert(git_path_exists("local"));
- cl_assert(!git_path_exists("global"));
+ cl_assert(git_fs_path_exists("local"));
+ cl_assert(!git_fs_path_exists("global"));
cl_git_pass(p_unlink("local"));
}
@@ -59,7 +59,7 @@ void test_config_readonly__writing_to_cfg_with_ro_precedence_succeeds(void)
cl_git_pass(git_config_set_string(cfg, "foo.bar", "baz"));
- cl_assert(!git_path_exists("local"));
- cl_assert(git_path_exists("global"));
+ cl_assert(!git_fs_path_exists("local"));
+ cl_assert(git_fs_path_exists("global"));
cl_git_pass(p_unlink("global"));
}
diff --git a/tests/config/stress.c b/tests/config/stress.c
index 7ec274b18..69e6810fa 100644
--- a/tests/config/stress.c
+++ b/tests/config/stress.c
@@ -30,7 +30,7 @@ void test_config_stress__dont_break_on_invalid_input(void)
{
git_config *config;
- cl_assert(git_path_exists(TEST_CONFIG));
+ cl_assert(git_fs_path_exists(TEST_CONFIG));
cl_git_pass(git_config_open_ondisk(&config, TEST_CONFIG));
cl_git_pass(git_config_get_string_buf(&buf, config, "color.ui"));
@@ -39,7 +39,7 @@ void test_config_stress__dont_break_on_invalid_input(void)
git_config_free(config);
}
-void assert_config_value(git_config *config, const char *key, const char *value)
+static void assert_config_value(git_config *config, const char *key, const char *value)
{
git_buf_dispose(&buf);
cl_git_pass(git_config_get_string_buf(&buf, config, key));
@@ -72,7 +72,7 @@ void test_config_stress__escape_subsection_names(void)
{
git_config *config;
- cl_assert(git_path_exists("git-test-config"));
+ cl_assert(git_fs_path_exists("git-test-config"));
cl_git_pass(git_config_open_ondisk(&config, TEST_CONFIG));
cl_git_pass(git_config_set_string(config, "some.sec\\tion.other", "foo"));
@@ -90,7 +90,7 @@ void test_config_stress__trailing_backslash(void)
git_config *config;
const char *path = "C:\\iam\\some\\windows\\path\\";
- cl_assert(git_path_exists("git-test-config"));
+ cl_assert(git_fs_path_exists("git-test-config"));
cl_git_pass(git_config_open_ondisk(&config, TEST_CONFIG));
cl_git_pass(git_config_set_string(config, "windows.path", path));
git_config_free(config);
diff --git a/tests/core/copy.c b/tests/core/copy.c
index d31274808..b03d71083 100644
--- a/tests/core/copy.c
+++ b/tests/core/copy.c
@@ -12,7 +12,7 @@ void test_core_copy__file(void)
cl_git_pass(git_futils_cp("copy_me", "copy_me_two", 0664));
- cl_git_pass(git_path_lstat("copy_me_two", &st));
+ cl_git_pass(git_fs_path_lstat("copy_me_two", &st));
cl_assert(S_ISREG(st.st_mode));
cl_assert(strlen(content) == (size_t)st.st_size);
@@ -27,7 +27,7 @@ void test_core_copy__file_in_dir(void)
cl_git_pass(git_futils_mkdir("an_dir/in_a_dir", 0775, GIT_MKDIR_PATH));
cl_git_mkfile("an_dir/in_a_dir/copy_me", content);
- cl_assert(git_path_isdir("an_dir"));
+ cl_assert(git_fs_path_isdir("an_dir"));
cl_git_pass(git_futils_mkpath2file
("an_dir/second_dir/and_more/copy_me_two", 0775));
@@ -37,23 +37,25 @@ void test_core_copy__file_in_dir(void)
"an_dir/second_dir/and_more/copy_me_two",
0664));
- cl_git_pass(git_path_lstat("an_dir/second_dir/and_more/copy_me_two", &st));
+ cl_git_pass(git_fs_path_lstat("an_dir/second_dir/and_more/copy_me_two", &st));
cl_assert(S_ISREG(st.st_mode));
cl_assert(strlen(content) == (size_t)st.st_size);
cl_git_pass(git_futils_rmdir_r("an_dir", NULL, GIT_RMDIR_REMOVE_FILES));
- cl_assert(!git_path_isdir("an_dir"));
+ cl_assert(!git_fs_path_isdir("an_dir"));
}
-void assert_hard_link(const char *path)
+#ifndef GIT_WIN32
+static void assert_hard_link(const char *path)
{
/* we assert this by checking that there's more than one link to the file */
struct stat st;
- cl_assert(git_path_isfile(path));
+ cl_assert(git_fs_path_isfile(path));
cl_git_pass(p_stat(path, &st));
cl_assert(st.st_nlink > 1);
}
+#endif
void test_core_copy__tree(void)
{
@@ -74,73 +76,73 @@ void test_core_copy__tree(void)
cl_assert(p_symlink("../../b/f2", "src/c/d/l1") == 0);
#endif
- cl_assert(git_path_isdir("src"));
- cl_assert(git_path_isdir("src/b"));
- cl_assert(git_path_isdir("src/c/d"));
- cl_assert(git_path_isfile("src/c/d/f4"));
+ cl_assert(git_fs_path_isdir("src"));
+ cl_assert(git_fs_path_isdir("src/b"));
+ cl_assert(git_fs_path_isdir("src/c/d"));
+ cl_assert(git_fs_path_isfile("src/c/d/f4"));
/* copy with no empty dirs, yes links, no dotfiles, no overwrite */
cl_git_pass(
git_futils_cp_r("src", "t1", GIT_CPDIR_COPY_SYMLINKS, 0) );
- cl_assert(git_path_isdir("t1"));
- cl_assert(git_path_isdir("t1/b"));
- cl_assert(git_path_isdir("t1/c"));
- cl_assert(git_path_isdir("t1/c/d"));
- cl_assert(!git_path_isdir("t1/c/e"));
+ cl_assert(git_fs_path_isdir("t1"));
+ cl_assert(git_fs_path_isdir("t1/b"));
+ cl_assert(git_fs_path_isdir("t1/c"));
+ cl_assert(git_fs_path_isdir("t1/c/d"));
+ cl_assert(!git_fs_path_isdir("t1/c/e"));
- cl_assert(git_path_isfile("t1/f1"));
- cl_assert(git_path_isfile("t1/b/f2"));
- cl_assert(git_path_isfile("t1/c/f3"));
- cl_assert(git_path_isfile("t1/c/d/f4"));
- cl_assert(!git_path_isfile("t1/c/d/.f5"));
+ cl_assert(git_fs_path_isfile("t1/f1"));
+ cl_assert(git_fs_path_isfile("t1/b/f2"));
+ cl_assert(git_fs_path_isfile("t1/c/f3"));
+ cl_assert(git_fs_path_isfile("t1/c/d/f4"));
+ cl_assert(!git_fs_path_isfile("t1/c/d/.f5"));
- cl_git_pass(git_path_lstat("t1/c/f3", &st));
+ cl_git_pass(git_fs_path_lstat("t1/c/f3", &st));
cl_assert(S_ISREG(st.st_mode));
cl_assert(strlen(content) == (size_t)st.st_size);
#ifndef GIT_WIN32
- cl_git_pass(git_path_lstat("t1/c/d/l1", &st));
+ cl_git_pass(git_fs_path_lstat("t1/c/d/l1", &st));
cl_assert(S_ISLNK(st.st_mode));
#endif
cl_git_pass(git_futils_rmdir_r("t1", NULL, GIT_RMDIR_REMOVE_FILES));
- cl_assert(!git_path_isdir("t1"));
+ cl_assert(!git_fs_path_isdir("t1"));
/* copy with empty dirs, no links, yes dotfiles, no overwrite */
cl_git_pass(
git_futils_cp_r("src", "t2", GIT_CPDIR_CREATE_EMPTY_DIRS | GIT_CPDIR_COPY_DOTFILES, 0) );
- cl_assert(git_path_isdir("t2"));
- cl_assert(git_path_isdir("t2/b"));
- cl_assert(git_path_isdir("t2/c"));
- cl_assert(git_path_isdir("t2/c/d"));
- cl_assert(git_path_isdir("t2/c/e"));
+ cl_assert(git_fs_path_isdir("t2"));
+ cl_assert(git_fs_path_isdir("t2/b"));
+ cl_assert(git_fs_path_isdir("t2/c"));
+ cl_assert(git_fs_path_isdir("t2/c/d"));
+ cl_assert(git_fs_path_isdir("t2/c/e"));
- cl_assert(git_path_isfile("t2/f1"));
- cl_assert(git_path_isfile("t2/b/f2"));
- cl_assert(git_path_isfile("t2/c/f3"));
- cl_assert(git_path_isfile("t2/c/d/f4"));
- cl_assert(git_path_isfile("t2/c/d/.f5"));
+ cl_assert(git_fs_path_isfile("t2/f1"));
+ cl_assert(git_fs_path_isfile("t2/b/f2"));
+ cl_assert(git_fs_path_isfile("t2/c/f3"));
+ cl_assert(git_fs_path_isfile("t2/c/d/f4"));
+ cl_assert(git_fs_path_isfile("t2/c/d/.f5"));
#ifndef GIT_WIN32
- cl_git_fail(git_path_lstat("t2/c/d/l1", &st));
+ cl_git_fail(git_fs_path_lstat("t2/c/d/l1", &st));
#endif
cl_git_pass(git_futils_rmdir_r("t2", NULL, GIT_RMDIR_REMOVE_FILES));
- cl_assert(!git_path_isdir("t2"));
+ cl_assert(!git_fs_path_isdir("t2"));
#ifndef GIT_WIN32
cl_git_pass(git_futils_cp_r("src", "t3", GIT_CPDIR_CREATE_EMPTY_DIRS | GIT_CPDIR_LINK_FILES, 0));
- cl_assert(git_path_isdir("t3"));
+ cl_assert(git_fs_path_isdir("t3"));
- cl_assert(git_path_isdir("t3"));
- cl_assert(git_path_isdir("t3/b"));
- cl_assert(git_path_isdir("t3/c"));
- cl_assert(git_path_isdir("t3/c/d"));
- cl_assert(git_path_isdir("t3/c/e"));
+ cl_assert(git_fs_path_isdir("t3"));
+ cl_assert(git_fs_path_isdir("t3/b"));
+ cl_assert(git_fs_path_isdir("t3/c"));
+ cl_assert(git_fs_path_isdir("t3/c/d"));
+ cl_assert(git_fs_path_isdir("t3/c/e"));
assert_hard_link("t3/f1");
assert_hard_link("t3/b/f2");
diff --git a/tests/core/dirent.c b/tests/core/dirent.c
index ce93e0358..2419ec7ab 100644
--- a/tests/core/dirent.c
+++ b/tests/core/dirent.c
@@ -113,7 +113,7 @@ void test_core_dirent__dont_traverse_dot(void)
cl_set_cleanup(&dirent_cleanup__cb, &dot);
setup(&dot);
- cl_git_pass(git_path_direach(&dot.path, 0, one_entry, &dot));
+ cl_git_pass(git_fs_path_direach(&dot.path, 0, one_entry, &dot));
check_counts(&dot);
}
@@ -137,7 +137,7 @@ void test_core_dirent__traverse_subfolder(void)
cl_set_cleanup(&dirent_cleanup__cb, &sub);
setup(&sub);
- cl_git_pass(git_path_direach(&sub.path, 0, one_entry, &sub));
+ cl_git_pass(git_fs_path_direach(&sub.path, 0, one_entry, &sub));
check_counts(&sub);
}
@@ -155,7 +155,7 @@ void test_core_dirent__traverse_slash_terminated_folder(void)
cl_set_cleanup(&dirent_cleanup__cb, &sub_slash);
setup(&sub_slash);
- cl_git_pass(git_path_direach(&sub_slash.path, 0, one_entry, &sub_slash));
+ cl_git_pass(git_fs_path_direach(&sub_slash.path, 0, one_entry, &sub_slash));
check_counts(&sub_slash);
}
@@ -176,12 +176,12 @@ void test_core_dirent__dont_traverse_empty_folders(void)
cl_set_cleanup(&dirent_cleanup__cb, &empty);
setup(&empty);
- cl_git_pass(git_path_direach(&empty.path, 0, one_entry, &empty));
+ cl_git_pass(git_fs_path_direach(&empty.path, 0, one_entry, &empty));
check_counts(&empty);
/* make sure callback not called */
- cl_assert(git_path_is_empty_dir(empty.path.ptr));
+ cl_assert(git_fs_path_is_empty_dir(empty.path.ptr));
}
static name_data odd_names[] = {
@@ -204,7 +204,7 @@ void test_core_dirent__traverse_weird_filenames(void)
cl_set_cleanup(&dirent_cleanup__cb, &odd);
setup(&odd);
- cl_git_pass(git_path_direach(&odd.path, 0, one_entry, &odd));
+ cl_git_pass(git_fs_path_direach(&odd.path, 0, one_entry, &odd));
check_counts(&odd);
}
@@ -224,30 +224,30 @@ void test_core_dirent__length_limits(void)
void test_core_dirent__empty_dir(void)
{
cl_must_pass(p_mkdir("empty_dir", 0777));
- cl_assert(git_path_is_empty_dir("empty_dir"));
+ cl_assert(git_fs_path_is_empty_dir("empty_dir"));
cl_git_mkfile("empty_dir/content", "whatever\n");
- cl_assert(!git_path_is_empty_dir("empty_dir"));
- cl_assert(!git_path_is_empty_dir("empty_dir/content"));
+ cl_assert(!git_fs_path_is_empty_dir("empty_dir"));
+ cl_assert(!git_fs_path_is_empty_dir("empty_dir/content"));
cl_must_pass(p_unlink("empty_dir/content"));
cl_must_pass(p_mkdir("empty_dir/content", 0777));
- cl_assert(!git_path_is_empty_dir("empty_dir"));
- cl_assert(git_path_is_empty_dir("empty_dir/content"));
+ cl_assert(!git_fs_path_is_empty_dir("empty_dir"));
+ cl_assert(git_fs_path_is_empty_dir("empty_dir/content"));
cl_must_pass(p_rmdir("empty_dir/content"));
cl_must_pass(p_rmdir("empty_dir"));
}
-static void handle_next(git_path_diriter *diriter, walk_data *walk)
+static void handle_next(git_fs_path_diriter *diriter, walk_data *walk)
{
const char *fullpath, *filename;
size_t fullpath_len, filename_len;
- cl_git_pass(git_path_diriter_fullpath(&fullpath, &fullpath_len, diriter));
- cl_git_pass(git_path_diriter_filename(&filename, &filename_len, diriter));
+ cl_git_pass(git_fs_path_diriter_fullpath(&fullpath, &fullpath_len, diriter));
+ cl_git_pass(git_fs_path_diriter_filename(&filename, &filename_len, diriter));
cl_assert_equal_strn(fullpath, "sub/", 4);
cl_assert_equal_s(fullpath+4, filename);
@@ -258,42 +258,42 @@ static void handle_next(git_path_diriter *diriter, walk_data *walk)
/* test directory iterator */
void test_core_dirent__diriter_with_fullname(void)
{
- git_path_diriter diriter = GIT_PATH_DIRITER_INIT;
+ git_fs_path_diriter diriter = GIT_FS_PATH_DIRITER_INIT;
int error;
cl_set_cleanup(&dirent_cleanup__cb, &sub);
setup(&sub);
- cl_git_pass(git_path_diriter_init(&diriter, sub.path.ptr, 0));
+ cl_git_pass(git_fs_path_diriter_init(&diriter, sub.path.ptr, 0));
- while ((error = git_path_diriter_next(&diriter)) == 0)
+ while ((error = git_fs_path_diriter_next(&diriter)) == 0)
handle_next(&diriter, &sub);
cl_assert_equal_i(error, GIT_ITEROVER);
- git_path_diriter_free(&diriter);
+ git_fs_path_diriter_free(&diriter);
check_counts(&sub);
}
void test_core_dirent__diriter_at_directory_root(void)
{
- git_path_diriter diriter = GIT_PATH_DIRITER_INIT;
+ git_fs_path_diriter diriter = GIT_FS_PATH_DIRITER_INIT;
const char *sandbox_path, *path;
char *root_path;
size_t path_len;
int root_offset, error;
sandbox_path = clar_sandbox_path();
- cl_assert((root_offset = git_path_root(sandbox_path)) >= 0);
+ cl_assert((root_offset = git_fs_path_root(sandbox_path)) >= 0);
cl_assert(root_path = git__calloc(1, root_offset + 2));
strncpy(root_path, sandbox_path, root_offset + 1);
- cl_git_pass(git_path_diriter_init(&diriter, root_path, 0));
+ cl_git_pass(git_fs_path_diriter_init(&diriter, root_path, 0));
- while ((error = git_path_diriter_next(&diriter)) == 0) {
- cl_git_pass(git_path_diriter_fullpath(&path, &path_len, &diriter));
+ while ((error = git_fs_path_diriter_next(&diriter)) == 0) {
+ cl_git_pass(git_fs_path_diriter_fullpath(&path, &path_len, &diriter));
cl_assert(path_len > (size_t)(root_offset + 1));
cl_assert(path[root_offset+1] != '/');
@@ -301,6 +301,6 @@ void test_core_dirent__diriter_at_directory_root(void)
cl_assert_equal_i(error, GIT_ITEROVER);
- git_path_diriter_free(&diriter);
+ git_fs_path_diriter_free(&diriter);
git__free(root_path);
}
diff --git a/tests/core/env.c b/tests/core/env.c
index 9a3f0ae76..88c5c6aa3 100644
--- a/tests/core/env.c
+++ b/tests/core/env.c
@@ -103,7 +103,7 @@ void test_core_env__0(void)
continue;
}
- cl_git_pass(git_path_prettify(&path, *val, NULL));
+ cl_git_pass(git_fs_path_prettify(&path, *val, NULL));
/* vary testfile name in each directory so accidentally leaving
* an environment variable set from a previous iteration won't
@@ -137,7 +137,7 @@ void test_core_env__0(void)
cl_git_pass(git_sysdir_find_global_file(&found, testfile));
{
- int root = git_path_root(path.ptr);
+ int root = git_fs_path_root(path.ptr);
char old;
if (root >= 0) {
@@ -270,7 +270,7 @@ void test_core_env__2(void)
continue;
}
- cl_git_pass(git_path_prettify(&path, *val, NULL));
+ cl_git_pass(git_fs_path_prettify(&path, *val, NULL));
/* vary testfile name so any sloppiness is resetting variables or
* deleting files won't accidentally make a test pass.
diff --git a/tests/core/filebuf.c b/tests/core/filebuf.c
index 6f654f523..6f40c2456 100644
--- a/tests/core/filebuf.c
+++ b/tests/core/filebuf.c
@@ -14,7 +14,7 @@ void test_core_filebuf__0(void)
cl_must_pass(p_close(fd));
cl_git_fail(git_filebuf_open(&file, test, 0, 0666));
- cl_assert(git_path_exists(testlock));
+ cl_assert(git_fs_path_exists(testlock));
cl_must_pass(p_unlink(testlock));
}
@@ -142,14 +142,14 @@ void test_core_filebuf__rename_error(void)
cl_git_pass(git_filebuf_printf(&file, "%s\n", "libgit2 rocks"));
- cl_assert_equal_i(true, git_path_exists(test_lock));
+ cl_assert_equal_i(true, git_fs_path_exists(test_lock));
cl_git_fail(git_filebuf_commit(&file));
p_close(fd);
git_filebuf_cleanup(&file);
- cl_assert_equal_i(false, git_path_exists(test_lock));
+ cl_assert_equal_i(false, git_fs_path_exists(test_lock));
}
void test_core_filebuf__symlink_follow(void)
@@ -157,7 +157,7 @@ void test_core_filebuf__symlink_follow(void)
git_filebuf file = GIT_FILEBUF_INIT;
const char *dir = "linkdir", *source = "linkdir/link";
- if (!git_path_supports_symlinks(clar_sandbox_path()))
+ if (!git_fs_path_supports_symlinks(clar_sandbox_path()))
cl_skip();
cl_git_pass(p_mkdir(dir, 0777));
@@ -166,10 +166,10 @@ void test_core_filebuf__symlink_follow(void)
cl_git_pass(git_filebuf_open(&file, source, 0, 0666));
cl_git_pass(git_filebuf_printf(&file, "%s\n", "libgit2 rocks"));
- cl_assert_equal_i(true, git_path_exists("linkdir/target.lock"));
+ cl_assert_equal_i(true, git_fs_path_exists("linkdir/target.lock"));
cl_git_pass(git_filebuf_commit(&file));
- cl_assert_equal_i(true, git_path_exists("linkdir/target"));
+ cl_assert_equal_i(true, git_fs_path_exists("linkdir/target"));
git_filebuf_cleanup(&file);
@@ -177,10 +177,10 @@ void test_core_filebuf__symlink_follow(void)
cl_git_pass(git_filebuf_open(&file, source, 0, 0666));
cl_git_pass(git_filebuf_printf(&file, "%s\n", "libgit2 rocks"));
- cl_assert_equal_i(true, git_path_exists("linkdir/target.lock"));
+ cl_assert_equal_i(true, git_fs_path_exists("linkdir/target.lock"));
cl_git_pass(git_filebuf_commit(&file));
- cl_assert_equal_i(true, git_path_exists("linkdir/target"));
+ cl_assert_equal_i(true, git_fs_path_exists("linkdir/target"));
git_filebuf_cleanup(&file);
cl_git_pass(git_futils_rmdir_r(dir, NULL, GIT_RMDIR_REMOVE_FILES));
@@ -191,7 +191,7 @@ void test_core_filebuf__symlink_follow_absolute_paths(void)
git_filebuf file = GIT_FILEBUF_INIT;
git_str source = GIT_STR_INIT, target = GIT_STR_INIT;
- if (!git_path_supports_symlinks(clar_sandbox_path()))
+ if (!git_fs_path_supports_symlinks(clar_sandbox_path()))
cl_skip();
cl_git_pass(git_str_joinpath(&source, clar_sandbox_path(), "linkdir/link"));
@@ -202,10 +202,10 @@ void test_core_filebuf__symlink_follow_absolute_paths(void)
cl_git_pass(git_filebuf_open(&file, source.ptr, 0, 0666));
cl_git_pass(git_filebuf_printf(&file, "%s\n", "libgit2 rocks"));
- cl_assert_equal_i(true, git_path_exists("linkdir/target.lock"));
+ cl_assert_equal_i(true, git_fs_path_exists("linkdir/target.lock"));
cl_git_pass(git_filebuf_commit(&file));
- cl_assert_equal_i(true, git_path_exists("linkdir/target"));
+ cl_assert_equal_i(true, git_fs_path_exists("linkdir/target"));
git_filebuf_cleanup(&file);
git_str_dispose(&source);
@@ -219,7 +219,7 @@ void test_core_filebuf__symlink_depth(void)
git_filebuf file = GIT_FILEBUF_INIT;
const char *dir = "linkdir", *source = "linkdir/link";
- if (!git_path_supports_symlinks(clar_sandbox_path()))
+ if (!git_fs_path_supports_symlinks(clar_sandbox_path()))
cl_skip();
cl_git_pass(p_mkdir(dir, 0777));
diff --git a/tests/core/futils.c b/tests/core/futils.c
index d08043b6e..b87ea183b 100644
--- a/tests/core/futils.c
+++ b/tests/core/futils.c
@@ -68,7 +68,7 @@ void test_core_futils__write_hidden_file(void)
void test_core_futils__recursive_rmdir_keeps_symlink_targets(void)
{
- if (!git_path_supports_symlinks(clar_sandbox_path()))
+ if (!git_fs_path_supports_symlinks(clar_sandbox_path()))
cl_skip();
cl_git_pass(git_futils_mkdir_r("a/b", 0777));
@@ -80,8 +80,8 @@ void test_core_futils__recursive_rmdir_keeps_symlink_targets(void)
cl_git_pass(git_futils_rmdir_r("a", NULL, GIT_RMDIR_REMOVE_FILES));
- cl_assert(git_path_exists("dir-target"));
- cl_assert(git_path_exists("file-target"));
+ cl_assert(git_fs_path_exists("dir-target"));
+ cl_assert(git_fs_path_exists("file-target"));
cl_must_pass(p_unlink("dir-target/file"));
cl_must_pass(p_rmdir("dir-target"));
diff --git a/tests/core/iconv.c b/tests/core/iconv.c
index 498094bdb..af1b4eabf 100644
--- a/tests/core/iconv.c
+++ b/tests/core/iconv.c
@@ -1,8 +1,8 @@
#include "clar_libgit2.h"
-#include "path.h"
+#include "fs_path.h"
#ifdef GIT_USE_ICONV
-static git_path_iconv_t ic;
+static git_fs_path_iconv_t ic;
static char *nfc = "\xC3\x85\x73\x74\x72\xC3\xB6\x6D";
static char *nfd = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D";
#endif
@@ -10,14 +10,14 @@ static char *nfd = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D";
void test_core_iconv__initialize(void)
{
#ifdef GIT_USE_ICONV
- cl_git_pass(git_path_iconv_init_precompose(&ic));
+ cl_git_pass(git_fs_path_iconv_init_precompose(&ic));
#endif
}
void test_core_iconv__cleanup(void)
{
#ifdef GIT_USE_ICONV
- git_path_iconv_clear(&ic);
+ git_fs_path_iconv_clear(&ic);
#endif
}
@@ -27,7 +27,7 @@ void test_core_iconv__unchanged(void)
const char *data = "Ascii data", *original = data;
size_t datalen = strlen(data);
- cl_git_pass(git_path_iconv(&ic, &data, &datalen));
+ cl_git_pass(git_fs_path_iconv(&ic, &data, &datalen));
GIT_UNUSED(datalen);
/* There are no high bits set, so this should leave data untouched */
@@ -42,7 +42,7 @@ void test_core_iconv__decomposed_to_precomposed(void)
size_t datalen, nfdlen = strlen(nfd);
datalen = nfdlen;
- cl_git_pass(git_path_iconv(&ic, &data, &datalen));
+ cl_git_pass(git_fs_path_iconv(&ic, &data, &datalen));
GIT_UNUSED(datalen);
/* The decomposed nfd string should be transformed to the nfc form
@@ -50,13 +50,13 @@ void test_core_iconv__decomposed_to_precomposed(void)
*/
cl_assert_equal_s(nfc, data);
- /* should be able to do it multiple times with the same git_path_iconv_t */
+ /* should be able to do it multiple times with the same git_fs_path_iconv_t */
data = nfd; datalen = nfdlen;
- cl_git_pass(git_path_iconv(&ic, &data, &datalen));
+ cl_git_pass(git_fs_path_iconv(&ic, &data, &datalen));
cl_assert_equal_s(nfc, data);
data = nfd; datalen = nfdlen;
- cl_git_pass(git_path_iconv(&ic, &data, &datalen));
+ cl_git_pass(git_fs_path_iconv(&ic, &data, &datalen));
cl_assert_equal_s(nfc, data);
#endif
}
@@ -67,7 +67,7 @@ void test_core_iconv__precomposed_is_unmodified(void)
const char *data = nfc;
size_t datalen = strlen(nfc);
- cl_git_pass(git_path_iconv(&ic, &data, &datalen));
+ cl_git_pass(git_fs_path_iconv(&ic, &data, &datalen));
GIT_UNUSED(datalen);
/* data is already in precomposed form, so even though some bytes have
diff --git a/tests/core/init.c b/tests/core/init.c
index a8cbd930b..eba77ef52 100644
--- a/tests/core/init.c
+++ b/tests/core/init.c
@@ -2,7 +2,7 @@
void test_core_init__returns_count(void)
{
- /* libgit2_clar initializes us first, so we have an existing
+ /* libgit2_tests initializes us first, so we have an existing
* initialization.
*/
cl_assert_equal_i(2, git_libgit2_init());
diff --git a/tests/core/mkdir.c b/tests/core/mkdir.c
index f0461ac1f..8d4b9afd6 100644
--- a/tests/core/mkdir.c
+++ b/tests/core/mkdir.c
@@ -22,32 +22,32 @@ void test_core_mkdir__absolute(void)
git_str_joinpath(&path, clar_sandbox_path(), "d0");
/* make a directory */
- cl_assert(!git_path_isdir(path.ptr));
+ cl_assert(!git_fs_path_isdir(path.ptr));
cl_git_pass(git_futils_mkdir(path.ptr, 0755, 0));
- cl_assert(git_path_isdir(path.ptr));
+ cl_assert(git_fs_path_isdir(path.ptr));
git_str_joinpath(&path, path.ptr, "subdir");
- cl_assert(!git_path_isdir(path.ptr));
+ cl_assert(!git_fs_path_isdir(path.ptr));
cl_git_pass(git_futils_mkdir(path.ptr, 0755, 0));
- cl_assert(git_path_isdir(path.ptr));
+ cl_assert(git_fs_path_isdir(path.ptr));
/* ensure mkdir_r works for a single subdir */
git_str_joinpath(&path, path.ptr, "another");
- cl_assert(!git_path_isdir(path.ptr));
+ cl_assert(!git_fs_path_isdir(path.ptr));
cl_git_pass(git_futils_mkdir_r(path.ptr, 0755));
- cl_assert(git_path_isdir(path.ptr));
+ cl_assert(git_fs_path_isdir(path.ptr));
/* ensure mkdir_r works */
git_str_joinpath(&path, clar_sandbox_path(), "d1/foo/bar/asdf");
- cl_assert(!git_path_isdir(path.ptr));
+ cl_assert(!git_fs_path_isdir(path.ptr));
cl_git_pass(git_futils_mkdir_r(path.ptr, 0755));
- cl_assert(git_path_isdir(path.ptr));
+ cl_assert(git_fs_path_isdir(path.ptr));
/* ensure we don't imply recursive */
git_str_joinpath(&path, clar_sandbox_path(), "d2/foo/bar/asdf");
- cl_assert(!git_path_isdir(path.ptr));
+ cl_assert(!git_fs_path_isdir(path.ptr));
cl_git_fail(git_futils_mkdir(path.ptr, 0755, 0));
- cl_assert(!git_path_isdir(path.ptr));
+ cl_assert(!git_fs_path_isdir(path.ptr));
git_str_dispose(&path);
}
@@ -57,39 +57,39 @@ void test_core_mkdir__basic(void)
cl_set_cleanup(cleanup_basic_dirs, NULL);
/* make a directory */
- cl_assert(!git_path_isdir("d0"));
+ cl_assert(!git_fs_path_isdir("d0"));
cl_git_pass(git_futils_mkdir("d0", 0755, 0));
- cl_assert(git_path_isdir("d0"));
+ cl_assert(git_fs_path_isdir("d0"));
/* make a path */
- cl_assert(!git_path_isdir("d1"));
+ cl_assert(!git_fs_path_isdir("d1"));
cl_git_pass(git_futils_mkdir("d1/d1.1/d1.2", 0755, GIT_MKDIR_PATH));
- cl_assert(git_path_isdir("d1"));
- cl_assert(git_path_isdir("d1/d1.1"));
- cl_assert(git_path_isdir("d1/d1.1/d1.2"));
+ cl_assert(git_fs_path_isdir("d1"));
+ cl_assert(git_fs_path_isdir("d1/d1.1"));
+ cl_assert(git_fs_path_isdir("d1/d1.1/d1.2"));
/* make a dir exclusively */
- cl_assert(!git_path_isdir("d2"));
+ cl_assert(!git_fs_path_isdir("d2"));
cl_git_pass(git_futils_mkdir("d2", 0755, GIT_MKDIR_EXCL));
- cl_assert(git_path_isdir("d2"));
+ cl_assert(git_fs_path_isdir("d2"));
/* make exclusive failure */
cl_git_fail(git_futils_mkdir("d2", 0755, GIT_MKDIR_EXCL));
/* make a path exclusively */
- cl_assert(!git_path_isdir("d3"));
+ cl_assert(!git_fs_path_isdir("d3"));
cl_git_pass(git_futils_mkdir("d3/d3.1/d3.2", 0755, GIT_MKDIR_PATH | GIT_MKDIR_EXCL));
- cl_assert(git_path_isdir("d3"));
- cl_assert(git_path_isdir("d3/d3.1/d3.2"));
+ cl_assert(git_fs_path_isdir("d3"));
+ cl_assert(git_fs_path_isdir("d3/d3.1/d3.2"));
/* make exclusive path failure */
cl_git_fail(git_futils_mkdir("d3/d3.1/d3.2", 0755, GIT_MKDIR_PATH | GIT_MKDIR_EXCL));
/* ??? Should EXCL only apply to the last item in the path? */
/* path with trailing slash? */
- cl_assert(!git_path_isdir("d4"));
+ cl_assert(!git_fs_path_isdir("d4"));
cl_git_pass(git_futils_mkdir("d4/d4.1/", 0755, GIT_MKDIR_PATH));
- cl_assert(git_path_isdir("d4/d4.1"));
+ cl_assert(git_fs_path_isdir("d4/d4.1"));
}
static void cleanup_basedir(void *ref)
@@ -107,10 +107,10 @@ void test_core_mkdir__with_base(void)
cl_git_pass(git_futils_mkdir(BASEDIR, 0755, GIT_MKDIR_PATH));
cl_git_pass(git_futils_mkdir_relative("a", BASEDIR, 0755, 0, NULL));
- cl_assert(git_path_isdir(BASEDIR "/a"));
+ cl_assert(git_fs_path_isdir(BASEDIR "/a"));
cl_git_pass(git_futils_mkdir_relative("b/b1/b2", BASEDIR, 0755, GIT_MKDIR_PATH, NULL));
- cl_assert(git_path_isdir(BASEDIR "/b/b1/b2"));
+ cl_assert(git_fs_path_isdir(BASEDIR "/b/b1/b2"));
/* exclusive with existing base */
cl_git_pass(git_futils_mkdir_relative("c/c1/c2", BASEDIR, 0755, GIT_MKDIR_PATH | GIT_MKDIR_EXCL, NULL));
@@ -126,7 +126,7 @@ void test_core_mkdir__with_base(void)
/* path with shorter base and existing dirs */
cl_git_pass(git_futils_mkdir_relative("dir/here/d/", "base", 0755, GIT_MKDIR_PATH, NULL));
- cl_assert(git_path_isdir("base/dir/here/d"));
+ cl_assert(git_fs_path_isdir("base/dir/here/d"));
/* fail: path with shorter base and existing dirs */
cl_git_fail(git_futils_mkdir_relative("dir/here/e/", "base", 0755, GIT_MKDIR_PATH | GIT_MKDIR_EXCL, NULL));
@@ -179,51 +179,51 @@ void test_core_mkdir__chmods(void)
cl_git_pass(git_futils_mkdir_relative("mode/is/important", "r", 0777, GIT_MKDIR_PATH, NULL));
- cl_git_pass(git_path_lstat("r/mode", &st));
+ cl_git_pass(git_fs_path_lstat("r/mode", &st));
check_mode(0755, st.st_mode);
- cl_git_pass(git_path_lstat("r/mode/is", &st));
+ cl_git_pass(git_fs_path_lstat("r/mode/is", &st));
check_mode(0755, st.st_mode);
- cl_git_pass(git_path_lstat("r/mode/is/important", &st));
+ cl_git_pass(git_fs_path_lstat("r/mode/is/important", &st));
check_mode(0755, st.st_mode);
cl_git_pass(git_futils_mkdir_relative("mode2/is2/important2", "r", 0777, GIT_MKDIR_PATH | GIT_MKDIR_CHMOD, NULL));
- cl_git_pass(git_path_lstat("r/mode2", &st));
+ cl_git_pass(git_fs_path_lstat("r/mode2", &st));
check_mode(0755, st.st_mode);
- cl_git_pass(git_path_lstat("r/mode2/is2", &st));
+ cl_git_pass(git_fs_path_lstat("r/mode2/is2", &st));
check_mode(0755, st.st_mode);
- cl_git_pass(git_path_lstat("r/mode2/is2/important2", &st));
+ cl_git_pass(git_fs_path_lstat("r/mode2/is2/important2", &st));
check_mode(0777, st.st_mode);
cl_git_pass(git_futils_mkdir_relative("mode3/is3/important3", "r", 0777, GIT_MKDIR_PATH | GIT_MKDIR_CHMOD_PATH, NULL));
- cl_git_pass(git_path_lstat("r/mode3", &st));
+ cl_git_pass(git_fs_path_lstat("r/mode3", &st));
check_mode(0777, st.st_mode);
- cl_git_pass(git_path_lstat("r/mode3/is3", &st));
+ cl_git_pass(git_fs_path_lstat("r/mode3/is3", &st));
check_mode(0777, st.st_mode);
- cl_git_pass(git_path_lstat("r/mode3/is3/important3", &st));
+ cl_git_pass(git_fs_path_lstat("r/mode3/is3/important3", &st));
check_mode(0777, st.st_mode);
/* test that we chmod existing dir */
cl_git_pass(git_futils_mkdir_relative("mode/is/important", "r", 0777, GIT_MKDIR_PATH | GIT_MKDIR_CHMOD, NULL));
- cl_git_pass(git_path_lstat("r/mode", &st));
+ cl_git_pass(git_fs_path_lstat("r/mode", &st));
check_mode(0755, st.st_mode);
- cl_git_pass(git_path_lstat("r/mode/is", &st));
+ cl_git_pass(git_fs_path_lstat("r/mode/is", &st));
check_mode(0755, st.st_mode);
- cl_git_pass(git_path_lstat("r/mode/is/important", &st));
+ cl_git_pass(git_fs_path_lstat("r/mode/is/important", &st));
check_mode(0777, st.st_mode);
/* test that we chmod even existing dirs if CHMOD_PATH is set */
cl_git_pass(git_futils_mkdir_relative("mode2/is2/important2.1", "r", 0777, GIT_MKDIR_PATH | GIT_MKDIR_CHMOD_PATH, NULL));
- cl_git_pass(git_path_lstat("r/mode2", &st));
+ cl_git_pass(git_fs_path_lstat("r/mode2", &st));
check_mode(0777, st.st_mode);
- cl_git_pass(git_path_lstat("r/mode2/is2", &st));
+ cl_git_pass(git_fs_path_lstat("r/mode2/is2", &st));
check_mode(0777, st.st_mode);
- cl_git_pass(git_path_lstat("r/mode2/is2/important2.1", &st));
+ cl_git_pass(git_fs_path_lstat("r/mode2/is2/important2.1", &st));
check_mode(0777, st.st_mode);
}
@@ -235,27 +235,27 @@ void test_core_mkdir__keeps_parent_symlinks(void)
cl_set_cleanup(cleanup_basic_dirs, NULL);
/* make a directory */
- cl_assert(!git_path_isdir("d0"));
+ cl_assert(!git_fs_path_isdir("d0"));
cl_git_pass(git_futils_mkdir("d0", 0755, 0));
- cl_assert(git_path_isdir("d0"));
+ cl_assert(git_fs_path_isdir("d0"));
cl_must_pass(symlink("d0", "d1"));
- cl_assert(git_path_islink("d1"));
+ cl_assert(git_fs_path_islink("d1"));
cl_git_pass(git_futils_mkdir("d1/foo/bar", 0755, GIT_MKDIR_PATH|GIT_MKDIR_REMOVE_SYMLINKS));
- cl_assert(git_path_islink("d1"));
- cl_assert(git_path_isdir("d1/foo/bar"));
- cl_assert(git_path_isdir("d0/foo/bar"));
+ cl_assert(git_fs_path_islink("d1"));
+ cl_assert(git_fs_path_isdir("d1/foo/bar"));
+ cl_assert(git_fs_path_isdir("d0/foo/bar"));
cl_must_pass(symlink("d0", "d2"));
- cl_assert(git_path_islink("d2"));
+ cl_assert(git_fs_path_islink("d2"));
git_str_joinpath(&path, clar_sandbox_path(), "d2/other/dir");
cl_git_pass(git_futils_mkdir(path.ptr, 0755, GIT_MKDIR_PATH|GIT_MKDIR_REMOVE_SYMLINKS));
- cl_assert(git_path_islink("d2"));
- cl_assert(git_path_isdir("d2/other/dir"));
- cl_assert(git_path_isdir("d0/other/dir"));
+ cl_assert(git_fs_path_islink("d2"));
+ cl_assert(git_fs_path_isdir("d2/other/dir"));
+ cl_assert(git_fs_path_isdir("d0/other/dir"));
git_str_dispose(&path);
#endif
@@ -276,16 +276,16 @@ void test_core_mkdir__mkdir_path_inside_unwriteable_parent(void)
cl_git_pass(git_futils_mkdir("r", 0777, 0));
cl_git_pass(git_futils_mkdir_relative("mode/is/important", "r", 0777, GIT_MKDIR_PATH, NULL));
- cl_git_pass(git_path_lstat("r/mode", &st));
+ cl_git_pass(git_fs_path_lstat("r/mode", &st));
check_mode(0755, st.st_mode);
cl_must_pass(p_chmod("r/mode", 0111));
- cl_git_pass(git_path_lstat("r/mode", &st));
+ cl_git_pass(git_fs_path_lstat("r/mode", &st));
check_mode(0111, st.st_mode);
cl_git_pass(
git_futils_mkdir_relative("mode/is/okay/inside", "r", 0777, GIT_MKDIR_PATH, NULL));
- cl_git_pass(git_path_lstat("r/mode/is/okay/inside", &st));
+ cl_git_pass(git_fs_path_lstat("r/mode/is/okay/inside", &st));
check_mode(0755, st.st_mode);
cl_must_pass(p_chmod("r/mode", 0777));
diff --git a/tests/core/path.c b/tests/core/path.c
index 6decf23ea..563dcd2a3 100644
--- a/tests/core/path.c
+++ b/tests/core/path.c
@@ -1,5 +1,6 @@
#include "clar_libgit2.h"
#include "futils.h"
+#include "fs_path.h"
static void
check_dirname(const char *A, const char *B)
@@ -7,11 +8,11 @@ check_dirname(const char *A, const char *B)
git_str dir = GIT_STR_INIT;
char *dir2;
- cl_assert(git_path_dirname_r(&dir, A) >= 0);
+ cl_assert(git_fs_path_dirname_r(&dir, A) >= 0);
cl_assert_equal_s(B, dir.ptr);
git_str_dispose(&dir);
- cl_assert((dir2 = git_path_dirname(A)) != NULL);
+ cl_assert((dir2 = git_fs_path_dirname(A)) != NULL);
cl_assert_equal_s(B, dir2);
git__free(dir2);
}
@@ -22,11 +23,11 @@ check_basename(const char *A, const char *B)
git_str base = GIT_STR_INIT;
char *base2;
- cl_assert(git_path_basename_r(&base, A) >= 0);
+ cl_assert(git_fs_path_basename_r(&base, A) >= 0);
cl_assert_equal_s(B, base.ptr);
git_str_dispose(&base);
- cl_assert((base2 = git_path_basename(A)) != NULL);
+ cl_assert((base2 = git_fs_path_basename(A)) != NULL);
cl_assert_equal_s(B, base2);
git__free(base2);
}
@@ -175,7 +176,7 @@ check_path_to_dir(
git_str tgt = GIT_STR_INIT;
git_str_sets(&tgt, path);
- cl_git_pass(git_path_to_dir(&tgt));
+ cl_git_pass(git_fs_path_to_dir(&tgt));
cl_assert_equal_s(expected, tgt.ptr);
git_str_dispose(&tgt);
@@ -193,7 +194,7 @@ check_string_to_dir(
strncpy(buf, path, len + 2);
- git_path_string_to_dir(buf, maxlen);
+ git_fs_path_string_to_dir(buf, maxlen);
cl_assert_equal_s(expected, buf);
@@ -294,10 +295,10 @@ static void check_fromurl(const char *expected_result, const char *input, int sh
assert(should_fail || expected_result);
if (!should_fail) {
- cl_git_pass(git_path_fromurl(&buf, input));
+ cl_git_pass(git_fs_path_fromurl(&buf, input));
cl_assert_equal_s(expected_result, git_str_cstr(&buf));
} else
- cl_git_fail(git_path_fromurl(&buf, input));
+ cl_git_fail(git_fs_path_fromurl(&buf, input));
git_str_dispose(&buf);
}
@@ -402,7 +403,7 @@ void test_core_path__11_walkup(void)
info.expect_idx = i;
cl_git_pass(
- git_path_walk_up(&p, root[j], check_one_walkup_step, &info)
+ git_fs_path_walk_up(&p, root[j], check_one_walkup_step, &info)
);
cl_assert_equal_s(p.ptr, expect[i]);
@@ -439,7 +440,7 @@ void test_core_path__11a_walkup_cancel(void)
cl_assert_equal_i(
CANCEL_VALUE,
- git_path_walk_up(&p, root[j], check_one_walkup_step, &info)
+ git_fs_path_walk_up(&p, root[j], check_one_walkup_step, &info)
);
/* skip to next run of expectations */
@@ -451,16 +452,16 @@ void test_core_path__11a_walkup_cancel(void)
void test_core_path__12_offset_to_path_root(void)
{
- cl_assert(git_path_root("non/rooted/path") == -1);
- cl_assert(git_path_root("/rooted/path") == 0);
+ cl_assert(git_fs_path_root("non/rooted/path") == -1);
+ cl_assert(git_fs_path_root("/rooted/path") == 0);
#ifdef GIT_WIN32
/* Windows specific tests */
- cl_assert(git_path_root("C:non/rooted/path") == -1);
- cl_assert(git_path_root("C:/rooted/path") == 2);
- cl_assert(git_path_root("//computername/sharefolder/resource") == 14);
- cl_assert(git_path_root("//computername/sharefolder") == 14);
- cl_assert(git_path_root("//computername") == -1);
+ cl_assert(git_fs_path_root("C:non/rooted/path") == -1);
+ cl_assert(git_fs_path_root("C:/rooted/path") == 2);
+ cl_assert(git_fs_path_root("//computername/sharefolder/resource") == 14);
+ cl_assert(git_fs_path_root("//computername/sharefolder") == 14);
+ cl_assert(git_fs_path_root("//computername") == -1);
#endif
}
@@ -470,9 +471,9 @@ void test_core_path__13_cannot_prettify_a_non_existing_file(void)
{
git_str p = GIT_STR_INIT;
- cl_assert_equal_b(git_path_exists(NON_EXISTING_FILEPATH), false);
- cl_assert_equal_i(GIT_ENOTFOUND, git_path_prettify(&p, NON_EXISTING_FILEPATH, NULL));
- cl_assert_equal_i(GIT_ENOTFOUND, git_path_prettify(&p, NON_EXISTING_FILEPATH "/so-do-i", NULL));
+ cl_assert_equal_b(git_fs_path_exists(NON_EXISTING_FILEPATH), false);
+ cl_assert_equal_i(GIT_ENOTFOUND, git_fs_path_prettify(&p, NON_EXISTING_FILEPATH, NULL));
+ cl_assert_equal_i(GIT_ENOTFOUND, git_fs_path_prettify(&p, NON_EXISTING_FILEPATH "/so-do-i", NULL));
git_str_dispose(&p);
}
@@ -483,57 +484,57 @@ void test_core_path__14_apply_relative(void)
cl_git_pass(git_str_sets(&p, "/this/is/a/base"));
- cl_git_pass(git_path_apply_relative(&p, "../test"));
+ cl_git_pass(git_fs_path_apply_relative(&p, "../test"));
cl_assert_equal_s("/this/is/a/test", p.ptr);
- cl_git_pass(git_path_apply_relative(&p, "../../the/./end"));
+ cl_git_pass(git_fs_path_apply_relative(&p, "../../the/./end"));
cl_assert_equal_s("/this/is/the/end", p.ptr);
- cl_git_pass(git_path_apply_relative(&p, "./of/this/../the/string"));
+ cl_git_pass(git_fs_path_apply_relative(&p, "./of/this/../the/string"));
cl_assert_equal_s("/this/is/the/end/of/the/string", p.ptr);
- cl_git_pass(git_path_apply_relative(&p, "../../../../../.."));
+ cl_git_pass(git_fs_path_apply_relative(&p, "../../../../../.."));
cl_assert_equal_s("/this/", p.ptr);
- cl_git_pass(git_path_apply_relative(&p, "../"));
+ cl_git_pass(git_fs_path_apply_relative(&p, "../"));
cl_assert_equal_s("/", p.ptr);
- cl_git_fail(git_path_apply_relative(&p, "../../.."));
+ cl_git_fail(git_fs_path_apply_relative(&p, "../../.."));
cl_git_pass(git_str_sets(&p, "d:/another/test"));
- cl_git_pass(git_path_apply_relative(&p, "../.."));
+ cl_git_pass(git_fs_path_apply_relative(&p, "../.."));
cl_assert_equal_s("d:/", p.ptr);
- cl_git_pass(git_path_apply_relative(&p, "from/here/to/../and/./back/."));
+ cl_git_pass(git_fs_path_apply_relative(&p, "from/here/to/../and/./back/."));
cl_assert_equal_s("d:/from/here/and/back/", p.ptr);
cl_git_pass(git_str_sets(&p, "https://my.url.com/test.git"));
- cl_git_pass(git_path_apply_relative(&p, "../another.git"));
+ cl_git_pass(git_fs_path_apply_relative(&p, "../another.git"));
cl_assert_equal_s("https://my.url.com/another.git", p.ptr);
- cl_git_pass(git_path_apply_relative(&p, "../full/path/url.patch"));
+ cl_git_pass(git_fs_path_apply_relative(&p, "../full/path/url.patch"));
cl_assert_equal_s("https://my.url.com/full/path/url.patch", p.ptr);
- cl_git_pass(git_path_apply_relative(&p, ".."));
+ cl_git_pass(git_fs_path_apply_relative(&p, ".."));
cl_assert_equal_s("https://my.url.com/full/path/", p.ptr);
- cl_git_pass(git_path_apply_relative(&p, "../../../"));
+ cl_git_pass(git_fs_path_apply_relative(&p, "../../../"));
cl_assert_equal_s("https://", p.ptr);
cl_git_pass(git_str_sets(&p, "../../this/is/relative"));
- cl_git_pass(git_path_apply_relative(&p, "../../preserves/the/prefix"));
+ cl_git_pass(git_fs_path_apply_relative(&p, "../../preserves/the/prefix"));
cl_assert_equal_s("../../this/preserves/the/prefix", p.ptr);
- cl_git_pass(git_path_apply_relative(&p, "../../../../that"));
+ cl_git_pass(git_fs_path_apply_relative(&p, "../../../../that"));
cl_assert_equal_s("../../that", p.ptr);
- cl_git_pass(git_path_apply_relative(&p, "../there"));
+ cl_git_pass(git_fs_path_apply_relative(&p, "../there"));
cl_assert_equal_s("../../there", p.ptr);
git_str_dispose(&p);
}
@@ -542,7 +543,7 @@ static void assert_resolve_relative(
git_str *buf, const char *expected, const char *path)
{
cl_git_pass(git_str_sets(buf, path));
- cl_git_pass(git_path_resolve_relative(buf, 0));
+ cl_git_pass(git_fs_path_resolve_relative(buf, 0));
cl_assert_equal_s(expected, buf->ptr);
}
@@ -596,22 +597,22 @@ void test_core_path__15_resolve_relative(void)
assert_resolve_relative(&buf, "../d", "a/b/../../../c/../d");
cl_git_pass(git_str_sets(&buf, "/.."));
- cl_git_fail(git_path_resolve_relative(&buf, 0));
+ cl_git_fail(git_fs_path_resolve_relative(&buf, 0));
cl_git_pass(git_str_sets(&buf, "/./.."));
- cl_git_fail(git_path_resolve_relative(&buf, 0));
+ cl_git_fail(git_fs_path_resolve_relative(&buf, 0));
cl_git_pass(git_str_sets(&buf, "/.//.."));
- cl_git_fail(git_path_resolve_relative(&buf, 0));
+ cl_git_fail(git_fs_path_resolve_relative(&buf, 0));
cl_git_pass(git_str_sets(&buf, "/../."));
- cl_git_fail(git_path_resolve_relative(&buf, 0));
+ cl_git_fail(git_fs_path_resolve_relative(&buf, 0));
cl_git_pass(git_str_sets(&buf, "/../.././../a"));
- cl_git_fail(git_path_resolve_relative(&buf, 0));
+ cl_git_fail(git_fs_path_resolve_relative(&buf, 0));
cl_git_pass(git_str_sets(&buf, "////.."));
- cl_git_fail(git_path_resolve_relative(&buf, 0));
+ cl_git_fail(git_fs_path_resolve_relative(&buf, 0));
/* things that start with Windows network paths */
#ifdef GIT_WIN32
@@ -620,7 +621,7 @@ void test_core_path__15_resolve_relative(void)
assert_resolve_relative(&buf, "//a/b/c", "//a/Q/../b/x/y/../../c");
cl_git_pass(git_str_sets(&buf, "//a/b/../.."));
- cl_git_fail(git_path_resolve_relative(&buf, 0));
+ cl_git_fail(git_fs_path_resolve_relative(&buf, 0));
#else
assert_resolve_relative(&buf, "/a/b/c", "//a/b/c");
assert_resolve_relative(&buf, "/a/", "//a/b/..");
@@ -632,7 +633,7 @@ void test_core_path__15_resolve_relative(void)
}
#define assert_common_dirlen(i, p, q) \
- cl_assert_equal_i((i), git_path_common_dirlen((p), (q)));
+ cl_assert_equal_i((i), git_fs_path_common_dirlen((p), (q)));
void test_core_path__16_resolve_relative(void)
{
@@ -650,12 +651,3 @@ void test_core_path__16_resolve_relative(void)
assert_common_dirlen(6, "a/b/c/foo.txt", "a/b/c/d/e/bar.txt");
assert_common_dirlen(7, "/a/b/c/foo.txt", "/a/b/c/d/e/bar.txt");
}
-
-void test_core_path__git_path_is_file(void)
-{
- cl_git_fail(git_path_is_gitfile("blob", 4, -1, GIT_PATH_FS_HFS));
- cl_git_pass(git_path_is_gitfile("blob", 4, GIT_PATH_GITFILE_GITIGNORE, GIT_PATH_FS_HFS));
- cl_git_pass(git_path_is_gitfile("blob", 4, GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_HFS));
- cl_git_pass(git_path_is_gitfile("blob", 4, GIT_PATH_GITFILE_GITATTRIBUTES, GIT_PATH_FS_HFS));
- cl_git_fail(git_path_is_gitfile("blob", 4, 3, GIT_PATH_FS_HFS));
-}
diff --git a/tests/core/posix.c b/tests/core/posix.c
index 247bd43f5..cba312913 100644
--- a/tests/core/posix.c
+++ b/tests/core/posix.c
@@ -147,7 +147,7 @@ void test_core_posix__utimes(void)
void test_core_posix__unlink_removes_symlink(void)
{
- if (!git_path_supports_symlinks(clar_sandbox_path()))
+ if (!git_fs_path_supports_symlinks(clar_sandbox_path()))
clar__skip();
cl_git_mkfile("file", "Dummy file.");
@@ -159,8 +159,8 @@ void test_core_posix__unlink_removes_symlink(void)
cl_must_pass(p_unlink("file-symlink"));
cl_must_pass(p_unlink("dir-symlink"));
- cl_assert(git_path_exists("file"));
- cl_assert(git_path_exists("dir"));
+ cl_assert(git_fs_path_exists("file"));
+ cl_assert(git_fs_path_exists("dir"));
cl_must_pass(p_unlink("file"));
cl_must_pass(p_rmdir("dir"));
@@ -170,7 +170,7 @@ void test_core_posix__symlink_resolves_to_correct_type(void)
{
git_str contents = GIT_STR_INIT;
- if (!git_path_supports_symlinks(clar_sandbox_path()))
+ if (!git_fs_path_supports_symlinks(clar_sandbox_path()))
clar__skip();
cl_must_pass(git_futils_mkdir("dir", 0777, 0));
@@ -194,7 +194,7 @@ void test_core_posix__relative_symlink(void)
{
git_str contents = GIT_STR_INIT;
- if (!git_path_supports_symlinks(clar_sandbox_path()))
+ if (!git_fs_path_supports_symlinks(clar_sandbox_path()))
clar__skip();
cl_must_pass(git_futils_mkdir("dir", 0777, 0));
@@ -214,7 +214,7 @@ void test_core_posix__symlink_to_file_across_dirs(void)
{
git_str contents = GIT_STR_INIT;
- if (!git_path_supports_symlinks(clar_sandbox_path()))
+ if (!git_fs_path_supports_symlinks(clar_sandbox_path()))
clar__skip();
/*
diff --git a/tests/core/rmdir.c b/tests/core/rmdir.c
index 56ea320be..8e5bd5878 100644
--- a/tests/core/rmdir.c
+++ b/tests/core/rmdir.c
@@ -29,7 +29,7 @@ void test_core_rmdir__initialize(void)
void test_core_rmdir__cleanup(void)
{
- if (git_path_exists(empty_tmp_dir))
+ if (git_fs_path_exists(empty_tmp_dir))
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_REMOVE_FILES));
}
@@ -38,11 +38,11 @@ void test_core_rmdir__delete_recursive(void)
{
git_str path = GIT_STR_INIT;
cl_git_pass(git_str_joinpath(&path, empty_tmp_dir, "/one"));
- cl_assert(git_path_exists(git_str_cstr(&path)));
+ cl_assert(git_fs_path_exists(git_str_cstr(&path)));
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_EMPTY_HIERARCHY));
- cl_assert(!git_path_exists(git_str_cstr(&path)));
+ cl_assert(!git_fs_path_exists(git_str_cstr(&path)));
git_str_dispose(&path);
}
@@ -61,7 +61,7 @@ void test_core_rmdir__fail_to_delete_non_empty_dir(void)
cl_must_pass(p_unlink(file.ptr));
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_EMPTY_HIERARCHY));
- cl_assert(!git_path_exists(empty_tmp_dir));
+ cl_assert(!git_fs_path_exists(empty_tmp_dir));
git_str_dispose(&file);
}
@@ -69,7 +69,7 @@ void test_core_rmdir__fail_to_delete_non_empty_dir(void)
void test_core_rmdir__keep_base(void)
{
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_SKIP_ROOT));
- cl_assert(git_path_exists(empty_tmp_dir));
+ cl_assert(git_fs_path_exists(empty_tmp_dir));
}
void test_core_rmdir__can_skip_non_empty_dir(void)
@@ -81,10 +81,10 @@ void test_core_rmdir__can_skip_non_empty_dir(void)
cl_git_mkfile(git_str_cstr(&file), "dummy");
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_SKIP_NONEMPTY));
- cl_assert(git_path_exists(git_str_cstr(&file)) == true);
+ cl_assert(git_fs_path_exists(git_str_cstr(&file)) == true);
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_REMOVE_FILES));
- cl_assert(git_path_exists(empty_tmp_dir) == false);
+ cl_assert(git_fs_path_exists(empty_tmp_dir) == false);
git_str_dispose(&file);
}
@@ -96,23 +96,23 @@ void test_core_rmdir__can_remove_empty_parents(void)
cl_git_pass(
git_str_joinpath(&file, empty_tmp_dir, "/one/two_two/three/file.txt"));
cl_git_mkfile(git_str_cstr(&file), "dummy");
- cl_assert(git_path_isfile(git_str_cstr(&file)));
+ cl_assert(git_fs_path_isfile(git_str_cstr(&file)));
cl_git_pass(git_futils_rmdir_r("one/two_two/three/file.txt", empty_tmp_dir,
GIT_RMDIR_REMOVE_FILES | GIT_RMDIR_EMPTY_PARENTS));
- cl_assert(!git_path_exists(git_str_cstr(&file)));
+ cl_assert(!git_fs_path_exists(git_str_cstr(&file)));
git_str_rtruncate_at_char(&file, '/'); /* three (only contained file.txt) */
- cl_assert(!git_path_exists(git_str_cstr(&file)));
+ cl_assert(!git_fs_path_exists(git_str_cstr(&file)));
git_str_rtruncate_at_char(&file, '/'); /* two_two (only contained three) */
- cl_assert(!git_path_exists(git_str_cstr(&file)));
+ cl_assert(!git_fs_path_exists(git_str_cstr(&file)));
git_str_rtruncate_at_char(&file, '/'); /* one (contained two_one also) */
- cl_assert(git_path_exists(git_str_cstr(&file)));
+ cl_assert(git_fs_path_exists(git_str_cstr(&file)));
- cl_assert(git_path_exists(empty_tmp_dir) == true);
+ cl_assert(git_fs_path_exists(empty_tmp_dir) == true);
git_str_dispose(&file);
diff --git a/tests/core/stat.c b/tests/core/stat.c
index 56d141e98..022380ba6 100644
--- a/tests/core/stat.c
+++ b/tests/core/stat.c
@@ -102,7 +102,7 @@ void test_core_stat__root(void)
int root_len;
struct stat st;
- root_len = git_path_root(sandbox);
+ root_len = git_fs_path_root(sandbox);
cl_assert(root_len >= 0);
git_str_set(&root, sandbox, root_len+1);
diff --git a/tests/date/date.c b/tests/date/date.c
index ae787c0d3..82b5c6728 100644
--- a/tests/date/date.c
+++ b/tests/date/date.c
@@ -1,6 +1,6 @@
#include "clar_libgit2.h"
-#include "util.h"
+#include "date.h"
void test_date_date__overflow(void)
{
@@ -8,8 +8,8 @@ void test_date_date__overflow(void)
git_time_t d2038, d2039;
/* This is expected to fail on a 32-bit machine. */
- cl_git_pass(git__date_parse(&d2038, "2038-1-1"));
- cl_git_pass(git__date_parse(&d2039, "2039-1-1"));
+ cl_git_pass(git_date_parse(&d2038, "2038-1-1"));
+ cl_git_pass(git_date_parse(&d2039, "2039-1-1"));
cl_assert(d2038 < d2039);
#endif
}
@@ -17,6 +17,6 @@ void test_date_date__overflow(void)
void test_date_date__invalid_date(void)
{
git_time_t d;
- cl_git_fail(git__date_parse(&d, ""));
- cl_git_fail(git__date_parse(&d, "NEITHER_INTEGER_NOR_DATETIME"));
+ cl_git_fail(git_date_parse(&d, ""));
+ cl_git_fail(git_date_parse(&d, "NEITHER_INTEGER_NOR_DATETIME"));
}
diff --git a/tests/date/rfc2822.c b/tests/date/rfc2822.c
index d98c1f05e..b0bbcfce5 100644
--- a/tests/date/rfc2822.c
+++ b/tests/date/rfc2822.c
@@ -1,40 +1,37 @@
#include "clar_libgit2.h"
-#include "util.h"
+#include "date.h"
void test_date_rfc2822__format_rfc2822_no_offset(void)
{
git_time t = {1397031663, 0};
- char buf[GIT_DATE_RFC2822_SZ];
+ git_str buf = GIT_STR_INIT;
- cl_git_pass(git__date_rfc2822_fmt(buf, sizeof(buf), &t));
- cl_assert(strcmp(buf, "Wed, 9 Apr 2014 08:21:03 +0000") == 0);
+ cl_git_pass(git_date_rfc2822_fmt(&buf, t.time, t.offset));
+ cl_assert_equal_s("Wed, 9 Apr 2014 08:21:03 +0000", buf.ptr);
+
+ git_str_dispose(&buf);
}
void test_date_rfc2822__format_rfc2822_positive_offset(void)
{
git_time t = {1397031663, 120};
- char buf[GIT_DATE_RFC2822_SZ];
+ git_str buf = GIT_STR_INIT;
+
+ cl_git_pass(git_date_rfc2822_fmt(&buf, t.time, t.offset));
+ cl_assert_equal_s("Wed, 9 Apr 2014 10:21:03 +0200", buf.ptr);
- cl_git_pass(git__date_rfc2822_fmt(buf, sizeof(buf), &t));
- cl_assert(strcmp(buf, "Wed, 9 Apr 2014 10:21:03 +0200") == 0);
+ git_str_dispose(&buf);
}
void test_date_rfc2822__format_rfc2822_negative_offset(void)
{
git_time t = {1397031663, -120};
- char buf[GIT_DATE_RFC2822_SZ];
+ git_str buf = GIT_STR_INIT;
- cl_git_pass(git__date_rfc2822_fmt(buf, sizeof(buf), &t));
- cl_assert(strcmp(buf, "Wed, 9 Apr 2014 06:21:03 -0200") == 0);
-}
-
-void test_date_rfc2822__format_rfc2822_buffer_too_small(void)
-{
- /* "Wed, 10 Apr 2014 08:21:03 +0000" */
- git_time t = {1397031663 + 86400, 0};
- char buf[GIT_DATE_RFC2822_SZ-1];
+ cl_git_pass(git_date_rfc2822_fmt(&buf, t.time, t.offset));
+ cl_assert_equal_s("Wed, 9 Apr 2014 06:21:03 -0200", buf.ptr);
- cl_git_fail(git__date_rfc2822_fmt(buf, sizeof(buf), &t));
+ git_str_dispose(&buf);
}
diff --git a/tests/diff/binary.c b/tests/diff/binary.c
index 24d2b22ef..4e71f39c6 100644
--- a/tests/diff/binary.c
+++ b/tests/diff/binary.c
@@ -17,7 +17,7 @@ void test_diff_binary__cleanup(void)
cl_git_sandbox_cleanup();
}
-void test_patch(
+static void test_patch(
const char *one,
const char *two,
const git_diff_options *opts,
diff --git a/tests/diff/drivers.c b/tests/diff/drivers.c
index ce24e9bc0..304a54b56 100644
--- a/tests/diff/drivers.c
+++ b/tests/diff/drivers.c
@@ -187,7 +187,7 @@ void test_diff_drivers__builtins(void)
g_repo = cl_git_sandbox_init("userdiff");
- cl_git_pass(git_path_dirload(&files, "userdiff/files", 9, 0));
+ cl_git_pass(git_fs_path_dirload(&files, "userdiff/files", 9, 0));
opts.interhunk_lines = 1;
opts.context_lines = 1;
diff --git a/tests/diff/rename.c b/tests/diff/rename.c
index d28a4d989..41dc95eb4 100644
--- a/tests/diff/rename.c
+++ b/tests/diff/rename.c
@@ -938,7 +938,7 @@ struct rename_expected
size_t idx;
};
-int test_names_expected(const git_diff_delta *delta, float progress, void *p)
+static int test_names_expected(const git_diff_delta *delta, float progress, void *p)
{
struct rename_expected *expected = p;
diff --git a/tests/diff/tree.c b/tests/diff/tree.c
index dfe4d254c..e03ee7b22 100644
--- a/tests/diff/tree.c
+++ b/tests/diff/tree.c
@@ -320,7 +320,7 @@ void test_diff_tree__checks_options_version(void)
err = git_error_last();
}
-void process_tree_to_tree_diffing(
+static void process_tree_to_tree_diffing(
const char *old_commit,
const char *new_commit)
{
diff --git a/tests/diff/workdir.c b/tests/diff/workdir.c
index f7c74a294..444fc2f97 100644
--- a/tests/diff/workdir.c
+++ b/tests/diff/workdir.c
@@ -1252,7 +1252,7 @@ void test_diff_workdir__can_diff_empty_file(void)
/* empty contents of file */
cl_git_rewritefile("attr_index/README.txt", "");
- cl_git_pass(git_path_lstat("attr_index/README.txt", &st));
+ cl_git_pass(git_fs_path_lstat("attr_index/README.txt", &st));
cl_assert_equal_i(0, (int)st.st_size);
cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, tree, &opts));
@@ -1265,7 +1265,7 @@ void test_diff_workdir__can_diff_empty_file(void)
/* remove a file altogether */
cl_git_pass(p_unlink("attr_index/README.txt"));
- cl_assert(!git_path_exists("attr_index/README.txt"));
+ cl_assert(!git_fs_path_exists("attr_index/README.txt"));
cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, tree, &opts));
cl_assert_equal_i(3, (int)git_diff_num_deltas(diff));
@@ -1759,7 +1759,7 @@ static int touch_file(void *payload, git_str *path)
struct p_timeval times[2];
GIT_UNUSED(payload);
- if (git_path_isdir(path->ptr))
+ if (git_fs_path_isdir(path->ptr))
return 0;
cl_must_pass(p_stat(path->ptr, &st));
@@ -1805,7 +1805,7 @@ void test_diff_workdir__can_update_index(void)
{
git_str path = GIT_STR_INIT;
cl_git_pass(git_str_sets(&path, "status"));
- cl_git_pass(git_path_direach(&path, 0, touch_file, NULL));
+ cl_git_pass(git_fs_path_direach(&path, 0, touch_file, NULL));
git_str_dispose(&path);
}
@@ -2040,7 +2040,7 @@ void test_diff_workdir__only_writes_index_when_necessary(void)
/* touch all the files so stat times are different */
cl_git_pass(git_str_sets(&path, "status"));
- cl_git_pass(git_path_direach(&path, 0, touch_file, NULL));
+ cl_git_pass(git_fs_path_direach(&path, 0, touch_file, NULL));
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
git_diff_free(diff);
diff --git a/tests/email/create.c.bak b/tests/email/create.c.bak
new file mode 100644
index 000000000..3bb95a6f6
--- /dev/null
+++ b/tests/email/create.c.bak
@@ -0,0 +1,386 @@
+#include "clar.h"
+#include "clar_libgit2.h"
+
+#include "buffer.h"
+#include "diff_generate.h"
+
+static git_repository *repo;
+
+void test_email_create__initialize(void)
+{
+ repo = cl_git_sandbox_init("diff_format_email");
+}
+
+void test_email_create__cleanup(void)
+{
+ cl_git_sandbox_cleanup();
+}
+
+static void email_for_commit(
+ git_buf *out,
+ const char *commit_id,
+ git_email_create_options *opts)
+{
+ git_oid oid;
+ git_commit *commit = NULL;
+ git_diff *diff = NULL;
+
+ git_oid_fromstr(&oid, commit_id);
+
+ cl_git_pass(git_commit_lookup(&commit, repo, &oid));
+
+ cl_git_pass(git_email_create_from_commit(out, commit, opts));
+
+ git_diff_free(diff);
+ git_commit_free(commit);
+}
+
+static void assert_email_match(
+ const char *expected,
+ const char *commit_id,
+ git_email_create_options *opts)
+{
+ git_buf buf = GIT_BUF_INIT;
+
+ email_for_commit(&buf, commit_id, opts);
+ cl_assert_equal_s(expected, git_buf_cstr(&buf));
+
+ git_buf_dispose(&buf);
+}
+
+static void assert_subject_match(
+ const char *expected,
+ const char *commit_id,
+ git_email_create_options *opts)
+{
+ git_buf buf = GIT_BUF_INIT;
+ const char *loc;
+
+ email_for_commit(&buf, commit_id, opts);
+
+ cl_assert((loc = strstr(buf.ptr, "\nSubject: ")) != NULL);
+ git_buf_consume(&buf, (loc + 10));
+ git_buf_truncate_at_char(&buf, '\n');
+
+ cl_assert_equal_s(expected, git_buf_cstr(&buf));
+
+ git_buf_dispose(&buf);
+}
+
+void test_email_create__commit(void)
+{
+ const char *expected =
+ "From 9264b96c6d104d0e07ae33d3007b6a48246c6f92 Mon Sep 17 00:00:00 2001\n" \
+ "From: Jacques Germishuys <jacquesg@striata.com>\n" \
+ "Date: Wed, 9 Apr 2014 20:57:01 +0200\n" \
+ "Subject: [PATCH] Modify some content\n" \
+ "\n" \
+ "---\n" \
+ " file1.txt | 8 +++++---\n" \
+ " 1 file changed, 5 insertions(+), 3 deletions(-)\n" \
+ "\n" \
+ "diff --git a/file1.txt b/file1.txt\n" \
+ "index 94aaae8..af8f41d 100644\n" \
+ "--- a/file1.txt\n" \
+ "+++ b/file1.txt\n" \
+ "@@ -1,15 +1,17 @@\n" \
+ " file1.txt\n" \
+ " file1.txt\n" \
+ "+_file1.txt_\n" \
+ " file1.txt\n" \
+ " file1.txt\n" \
+ " file1.txt\n" \
+ " file1.txt\n" \
+ "+\n" \
+ "+\n" \
+ " file1.txt\n" \
+ " file1.txt\n" \
+ " file1.txt\n" \
+ " file1.txt\n" \
+ " file1.txt\n" \
+ "-file1.txt\n" \
+ "-file1.txt\n" \
+ "-file1.txt\n" \
+ "+_file1.txt_\n" \
+ "+_file1.txt_\n" \
+ " file1.txt\n" \
+ "--\n" \
+ "libgit2 " LIBGIT2_VERSION "\n" \
+ "\n";
+
+ assert_email_match(
+ expected, "9264b96c6d104d0e07ae33d3007b6a48246c6f92", NULL);
+}
+
+void test_email_create__custom_summary_and_body(void)
+{
+ const char *expected = "From 627e7e12d87e07a83fad5b6bfa25e86ead4a5270 Mon Sep 17 00:00:00 2001\n" \
+ "From: Patrick Steinhardt <ps@pks.im>\n" \
+ "Date: Tue, 24 Nov 2015 13:34:39 +0100\n" \
+ "Subject: [PPPPPATCH 2/4] This is a subject\n" \
+ "\n" \
+ "Modify content of file3.txt by appending a new line. Make this\n" \
+ "commit message somewhat longer to test behavior with newlines\n" \
+ "embedded in the message body.\n" \
+ "\n" \
+ "Also test if new paragraphs are included correctly.\n" \
+ "---\n" \
+ " file3.txt | 1 +\n" \
+ " 1 file changed, 1 insertion(+)\n" \
+ "\n" \
+ "diff --git a/file3.txt b/file3.txt\n" \
+ "index 9a2d780..7309653 100644\n" \
+ "--- a/file3.txt\n" \
+ "+++ b/file3.txt\n" \
+ "@@ -3,3 +3,4 @@ file3!\n" \
+ " file3\n" \
+ " file3\n" \
+ " file3\n" \
+ "+file3\n" \
+ "--\n" \
+ "libgit2 " LIBGIT2_VERSION "\n" \
+ "\n";
+
+ const char *summary = "This is a subject\nwith\nnewlines";
+ const char *body = "Modify content of file3.txt by appending a new line. Make this\n" \
+ "commit message somewhat longer to test behavior with newlines\n" \
+ "embedded in the message body.\n" \
+ "\n" \
+ "Also test if new paragraphs are included correctly.";
+
+ git_oid oid;
+ git_commit *commit = NULL;
+ git_diff *diff = NULL;
+ git_buf buf = GIT_BUF_INIT;
+ git_email_create_options opts = GIT_EMAIL_CREATE_OPTIONS_INIT;
+
+ opts.subject_prefix = "PPPPPATCH";
+
+ git_oid_fromstr(&oid, "627e7e12d87e07a83fad5b6bfa25e86ead4a5270");
+ cl_git_pass(git_commit_lookup(&commit, repo, &oid));
+ cl_git_pass(git_diff__commit(&diff, repo, commit, NULL));
+ cl_git_pass(git_email_create_from_diff(&buf, diff, 2, 4, &oid, summary, body, git_commit_author(commit), &opts));
+
+ cl_assert_equal_s(expected, git_buf_cstr(&buf));
+
+ git_diff_free(diff);
+ git_commit_free(commit);
+ git_buf_dispose(&buf);
+}
+
+void test_email_create__mode_change(void)
+{
+ const char *expected =
+ "From 7ade76dd34bba4733cf9878079f9fd4a456a9189 Mon Sep 17 00:00:00 2001\n" \
+ "From: Jacques Germishuys <jacquesg@striata.com>\n" \
+ "Date: Thu, 10 Apr 2014 10:05:03 +0200\n" \
+ "Subject: [PATCH] Update permissions\n" \
+ "\n" \
+ "---\n" \
+ " file1.txt.renamed | 0\n" \
+ " 1 file changed, 0 insertions(+), 0 deletions(-)\n" \
+ " mode change 100644 => 100755 file1.txt.renamed\n" \
+ "\n" \
+ "diff --git a/file1.txt.renamed b/file1.txt.renamed\n" \
+ "old mode 100644\n" \
+ "new mode 100755\n" \
+ "--\n" \
+ "libgit2 " LIBGIT2_VERSION "\n" \
+ "\n";
+
+ assert_email_match(expected, "7ade76dd34bba4733cf9878079f9fd4a456a9189", NULL);
+}
+
+void test_email_create__rename(void)
+{
+ const char *expected =
+ "From 6e05acc5a5dab507d91a0a0cc0fb05a3dd98892d Mon Sep 17 00:00:00 2001\n" \
+ "From: Jacques Germishuys <jacquesg@striata.com>\n" \
+ "Date: Wed, 9 Apr 2014 21:15:56 +0200\n" \
+ "Subject: [PATCH] Renamed file1.txt -> file1.txt.renamed\n" \
+ "\n" \
+ "---\n" \
+ " file1.txt => file1.txt.renamed | 4 ++--\n" \
+ " 1 file changed, 2 insertions(+), 2 deletions(-)\n" \
+ "\n" \
+ "diff --git a/file1.txt b/file1.txt.renamed\n" \
+ "similarity index 86%\n" \
+ "rename from file1.txt\n" \
+ "rename to file1.txt.renamed\n" \
+ "index af8f41d..a97157a 100644\n" \
+ "--- a/file1.txt\n" \
+ "+++ b/file1.txt.renamed\n" \
+ "@@ -3,13 +3,13 @@ file1.txt\n" \
+ " _file1.txt_\n" \
+ " file1.txt\n" \
+ " file1.txt\n" \
+ "-file1.txt\n" \
+ "+file1.txt_renamed\n" \
+ " file1.txt\n" \
+ " \n" \
+ " \n" \
+ " file1.txt\n" \
+ " file1.txt\n" \
+ "-file1.txt\n" \
+ "+file1.txt_renamed\n" \
+ " file1.txt\n" \
+ " file1.txt\n" \
+ " _file1.txt_\n" \
+ "--\n" \
+ "libgit2 " LIBGIT2_VERSION "\n" \
+ "\n";
+
+ assert_email_match(expected, "6e05acc5a5dab507d91a0a0cc0fb05a3dd98892d", NULL);
+}
+
+void test_email_create__rename_as_add_delete(void)
+{
+ const char *expected =
+ "From 6e05acc5a5dab507d91a0a0cc0fb05a3dd98892d Mon Sep 17 00:00:00 2001\n" \
+ "From: Jacques Germishuys <jacquesg@striata.com>\n" \
+ "Date: Wed, 9 Apr 2014 21:15:56 +0200\n" \
+ "Subject: [PATCH] Renamed file1.txt -> file1.txt.renamed\n" \
+ "\n" \
+ "---\n" \
+ " file1.txt | 17 -----------------\n" \
+ " file1.txt.renamed | 17 +++++++++++++++++\n" \
+ " 2 files changed, 17 insertions(+), 17 deletions(-)\n" \
+ " delete mode 100644 file1.txt\n" \
+ " create mode 100644 file1.txt.renamed\n" \
+ "\n" \
+ "diff --git a/file1.txt b/file1.txt\n" \
+ "deleted file mode 100644\n" \
+ "index af8f41d..0000000\n" \
+ "--- a/file1.txt\n" \
+ "+++ /dev/null\n" \
+ "@@ -1,17 +0,0 @@\n" \
+ "-file1.txt\n" \
+ "-file1.txt\n" \
+ "-_file1.txt_\n" \
+ "-file1.txt\n" \
+ "-file1.txt\n" \
+ "-file1.txt\n" \
+ "-file1.txt\n" \
+ "-\n" \
+ "-\n" \
+ "-file1.txt\n" \
+ "-file1.txt\n" \
+ "-file1.txt\n" \
+ "-file1.txt\n" \
+ "-file1.txt\n" \
+ "-_file1.txt_\n" \
+ "-_file1.txt_\n" \
+ "-file1.txt\n" \
+ "diff --git a/file1.txt.renamed b/file1.txt.renamed\n" \
+ "new file mode 100644\n" \
+ "index 0000000..a97157a\n" \
+ "--- /dev/null\n" \
+ "+++ b/file1.txt.renamed\n" \
+ "@@ -0,0 +1,17 @@\n" \
+ "+file1.txt\n" \
+ "+file1.txt\n" \
+ "+_file1.txt_\n" \
+ "+file1.txt\n" \
+ "+file1.txt\n" \
+ "+file1.txt_renamed\n" \
+ "+file1.txt\n" \
+ "+\n" \
+ "+\n" \
+ "+file1.txt\n" \
+ "+file1.txt\n" \
+ "+file1.txt_renamed\n" \
+ "+file1.txt\n" \
+ "+file1.txt\n" \
+ "+_file1.txt_\n" \
+ "+_file1.txt_\n" \
+ "+file1.txt\n" \
+ "--\n" \
+ "libgit2 " LIBGIT2_VERSION "\n" \
+ "\n";
+
+ git_email_create_options opts = GIT_EMAIL_CREATE_OPTIONS_INIT;
+ opts.flags |= GIT_EMAIL_CREATE_NO_RENAMES;
+
+ assert_email_match(expected, "6e05acc5a5dab507d91a0a0cc0fb05a3dd98892d", &opts);
+}
+
+void test_email_create__binary(void)
+{
+ const char *expected =
+ "From 8d7523f6fcb2404257889abe0d96f093d9f524f9 Mon Sep 17 00:00:00 2001\n" \
+ "From: Jacques Germishuys <jacquesg@striata.com>\n" \
+ "Date: Sun, 13 Apr 2014 18:10:18 +0200\n" \
+ "Subject: [PATCH] Modified binary file\n" \
+ "\n" \
+ "---\n" \
+ " binary.bin | Bin 3 -> 5 bytes\n" \
+ " 1 file changed, 0 insertions(+), 0 deletions(-)\n" \
+ "\n" \
+ "diff --git a/binary.bin b/binary.bin\n" \
+ "index bd474b2519cc15eab801ff851cc7d50f0dee49a1..9ac35ff15cd8864aeafd889e4826a3150f0b06c4 100644\n" \
+ "GIT binary patch\n" \
+ "literal 5\n" \
+ "Mc${NkU}WL~000&M4gdfE\n" \
+ "\n" \
+ "literal 3\n" \
+ "Kc${Nk-~s>u4FC%O\n" \
+ "\n" \
+ "--\n" \
+ "libgit2 " LIBGIT2_VERSION "\n" \
+ "\n";
+
+ assert_email_match(expected, "8d7523f6fcb2404257889abe0d96f093d9f524f9", NULL);
+}
+
+void test_email_create__binary_not_included(void)
+{
+ const char *expected =
+ "From 8d7523f6fcb2404257889abe0d96f093d9f524f9 Mon Sep 17 00:00:00 2001\n" \
+ "From: Jacques Germishuys <jacquesg@striata.com>\n" \
+ "Date: Sun, 13 Apr 2014 18:10:18 +0200\n" \
+ "Subject: [PATCH] Modified binary file\n" \
+ "\n" \
+ "---\n" \
+ " binary.bin | Bin 3 -> 5 bytes\n" \
+ " 1 file changed, 0 insertions(+), 0 deletions(-)\n" \
+ "\n" \
+ "diff --git a/binary.bin b/binary.bin\n" \
+ "index bd474b2..9ac35ff 100644\n" \
+ "Binary files a/binary.bin and b/binary.bin differ\n" \
+ "--\n" \
+ "libgit2 " LIBGIT2_VERSION "\n" \
+ "\n";
+
+ git_email_create_options opts = GIT_EMAIL_CREATE_OPTIONS_INIT;
+ opts.diff_opts.flags &= ~GIT_DIFF_SHOW_BINARY;
+
+ assert_email_match(expected, "8d7523f6fcb2404257889abe0d96f093d9f524f9", &opts);
+}
+
+void test_email_create__commit_subjects(void)
+{
+ git_email_create_options opts = GIT_EMAIL_CREATE_OPTIONS_INIT;
+
+ assert_subject_match("[PATCH] Modify some content", "9264b96c6d104d0e07ae33d3007b6a48246c6f92", &opts);
+
+ opts.reroll_number = 42;
+ assert_subject_match("[PATCH v42] Modify some content", "9264b96c6d104d0e07ae33d3007b6a48246c6f92", &opts);
+
+ opts.flags |= GIT_EMAIL_CREATE_ALWAYS_NUMBER;
+ assert_subject_match("[PATCH v42 1/1] Modify some content", "9264b96c6d104d0e07ae33d3007b6a48246c6f92", &opts);
+
+ opts.start_number = 9;
+ assert_subject_match("[PATCH v42 9/9] Modify some content", "9264b96c6d104d0e07ae33d3007b6a48246c6f92", &opts);
+
+ opts.subject_prefix = "";
+ assert_subject_match("[v42 9/9] Modify some content", "9264b96c6d104d0e07ae33d3007b6a48246c6f92", &opts);
+
+ opts.reroll_number = 0;
+ assert_subject_match("[9/9] Modify some content", "9264b96c6d104d0e07ae33d3007b6a48246c6f92", &opts);
+
+ opts.start_number = 0;
+ assert_subject_match("[1/1] Modify some content", "9264b96c6d104d0e07ae33d3007b6a48246c6f92", &opts);
+
+ opts.flags = GIT_EMAIL_CREATE_OMIT_NUMBERS;
+ assert_subject_match("Modify some content", "9264b96c6d104d0e07ae33d3007b6a48246c6f92", &opts);
+}
diff --git a/tests/fetchhead/nonetwork.c b/tests/fetchhead/nonetwork.c
index d1f09a817..ab31d3610 100644
--- a/tests/fetchhead/nonetwork.c
+++ b/tests/fetchhead/nonetwork.c
@@ -408,7 +408,7 @@ static bool found_master;
static bool found_haacked;
static bool find_master_haacked_called;
-int find_master_haacked(const char *ref_name, const char *remote_url, const git_oid *oid, unsigned int is_merge, void *payload)
+static int find_master_haacked(const char *ref_name, const char *remote_url, const git_oid *oid, unsigned int is_merge, void *payload)
{
GIT_UNUSED(remote_url);
GIT_UNUSED(oid);
@@ -446,9 +446,9 @@ void test_fetchhead_nonetwork__create_when_refpecs_given(void)
cl_git_pass(git_str_joinpath(&path, git_repository_path(g_repo), "FETCH_HEAD"));
cl_git_pass(git_remote_create(&remote, g_repo, "origin", cl_fixture("testrepo.git")));
- cl_assert(!git_path_exists(path.ptr));
+ cl_assert(!git_fs_path_exists(path.ptr));
cl_git_pass(git_remote_fetch(remote, &specs, NULL, NULL));
- cl_assert(git_path_exists(path.ptr));
+ cl_assert(git_fs_path_exists(path.ptr));
cl_git_pass(git_repository_fetchhead_foreach(g_repo, find_master_haacked, NULL));
cl_assert(find_master_haacked_called);
@@ -466,7 +466,7 @@ struct prefix_count {
int expected;
};
-int count_refs(const char *ref_name, const char *remote_url, const git_oid *oid, unsigned int is_merge, void *payload)
+static int count_refs(const char *ref_name, const char *remote_url, const git_oid *oid, unsigned int is_merge, void *payload)
{
int i;
struct prefix_count *prefix_counts = (struct prefix_count *) payload;
@@ -500,9 +500,9 @@ void test_fetchhead_nonetwork__create_with_multiple_refspecs(void)
cl_git_pass(git_remote_lookup(&remote, g_repo, "origin"));
cl_git_pass(git_str_joinpath(&path, git_repository_path(g_repo), "FETCH_HEAD"));
- cl_assert(!git_path_exists(path.ptr));
+ cl_assert(!git_fs_path_exists(path.ptr));
cl_git_pass(git_remote_fetch(remote, NULL, NULL, NULL));
- cl_assert(git_path_exists(path.ptr));
+ cl_assert(git_fs_path_exists(path.ptr));
{
int i;
diff --git a/tests/filter/custom_helpers.c b/tests/filter/custom_helpers.c
index 7aa3777e6..95a9f978e 100644
--- a/tests/filter/custom_helpers.c
+++ b/tests/filter/custom_helpers.c
@@ -2,6 +2,7 @@
#include "posix.h"
#include "filter.h"
#include "git2/sys/filter.h"
+#include "custom_helpers.h"
#define VERY_SECURE_ENCRYPTION(b) ((b) ^ 0xff)
@@ -128,7 +129,7 @@ git_filter *create_reverse_filter(const char *attrs)
return filter;
}
-int erroneous_filter_stream(
+static int erroneous_filter_stream(
git_writestream **out,
git_filter *self,
void **payload,
diff --git a/tests/filter/file.c b/tests/filter/file.c
index 3b7ab19e2..14b33bab9 100644
--- a/tests/filter/file.c
+++ b/tests/filter/file.c
@@ -55,19 +55,19 @@ struct buf_writestream {
git_str buf;
};
-int buf_writestream_write(git_writestream *s, const char *buf, size_t len)
+static int buf_writestream_write(git_writestream *s, const char *buf, size_t len)
{
struct buf_writestream *stream = (struct buf_writestream *)s;
return git_str_put(&stream->buf, buf, len);
}
-int buf_writestream_close(git_writestream *s)
+static int buf_writestream_close(git_writestream *s)
{
GIT_UNUSED(s);
return 0;
}
-void buf_writestream_free(git_writestream *s)
+static void buf_writestream_free(git_writestream *s)
{
struct buf_writestream *stream = (struct buf_writestream *)s;
git_str_dispose(&stream->buf);
diff --git a/tests/generate.py b/tests/generate.py
index 9ed6edef3..d2cdb684a 100644
--- a/tests/generate.py
+++ b/tests/generate.py
@@ -8,7 +8,7 @@
from __future__ import with_statement
from string import Template
-import re, fnmatch, os, sys, codecs, pickle
+import re, fnmatch, os, sys, codecs, pickle, io
class Module(object):
class Template(object):
@@ -147,7 +147,7 @@ class TestSuite(object):
self.path = path
self.output = output
- def should_generate(self, path):
+ def maybe_generate(self, path):
if not os.path.isfile(path):
return True
@@ -216,33 +216,82 @@ class TestSuite(object):
return sum(len(module.callbacks) for module in self.modules.values())
def write(self):
- output = os.path.join(self.output, 'clar.suite')
+ wrote_suite = self.write_suite()
+ wrote_header = self.write_header()
- if not self.should_generate(output):
+ if wrote_suite or wrote_header:
+ self.save_cache()
+ return True
+
+ return False
+
+ def write_output(self, fn, data):
+ if not self.maybe_generate(fn):
return False
- with open(output, 'w') as data:
+ current = None
+
+ try:
+ with open(fn, 'r') as input:
+ current = input.read()
+ except OSError:
+ pass
+ except IOError:
+ pass
+
+ if current == data:
+ return False
+
+ with open(fn, 'w') as output:
+ output.write(data)
+
+ return True
+
+ def write_suite(self):
+ suite_fn = os.path.join(self.output, 'clar.suite')
+
+ with io.StringIO() as suite_file:
modules = sorted(self.modules.values(), key=lambda module: module.name)
for module in modules:
t = Module.DeclarationTemplate(module)
- data.write(t.render())
+ suite_file.write(t.render())
for module in modules:
t = Module.CallbacksTemplate(module)
- data.write(t.render())
+ suite_file.write(t.render())
suites = "static struct clar_suite _clar_suites[] = {" + ','.join(
Module.InfoTemplate(module).render() for module in modules
) + "\n};\n"
- data.write(suites)
+ suite_file.write(suites)
- data.write("static const size_t _clar_suite_count = %d;\n" % self.suite_count())
- data.write("static const size_t _clar_callback_count = %d;\n" % self.callback_count())
+ suite_file.write(u"static const size_t _clar_suite_count = %d;\n" % self.suite_count())
+ suite_file.write(u"static const size_t _clar_callback_count = %d;\n" % self.callback_count())
- self.save_cache()
- return True
+ return self.write_output(suite_fn, suite_file.getvalue())
+
+ return False
+
+ def write_header(self):
+ header_fn = os.path.join(self.output, 'clar_suite.h')
+
+ with io.StringIO() as header_file:
+ header_file.write(u"#ifndef _____clar_suite_h_____\n")
+ header_file.write(u"#define _____clar_suite_h_____\n")
+
+ modules = sorted(self.modules.values(), key=lambda module: module.name)
+
+ for module in modules:
+ t = Module.DeclarationTemplate(module)
+ header_file.write(t.render())
+
+ header_file.write(u"#endif\n")
+
+ return self.write_output(header_fn, header_file.getvalue())
+
+ return False
if __name__ == '__main__':
from optparse import OptionParser
@@ -263,5 +312,5 @@ if __name__ == '__main__':
suite.load(options.force)
suite.disable(options.excluded)
if suite.write():
- print("Written `clar.suite` (%d tests in %d suites)" % (suite.callback_count(), suite.suite_count()))
+ print("Written `clar.suite`, `clar_suite.h` (%d tests in %d suites)" % (suite.callback_count(), suite.suite_count()))
diff --git a/tests/headertest.c b/tests/headertest.c
new file mode 100644
index 000000000..2af8a14ec
--- /dev/null
+++ b/tests/headertest.c
@@ -0,0 +1,13 @@
+/*
+ * Dummy project to validate header files
+ *
+ * This project is not intended to be executed, it should only include all
+ * header files to make sure that they can be used with stricter compiler
+ * settings than the libgit2 source files generally supports.
+ */
+#include "git2.h"
+
+int main(void)
+{
+ return 0;
+}
diff --git a/tests/ignore/path.c b/tests/ignore/path.c
index d55bdc5dd..a574d1d79 100644
--- a/tests/ignore/path.c
+++ b/tests/ignore/path.c
@@ -257,7 +257,7 @@ void test_ignore_path__skip_gitignore_directory(void)
{
cl_git_rewritefile("attr/.git/info/exclude", "/NewFolder\n/NewFolder/NewFolder");
cl_must_pass(p_unlink("attr/.gitignore"));
- cl_assert(!git_path_exists("attr/.gitignore"));
+ cl_assert(!git_fs_path_exists("attr/.gitignore"));
p_mkdir("attr/.gitignore", 0777);
cl_git_mkfile("attr/.gitignore/garbage.txt", "new_file\n");
@@ -270,7 +270,7 @@ void test_ignore_path__skip_gitignore_directory(void)
void test_ignore_path__subdirectory_gitignore(void)
{
cl_must_pass(p_unlink("attr/.gitignore"));
- cl_assert(!git_path_exists("attr/.gitignore"));
+ cl_assert(!git_fs_path_exists("attr/.gitignore"));
cl_git_mkfile(
"attr/.gitignore",
"file1\n");
diff --git a/tests/index/crlf.c b/tests/index/crlf.c
index 8d2a5fcce..7520c23a3 100644
--- a/tests/index/crlf.c
+++ b/tests/index/crlf.c
@@ -53,7 +53,7 @@ static int add_and_check_file(void *payload, git_str *actual_path)
git_blob *blob;
bool failed = true;
- basename = git_path_basename(actual_path->ptr);
+ basename = git_fs_path_basename(actual_path->ptr);
if (!strcmp(basename, ".git") || !strcmp(basename, ".gitattributes")) {
failed = false;
@@ -65,7 +65,7 @@ static int add_and_check_file(void *payload, git_str *actual_path)
cl_git_pass(git_str_puts(&expected_path_fail, expected_path.ptr));
cl_git_pass(git_str_puts(&expected_path_fail, ".fail"));
- if (git_path_isfile(expected_path.ptr)) {
+ if (git_fs_path_isfile(expected_path.ptr)) {
cl_git_pass(git_index_add_bypath(g_index, basename));
cl_assert(entry = git_index_get_bypath(g_index, basename, 0));
@@ -77,7 +77,7 @@ static int add_and_check_file(void *payload, git_str *actual_path)
goto done;
git_blob_free(blob);
- } else if (git_path_isfile(expected_path_fail.ptr)) {
+ } else if (git_fs_path_isfile(expected_path_fail.ptr)) {
cl_git_pass(git_futils_readbuffer(&expected_contents, expected_path_fail.ptr));
git_str_rtrim(&expected_contents);
@@ -161,7 +161,7 @@ static void test_add_index(const char *safecrlf, const char *autocrlf, const cha
cl_fixture_sandbox(expected_fixture.ptr);
compare_data.dirname = sandboxname.ptr;
- cl_git_pass(git_path_direach(&reponame, 0, add_and_check_file, &compare_data));
+ cl_git_pass(git_fs_path_direach(&reponame, 0, add_and_check_file, &compare_data));
cl_fixture_cleanup(expected_fixture.ptr);
git_str_dispose(&expected_fixture);
@@ -179,9 +179,9 @@ static void set_up_workingdir(const char *name)
size_t i;
const char *fn;
- git_path_dirload(&contents, name, 0, 0);
+ git_fs_path_dirload(&contents, name, 0, 0);
git_vector_foreach(&contents, i, fn) {
- char *basename = git_path_basename(fn);
+ char *basename = git_fs_path_basename(fn);
bool skip = strncasecmp(basename, ".git", 4) == 0 && strlen(basename) == 4;
git__free(basename);
@@ -193,9 +193,9 @@ static void set_up_workingdir(const char *name)
git_vector_free_deep(&contents);
/* copy input files */
- git_path_dirload(&contents, cl_fixture("crlf"), 0, 0);
+ git_fs_path_dirload(&contents, cl_fixture("crlf"), 0, 0);
git_vector_foreach(&contents, i, fn) {
- char *basename = git_path_basename(fn);
+ char *basename = git_fs_path_basename(fn);
git_str dest_filename = GIT_STR_INIT;
if (strcmp(basename, ".gitted") &&
diff --git a/tests/index/tests.c b/tests/index/tests.c
index 9b28028e6..b6715574e 100644
--- a/tests/index/tests.c
+++ b/tests/index/tests.c
@@ -571,9 +571,9 @@ void test_index_tests__cannot_add_invalid_filename(void)
cl_must_pass(p_mkdir("./invalid/subdir", 0777));
/* cl_git_mkfile() needs the dir to exist */
- if (!git_path_exists("./invalid/.GIT"))
+ if (!git_fs_path_exists("./invalid/.GIT"))
cl_must_pass(p_mkdir("./invalid/.GIT", 0777));
- if (!git_path_exists("./invalid/.GiT"))
+ if (!git_fs_path_exists("./invalid/.GiT"))
cl_must_pass(p_mkdir("./invalid/.GiT", 0777));
assert_add_bypath_fails(repo, ".git/hello");
diff --git a/tests/iterator/index.c b/tests/iterator/index.c
index 69b795f5c..7218b4f75 100644
--- a/tests/iterator/index.c
+++ b/tests/iterator/index.c
@@ -283,7 +283,7 @@ void test_iterator_index__case_folding(void)
int fs_is_ci = 0;
cl_git_pass(git_str_joinpath(&path, cl_fixture("icase"), ".gitted/CoNfIg"));
- fs_is_ci = git_path_exists(path.ptr);
+ fs_is_ci = git_fs_path_exists(path.ptr);
git_str_dispose(&path);
index_iterator_test(
diff --git a/tests/iterator/workdir.c b/tests/iterator/workdir.c
index 7ca726c24..86b847cab 100644
--- a/tests/iterator/workdir.c
+++ b/tests/iterator/workdir.c
@@ -1024,7 +1024,7 @@ static void create_paths(const char *root, int depth)
int i;
cl_git_pass(git_str_puts(&fullpath, root));
- cl_git_pass(git_path_to_dir(&fullpath));
+ cl_git_pass(git_fs_path_to_dir(&fullpath));
root_len = fullpath.size;
diff --git a/tests/merge/merge_helpers.c b/tests/merge/merge_helpers.c
index 1eb423ef7..ce3cd229b 100644
--- a/tests/merge/merge_helpers.c
+++ b/tests/merge/merge_helpers.c
@@ -328,7 +328,7 @@ int merge_test_reuc(git_index *index, const struct merge_reuc_entry expected[],
return 1;
}
-int dircount(void *payload, git_str *pathbuf)
+static int dircount(void *payload, git_str *pathbuf)
{
size_t *entries = payload;
size_t len = git_str_len(pathbuf);
@@ -346,7 +346,7 @@ int merge_test_workdir(git_repository *repo, const struct merge_index_entry expe
git_str wd = GIT_STR_INIT;
git_str_puts(&wd, repo->workdir);
- git_path_direach(&wd, 0, dircount, &actual_len);
+ git_fs_path_direach(&wd, 0, dircount, &actual_len);
if (actual_len != expected_len)
return 0;
diff --git a/tests/merge/merge_helpers.h b/tests/merge/merge_helpers.h
index 166b4eefd..339812ba5 100644
--- a/tests/merge/merge_helpers.h
+++ b/tests/merge/merge_helpers.h
@@ -65,4 +65,8 @@ int merge_test_reuc(git_index *index, const struct merge_reuc_entry expected[],
int merge_test_workdir(git_repository *repo, const struct merge_index_entry expected[], size_t expected_len);
+void merge__dump_names(git_index *index);
+void merge__dump_index_entries(git_vector *index_entries);
+void merge__dump_reuc(git_index *index);
+
#endif
diff --git a/tests/merge/workdir/setup.c b/tests/merge/workdir/setup.c
index fe33e21f2..3db2d074f 100644
--- a/tests/merge/workdir/setup.c
+++ b/tests/merge/workdir/setup.c
@@ -48,15 +48,15 @@ static bool test_file_contents(const char *filename, const char *expected)
{
git_str file_path_buf = GIT_STR_INIT, file_buf = GIT_STR_INIT;
bool equals;
-
+
git_str_joinpath(&file_path_buf, git_repository_path(repo), filename);
-
+
cl_git_pass(git_futils_readbuffer(&file_buf, file_path_buf.ptr));
equals = (strcmp(file_buf.ptr, expected) == 0);
git_str_dispose(&file_path_buf);
git_str_dispose(&file_buf);
-
+
return equals;
}
@@ -77,13 +77,13 @@ void test_merge_workdir_setup__one_branch(void)
git_oid our_oid;
git_reference *octo1_ref;
git_annotated_commit *our_head, *their_heads[1];
-
+
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
-
+
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
-
+
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 1));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n"));
@@ -92,7 +92,7 @@ void test_merge_workdir_setup__one_branch(void)
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branch '" OCTO1_BRANCH "'\n"));
git_reference_free(octo1_ref);
-
+
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
}
@@ -103,10 +103,10 @@ void test_merge_workdir_setup__one_oid(void)
git_oid our_oid;
git_oid octo1_oid;
git_annotated_commit *our_head, *their_heads[1];
-
+
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
-
+
cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &octo1_oid));
@@ -128,10 +128,10 @@ void test_merge_workdir_setup__two_branches(void)
git_reference *octo1_ref;
git_reference *octo2_ref;
git_annotated_commit *our_head, *their_heads[2];
-
+
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
-
+
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
@@ -139,15 +139,15 @@ void test_merge_workdir_setup__two_branches(void)
cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 2));
-
+
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branches '" OCTO1_BRANCH "' and '" OCTO2_BRANCH "'\n"));
-
+
git_reference_free(octo1_ref);
git_reference_free(octo2_ref);
-
+
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
@@ -161,13 +161,13 @@ void test_merge_workdir_setup__three_branches(void)
git_reference *octo2_ref;
git_reference *octo3_ref;
git_annotated_commit *our_head, *their_heads[3];
-
+
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
-
+
cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
@@ -180,7 +180,7 @@ void test_merge_workdir_setup__three_branches(void)
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branches '" OCTO1_BRANCH "', '" OCTO2_BRANCH "' and '" OCTO3_BRANCH "'\n"));
-
+
git_reference_free(octo1_ref);
git_reference_free(octo2_ref);
git_reference_free(octo3_ref);
@@ -199,13 +199,13 @@ void test_merge_workdir_setup__three_oids(void)
git_oid octo2_oid;
git_oid octo3_oid;
git_annotated_commit *our_head, *their_heads[3];
-
+
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &octo1_oid));
-
+
cl_git_pass(git_oid_fromstr(&octo2_oid, OCTO2_OID));
cl_git_pass(git_annotated_commit_lookup(&their_heads[1], repo, &octo2_oid));
@@ -218,7 +218,7 @@ void test_merge_workdir_setup__three_oids(void)
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge commit '" OCTO1_OID "'; commit '" OCTO2_OID "'; commit '" OCTO3_OID "'\n"));
-
+
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
@@ -232,7 +232,7 @@ void test_merge_workdir_setup__branches_and_oids_1(void)
git_reference *octo1_ref;
git_oid octo2_oid;
git_annotated_commit *our_head, *their_heads[2];
-
+
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
@@ -248,7 +248,7 @@ void test_merge_workdir_setup__branches_and_oids_1(void)
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branch '" OCTO1_BRANCH "'; commit '" OCTO2_OID "'\n"));
-
+
git_reference_free(octo1_ref);
git_annotated_commit_free(our_head);
@@ -271,23 +271,23 @@ void test_merge_workdir_setup__branches_and_oids_2(void)
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
-
+
cl_git_pass(git_oid_fromstr(&octo2_oid, OCTO2_OID));
cl_git_pass(git_annotated_commit_lookup(&their_heads[1], repo, &octo2_oid));
cl_git_pass(git_reference_lookup(&octo3_ref, repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[2], repo, octo3_ref));
-
+
cl_git_pass(git_oid_fromstr(&octo4_oid, OCTO4_OID));
cl_git_pass(git_annotated_commit_lookup(&their_heads[3], repo, &octo4_oid));
-
+
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 4));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n" OCTO4_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branches '" OCTO1_BRANCH "' and '" OCTO3_BRANCH "'; commit '" OCTO2_OID "'; commit '" OCTO4_OID "'\n"));
-
+
git_reference_free(octo1_ref);
git_reference_free(octo3_ref);
@@ -307,7 +307,7 @@ void test_merge_workdir_setup__branches_and_oids_3(void)
git_oid octo3_oid;
git_reference *octo4_ref;
git_annotated_commit *our_head, *their_heads[4];
-
+
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
@@ -319,17 +319,17 @@ void test_merge_workdir_setup__branches_and_oids_3(void)
cl_git_pass(git_oid_fromstr(&octo3_oid, OCTO3_OID));
cl_git_pass(git_annotated_commit_lookup(&their_heads[2], repo, &octo3_oid));
-
+
cl_git_pass(git_reference_lookup(&octo4_ref, repo, GIT_REFS_HEADS_DIR OCTO4_BRANCH));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[3], repo, octo4_ref));
-
+
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 4));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n" OCTO4_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge commit '" OCTO1_OID "'; branches '" OCTO2_BRANCH "' and '" OCTO4_BRANCH "'; commit '" OCTO3_OID "'\n"));
-
+
git_reference_free(octo2_ref);
git_reference_free(octo4_ref);
@@ -350,19 +350,19 @@ void test_merge_workdir_setup__branches_and_oids_4(void)
git_reference *octo4_ref;
git_reference *octo5_ref;
git_annotated_commit *our_head, *their_heads[5];
-
+
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
-
+
cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &octo1_oid));
-
+
cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
-
+
cl_git_pass(git_oid_fromstr(&octo3_oid, OCTO3_OID));
cl_git_pass(git_annotated_commit_lookup(&their_heads[2], repo, &octo3_oid));
-
+
cl_git_pass(git_reference_lookup(&octo4_ref, repo, GIT_REFS_HEADS_DIR OCTO4_BRANCH));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[3], repo, octo4_ref));
@@ -375,7 +375,7 @@ void test_merge_workdir_setup__branches_and_oids_4(void)
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge commit '" OCTO1_OID "'; branches '" OCTO2_BRANCH "', '" OCTO4_BRANCH "' and '" OCTO5_BRANCH "'; commit '" OCTO3_OID "'\n"));
-
+
git_reference_free(octo2_ref);
git_reference_free(octo4_ref);
git_reference_free(octo5_ref);
@@ -396,30 +396,30 @@ void test_merge_workdir_setup__three_same_branches(void)
git_reference *octo1_2_ref;
git_reference *octo1_3_ref;
git_annotated_commit *our_head, *their_heads[3];
-
+
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
-
+
cl_git_pass(git_reference_lookup(&octo1_1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_1_ref));
-
+
cl_git_pass(git_reference_lookup(&octo1_2_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo1_2_ref));
-
+
cl_git_pass(git_reference_lookup(&octo1_3_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[2], repo, octo1_3_ref));
-
+
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 3));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO1_OID "\n" OCTO1_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branches '" OCTO1_BRANCH "', '" OCTO1_BRANCH "' and '" OCTO1_BRANCH "'\n"));
-
+
git_reference_free(octo1_1_ref);
git_reference_free(octo1_2_ref);
git_reference_free(octo1_3_ref);
-
+
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
@@ -434,26 +434,26 @@ void test_merge_workdir_setup__three_same_oids(void)
git_oid octo1_2_oid;
git_oid octo1_3_oid;
git_annotated_commit *our_head, *their_heads[3];
-
+
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
-
+
cl_git_pass(git_oid_fromstr(&octo1_1_oid, OCTO1_OID));
cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &octo1_1_oid));
-
+
cl_git_pass(git_oid_fromstr(&octo1_2_oid, OCTO1_OID));
cl_git_pass(git_annotated_commit_lookup(&their_heads[1], repo, &octo1_2_oid));
-
+
cl_git_pass(git_oid_fromstr(&octo1_3_oid, OCTO1_OID));
cl_git_pass(git_annotated_commit_lookup(&their_heads[2], repo, &octo1_3_oid));
-
+
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 3));
-
+
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO1_OID "\n" OCTO1_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge commit '" OCTO1_OID "'; commit '" OCTO1_OID "'; commit '" OCTO1_OID "'\n"));
-
+
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
@@ -473,7 +473,7 @@ static int create_remote_tracking_branch(const char *branch_name, const char *oi
(error = git_str_puts(&remotes_path, GIT_REFS_REMOTES_DIR)) < 0)
goto done;
- if (!git_path_exists(git_str_cstr(&remotes_path)) &&
+ if (!git_fs_path_exists(git_str_cstr(&remotes_path)) &&
(error = p_mkdir(git_str_cstr(&remotes_path), 0777)) < 0)
goto done;
@@ -481,7 +481,7 @@ static int create_remote_tracking_branch(const char *branch_name, const char *oi
(error = git_str_puts(&origin_path, "origin")) < 0)
goto done;
- if (!git_path_exists(git_str_cstr(&origin_path)) &&
+ if (!git_fs_path_exists(git_str_cstr(&origin_path)) &&
(error = p_mkdir(git_str_cstr(&origin_path), 0777)) < 0)
goto done;
@@ -514,10 +514,10 @@ void test_merge_workdir_setup__remote_tracking_one_branch(void)
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
-
+
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO1_BRANCH));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
-
+
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 1));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n"));
@@ -526,7 +526,7 @@ void test_merge_workdir_setup__remote_tracking_one_branch(void)
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge remote-tracking branch 'refs/remotes/origin/" OCTO1_BRANCH "'\n"));
git_reference_free(octo1_ref);
-
+
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
}
@@ -544,7 +544,7 @@ void test_merge_workdir_setup__remote_tracking_two_branches(void)
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
-
+
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO1_BRANCH));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
@@ -552,15 +552,15 @@ void test_merge_workdir_setup__remote_tracking_two_branches(void)
cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 2));
-
+
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge remote-tracking branches 'refs/remotes/origin/" OCTO1_BRANCH "' and 'refs/remotes/origin/" OCTO2_BRANCH "'\n"));
-
+
git_reference_free(octo1_ref);
git_reference_free(octo2_ref);
-
+
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
@@ -578,13 +578,13 @@ void test_merge_workdir_setup__remote_tracking_three_branches(void)
cl_git_pass(create_remote_tracking_branch(OCTO1_BRANCH, OCTO1_OID));
cl_git_pass(create_remote_tracking_branch(OCTO2_BRANCH, OCTO2_OID));
cl_git_pass(create_remote_tracking_branch(OCTO3_BRANCH, OCTO3_OID));
-
+
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO1_BRANCH));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
-
+
cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO2_BRANCH));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
@@ -597,7 +597,7 @@ void test_merge_workdir_setup__remote_tracking_three_branches(void)
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge remote-tracking branches 'refs/remotes/origin/" OCTO1_BRANCH "', 'refs/remotes/origin/" OCTO2_BRANCH "' and 'refs/remotes/origin/" OCTO3_BRANCH "'\n"));
-
+
git_reference_free(octo1_ref);
git_reference_free(octo2_ref);
git_reference_free(octo3_ref);
@@ -628,15 +628,15 @@ void test_merge_workdir_setup__normal_branch_and_remote_tracking_branch(void)
cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 2));
-
+
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branch '" OCTO1_BRANCH "', remote-tracking branch 'refs/remotes/origin/" OCTO2_BRANCH "'\n"));
-
+
git_reference_free(octo1_ref);
git_reference_free(octo2_ref);
-
+
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
@@ -654,7 +654,7 @@ void test_merge_workdir_setup__remote_tracking_branch_and_normal_branch(void)
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
-
+
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO1_BRANCH));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
@@ -662,15 +662,15 @@ void test_merge_workdir_setup__remote_tracking_branch_and_normal_branch(void)
cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 2));
-
+
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branch '" OCTO2_BRANCH "', remote-tracking branch 'refs/remotes/origin/" OCTO1_BRANCH "'\n"));
-
+
git_reference_free(octo1_ref);
git_reference_free(octo2_ref);
-
+
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
@@ -691,7 +691,7 @@ void test_merge_workdir_setup__two_remote_tracking_branch_and_two_normal_branche
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
-
+
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
@@ -705,17 +705,17 @@ void test_merge_workdir_setup__two_remote_tracking_branch_and_two_normal_branche
cl_git_pass(git_annotated_commit_from_ref(&their_heads[3], repo, octo4_ref));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 4));
-
+
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n" OCTO4_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branches '" OCTO1_BRANCH "' and '" OCTO3_BRANCH "', remote-tracking branches 'refs/remotes/origin/" OCTO2_BRANCH "' and 'refs/remotes/origin/" OCTO4_BRANCH "'\n"));
-
+
git_reference_free(octo1_ref);
git_reference_free(octo2_ref);
git_reference_free(octo3_ref);
git_reference_free(octo4_ref);
-
+
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
@@ -735,14 +735,14 @@ void test_merge_workdir_setup__pull_one(void)
cl_git_pass(git_oid_fromstr(&octo1_1_oid, OCTO1_OID));
cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.url/repo.git", &octo1_1_oid));
-
+
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 1));
-
+
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branch 'octo1' of http://remote.url/repo.git\n"));
-
+
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
}
@@ -754,7 +754,7 @@ void test_merge_workdir_setup__pull_two(void)
git_oid octo1_oid;
git_oid octo2_oid;
git_annotated_commit *our_head, *their_heads[2];
-
+
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
@@ -770,7 +770,7 @@ void test_merge_workdir_setup__pull_two(void)
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branches '" OCTO1_BRANCH "' and '" OCTO2_BRANCH "' of http://remote.url/repo.git\n"));
-
+
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
@@ -784,7 +784,7 @@ void test_merge_workdir_setup__pull_three(void)
git_oid octo2_oid;
git_oid octo3_oid;
git_annotated_commit *our_head, *their_heads[3];
-
+
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
@@ -803,7 +803,7 @@ void test_merge_workdir_setup__pull_three(void)
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branches '" OCTO1_BRANCH "', '" OCTO2_BRANCH "' and '" OCTO3_BRANCH "' of http://remote.url/repo.git\n"));
-
+
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
@@ -817,7 +817,7 @@ void test_merge_workdir_setup__three_remotes(void)
git_oid octo2_oid;
git_oid octo3_oid;
git_annotated_commit *our_head, *their_heads[3];
-
+
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
@@ -836,7 +836,7 @@ void test_merge_workdir_setup__three_remotes(void)
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branch '" OCTO1_BRANCH "' of http://remote.first/repo.git, branch '" OCTO2_BRANCH "' of http://remote.second/repo.git, branch '" OCTO3_BRANCH "' of http://remote.third/repo.git\n"));
-
+
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
@@ -851,7 +851,7 @@ void test_merge_workdir_setup__two_remotes(void)
git_oid octo3_oid;
git_oid octo4_oid;
git_annotated_commit *our_head, *their_heads[4];
-
+
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
@@ -873,7 +873,7 @@ void test_merge_workdir_setup__two_remotes(void)
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branches '" OCTO1_BRANCH "' and '" OCTO3_BRANCH "' of http://remote.first/repo.git, branches '" OCTO2_BRANCH "' and '" OCTO4_BRANCH "' of http://remote.second/repo.git\n"));
-
+
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
@@ -1036,9 +1036,9 @@ void test_merge_workdir_setup__removed_after_failure(void)
cl_git_fail(git_merge(
repo, (const git_annotated_commit **)&their_heads[0], 1, NULL, NULL));
- cl_assert(!git_path_exists("merge-resolve/.git/" GIT_MERGE_HEAD_FILE));
- cl_assert(!git_path_exists("merge-resolve/.git/" GIT_MERGE_MODE_FILE));
- cl_assert(!git_path_exists("merge-resolve/.git/" GIT_MERGE_MSG_FILE));
+ cl_assert(!git_fs_path_exists("merge-resolve/.git/" GIT_MERGE_HEAD_FILE));
+ cl_assert(!git_fs_path_exists("merge-resolve/.git/" GIT_MERGE_MODE_FILE));
+ cl_assert(!git_fs_path_exists("merge-resolve/.git/" GIT_MERGE_MSG_FILE));
git_reference_free(octo1_ref);
@@ -1061,7 +1061,7 @@ void test_merge_workdir_setup__unlocked_after_success(void)
cl_git_pass(git_merge(
repo, (const git_annotated_commit **)&their_heads[0], 1, NULL, NULL));
- cl_assert(!git_path_exists("merge-resolve/.git/index.lock"));
+ cl_assert(!git_fs_path_exists("merge-resolve/.git/index.lock"));
git_reference_free(octo1_ref);
@@ -1087,7 +1087,7 @@ void test_merge_workdir_setup__unlocked_after_conflict(void)
cl_git_fail(git_merge(
repo, (const git_annotated_commit **)&their_heads[0], 1, NULL, NULL));
- cl_assert(!git_path_exists("merge-resolve/.git/index.lock"));
+ cl_assert(!git_fs_path_exists("merge-resolve/.git/index.lock"));
git_reference_free(octo1_ref);
diff --git a/tests/merge/workdir/simple.c b/tests/merge/workdir/simple.c
index 6c4cf7e3c..f51ff09a7 100644
--- a/tests/merge/workdir/simple.c
+++ b/tests/merge/workdir/simple.c
@@ -504,7 +504,7 @@ void test_merge_workdir_simple__checkout_ours(void)
cl_assert(merge_test_index(repo_index, merge_index_entries, 8));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 3));
- cl_assert(git_path_exists(TEST_REPO_PATH "/conflicting.txt"));
+ cl_assert(git_fs_path_exists(TEST_REPO_PATH "/conflicting.txt"));
}
void test_merge_workdir_simple__favor_ours(void)
diff --git a/tests/network/fetchlocal.c b/tests/network/fetchlocal.c
index 2aa9fd5f1..c54f45472 100644
--- a/tests/network/fetchlocal.c
+++ b/tests/network/fetchlocal.c
@@ -108,7 +108,7 @@ void test_network_fetchlocal__prune(void)
git_repository_free(repo);
}
-int update_tips_fail_on_call(const char *ref, const git_oid *old, const git_oid *new, void *data)
+static int update_tips_fail_on_call(const char *ref, const git_oid *old, const git_oid *new, void *data)
{
GIT_UNUSED(ref);
GIT_UNUSED(old);
@@ -119,7 +119,7 @@ int update_tips_fail_on_call(const char *ref, const git_oid *old, const git_oid
return 0;
}
-void assert_ref_exists(git_repository *repo, const char *name)
+static void assert_ref_exists(git_repository *repo, const char *name)
{
git_reference *ref;
diff --git a/tests/network/remote/push.c b/tests/network/remote/push.c
index 34860542e..3905debdf 100644
--- a/tests/network/remote/push.c
+++ b/tests/network/remote/push.c
@@ -29,7 +29,7 @@ void test_network_remote_push__cleanup(void)
cl_fixture_cleanup("dummy.git");
}
-int negotiation_cb(const git_push_update **updates, size_t len, void *payload)
+static int negotiation_cb(const git_push_update **updates, size_t len, void *payload)
{
const git_push_update *expected = payload;
@@ -69,7 +69,7 @@ void test_network_remote_push__delete_notification(void)
}
-void create_dummy_commit(git_reference **out, git_repository *repo)
+static void create_dummy_commit(git_reference **out, git_repository *repo)
{
git_index *index;
git_oid tree_id, commit_id;
diff --git a/tests/notes/notes.c b/tests/notes/notes.c
index dd9ad1e4b..a36cddb8a 100644
--- a/tests/notes/notes.c
+++ b/tests/notes/notes.c
@@ -103,7 +103,7 @@ static int note_list_create_cb(
return 0;
}
-void assert_notes_seen(struct note_create_payload payload[], size_t n)
+static void assert_notes_seen(struct note_create_payload payload[], size_t n)
{
size_t seen = 0, i;
diff --git a/tests/object/blob/write.c b/tests/object/blob/write.c
index 802467498..422258d63 100644
--- a/tests/object/blob/write.c
+++ b/tests/object/blob/write.c
@@ -42,7 +42,7 @@ void test_object_blob_write__can_create_a_blob_in_a_standard_repo_from_a_absolut
repo = cl_git_sandbox_init(WORKDIR);
cl_must_pass(p_mkdir(ELSEWHERE, 0777));
- cl_must_pass(git_path_prettify_dir(&full_path, ELSEWHERE, NULL));
+ cl_must_pass(git_fs_path_prettify_dir(&full_path, ELSEWHERE, NULL));
cl_must_pass(git_str_puts(&full_path, "test.txt"));
assert_blob_creation(ELSEWHERE "/test.txt", git_str_cstr(&full_path), &git_blob_create_from_disk);
@@ -58,7 +58,7 @@ void test_object_blob_write__can_create_a_blob_in_a_bare_repo_from_a_absolute_fi
repo = cl_git_sandbox_init(BARE_REPO);
cl_must_pass(p_mkdir(ELSEWHERE, 0777));
- cl_must_pass(git_path_prettify_dir(&full_path, ELSEWHERE, NULL));
+ cl_must_pass(git_fs_path_prettify_dir(&full_path, ELSEWHERE, NULL));
cl_must_pass(git_str_puts(&full_path, "test.txt"));
assert_blob_creation(ELSEWHERE "/test.txt", git_str_cstr(&full_path), &git_blob_create_from_disk);
diff --git a/tests/object/raw/write.c b/tests/object/raw/write.c
index 9bc127680..40e05f357 100644
--- a/tests/object/raw/write.c
+++ b/tests/object/raw/write.c
@@ -39,8 +39,8 @@ static void streaming_write(git_oid *oid, git_odb *odb, git_rawobj *raw)
static void check_object_files(object_data *d)
{
- cl_assert(git_path_exists(d->dir));
- cl_assert(git_path_exists(d->file));
+ cl_assert(git_fs_path_exists(d->dir));
+ cl_assert(git_fs_path_exists(d->file));
}
static void cmp_objects(git_rawobj *o1, git_rawobj *o2)
diff --git a/tests/object/tag/write.c b/tests/object/tag/write.c
index 48c8bfd36..3c1a98956 100644
--- a/tests/object/tag/write.c
+++ b/tests/object/tag/write.c
@@ -221,7 +221,7 @@ void test_object_tag_write__deleting_with_an_invalid_name_returns_EINVALIDSPEC(v
cl_assert_equal_i(GIT_EINVALIDSPEC, git_tag_delete(g_repo, "Inv@{id"));
}
-void create_annotation(git_oid *tag_id, const char *name)
+static void create_annotation(git_oid *tag_id, const char *name)
{
git_object *target;
git_oid target_id;
diff --git a/tests/odb/alternates.c b/tests/odb/alternates.c
index e36010b75..6c00fda2f 100644
--- a/tests/odb/alternates.c
+++ b/tests/odb/alternates.c
@@ -26,7 +26,7 @@ static void init_linked_repo(const char *path, const char *alternate)
git_str_clear(&filepath);
cl_git_pass(git_repository_init(&repo, path, 1));
- cl_git_pass(git_path_prettify(&destpath, alternate, NULL));
+ cl_git_pass(git_fs_path_prettify(&destpath, alternate, NULL));
cl_git_pass(git_str_joinpath(&destpath, destpath.ptr, "objects"));
cl_git_pass(git_str_joinpath(&filepath, git_repository_path(repo), "objects/info"));
cl_git_pass(git_futils_mkdir(filepath.ptr, 0755, GIT_MKDIR_PATH));
diff --git a/tests/odb/backend/backend_helpers.c b/tests/odb/backend/backend_helpers.c
index 139d2fc72..542799242 100644
--- a/tests/odb/backend/backend_helpers.c
+++ b/tests/odb/backend/backend_helpers.c
@@ -123,6 +123,18 @@ static int fake_backend__read_prefix(
return 0;
}
+static int fake_backend__refresh(git_odb_backend *backend)
+{
+ fake_backend *fake;
+
+ fake = (fake_backend *)backend;
+
+ fake->refresh_calls++;
+
+ return 0;
+}
+
+
static void fake_backend__free(git_odb_backend *_backend)
{
fake_backend *backend;
@@ -134,7 +146,8 @@ static void fake_backend__free(git_odb_backend *_backend)
int build_fake_backend(
git_odb_backend **out,
- const fake_object *objects)
+ const fake_object *objects,
+ bool support_refresh)
{
fake_backend *backend;
@@ -143,12 +156,12 @@ int build_fake_backend(
backend->parent.version = GIT_ODB_BACKEND_VERSION;
- backend->parent.refresh = NULL;
backend->objects = objects;
backend->parent.read = fake_backend__read;
backend->parent.read_prefix = fake_backend__read_prefix;
backend->parent.read_header = fake_backend__read_header;
+ backend->parent.refresh = support_refresh ? fake_backend__refresh : NULL;
backend->parent.exists = fake_backend__exists;
backend->parent.exists_prefix = fake_backend__exists_prefix;
backend->parent.free = &fake_backend__free;
diff --git a/tests/odb/backend/backend_helpers.h b/tests/odb/backend/backend_helpers.h
index 5c393c0a5..32d7a8bf0 100644
--- a/tests/odb/backend/backend_helpers.h
+++ b/tests/odb/backend/backend_helpers.h
@@ -13,10 +13,12 @@ typedef struct {
int read_calls;
int read_header_calls;
int read_prefix_calls;
+ int refresh_calls;
const fake_object *objects;
} fake_backend;
int build_fake_backend(
git_odb_backend **out,
- const fake_object *objects);
+ const fake_object *objects,
+ bool support_refresh);
diff --git a/tests/odb/backend/multiple.c b/tests/odb/backend/multiple.c
index 1c6068df3..5f1eacd52 100644
--- a/tests/odb/backend/multiple.c
+++ b/tests/odb/backend/multiple.c
@@ -29,10 +29,10 @@ void test_odb_backend_multiple__initialize(void)
_obj = NULL;
_repo = cl_git_sandbox_init("testrepo.git");
- cl_git_pass(build_fake_backend(&backend, _objects_filled));
+ cl_git_pass(build_fake_backend(&backend, _objects_filled, false));
_fake_filled = (fake_backend *)backend;
- cl_git_pass(build_fake_backend(&backend, _objects_empty));
+ cl_git_pass(build_fake_backend(&backend, _objects_empty, false));
_fake_empty = (fake_backend *)backend;
}
diff --git a/tests/odb/backend/nonrefreshing.c b/tests/odb/backend/nonrefreshing.c
index ede48ade6..2db10efbc 100644
--- a/tests/odb/backend/nonrefreshing.c
+++ b/tests/odb/backend/nonrefreshing.c
@@ -23,7 +23,7 @@ static void setup_repository_and_backend(void)
_repo = cl_git_sandbox_init("testrepo.git");
- cl_git_pass(build_fake_backend(&backend, _objects));
+ cl_git_pass(build_fake_backend(&backend, _objects, false));
cl_git_pass(git_repository_odb__weakptr(&odb, _repo));
cl_git_pass(git_odb_add_backend(odb, backend, 10));
diff --git a/tests/odb/backend/refreshing.c b/tests/odb/backend/refreshing.c
new file mode 100644
index 000000000..9e49298a8
--- /dev/null
+++ b/tests/odb/backend/refreshing.c
@@ -0,0 +1,176 @@
+#include "clar_libgit2.h"
+#include "repository.h"
+#include "backend_helpers.h"
+
+static git_repository *_repo;
+static fake_backend *_fake;
+
+#define NONEXISTING_HASH "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
+#define EXISTING_HASH "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"
+
+static const fake_object _objects[] = {
+ { EXISTING_HASH, "" },
+ { NULL, NULL }
+};
+
+static git_oid _nonexisting_oid;
+static git_oid _existing_oid;
+
+static void setup_repository_and_backend(void)
+{
+ git_odb *odb = NULL;
+ git_odb_backend *backend = NULL;
+
+ _repo = cl_git_sandbox_init("testrepo.git");
+
+ cl_git_pass(build_fake_backend(&backend, _objects, true));
+
+ cl_git_pass(git_repository_odb__weakptr(&odb, _repo));
+ cl_git_pass(git_odb_add_backend(odb, backend, 10));
+
+ _fake = (fake_backend *)backend;
+}
+
+void test_odb_backend_refreshing__initialize(void)
+{
+ git_oid_fromstr(&_nonexisting_oid, NONEXISTING_HASH);
+ git_oid_fromstr(&_existing_oid, EXISTING_HASH);
+ setup_repository_and_backend();
+}
+
+void test_odb_backend_refreshing__cleanup(void)
+{
+ cl_git_sandbox_cleanup();
+}
+
+void test_odb_backend_refreshing__exists_is_invoked_twice_on_failure(void)
+{
+ git_odb *odb;
+
+ cl_git_pass(git_repository_odb__weakptr(&odb, _repo));
+ cl_assert_equal_b(false, git_odb_exists(odb, &_nonexisting_oid));
+
+ cl_assert_equal_i(2, _fake->exists_calls);
+ cl_assert_equal_i(1, _fake->refresh_calls);
+}
+
+void test_odb_backend_refreshing__read_is_invoked_twice_on_failure(void)
+{
+ git_object *obj;
+
+ cl_git_fail_with(
+ git_object_lookup(&obj, _repo, &_nonexisting_oid, GIT_OBJECT_ANY),
+ GIT_ENOTFOUND);
+
+ cl_assert_equal_i(2, _fake->read_calls);
+ cl_assert_equal_i(1, _fake->refresh_calls);
+}
+
+void test_odb_backend_refreshing__readprefix_is_invoked_twice_on_failure(void)
+{
+ git_object *obj;
+
+ cl_git_fail_with(
+ git_object_lookup_prefix(&obj, _repo, &_nonexisting_oid, 7, GIT_OBJECT_ANY),
+ GIT_ENOTFOUND);
+
+ cl_assert_equal_i(2, _fake->read_prefix_calls);
+ cl_assert_equal_i(1, _fake->refresh_calls);
+}
+
+void test_odb_backend_refreshing__readheader_is_invoked_twice_on_failure(void)
+{
+ git_odb *odb;
+ size_t len;
+ git_object_t type;
+
+ cl_git_pass(git_repository_odb__weakptr(&odb, _repo));
+
+ cl_git_fail_with(
+ git_odb_read_header(&len, &type, odb, &_nonexisting_oid),
+ GIT_ENOTFOUND);
+
+ cl_assert_equal_i(2, _fake->read_header_calls);
+ cl_assert_equal_i(1, _fake->refresh_calls);
+}
+
+void test_odb_backend_refreshing__exists_is_invoked_once_on_success(void)
+{
+ git_odb *odb;
+
+ cl_git_pass(git_repository_odb__weakptr(&odb, _repo));
+ cl_assert_equal_b(true, git_odb_exists(odb, &_existing_oid));
+
+ cl_assert_equal_i(1, _fake->exists_calls);
+ cl_assert_equal_i(0, _fake->refresh_calls);
+}
+
+void test_odb_backend_refreshing__read_is_invoked_once_on_success(void)
+{
+ git_object *obj;
+
+ cl_git_pass(git_object_lookup(&obj, _repo, &_existing_oid, GIT_OBJECT_ANY));
+
+ cl_assert_equal_i(1, _fake->read_calls);
+ cl_assert_equal_i(0, _fake->refresh_calls);
+
+ git_object_free(obj);
+}
+
+void test_odb_backend_refreshing__readprefix_is_invoked_once_on_success(void)
+{
+ git_object *obj;
+
+ cl_git_pass(git_object_lookup_prefix(&obj, _repo, &_existing_oid, 7, GIT_OBJECT_ANY));
+
+ cl_assert_equal_i(1, _fake->read_prefix_calls);
+ cl_assert_equal_i(0, _fake->refresh_calls);
+
+ git_object_free(obj);
+}
+
+void test_odb_backend_refreshing__readheader_is_invoked_once_on_success(void)
+{
+ git_odb *odb;
+ size_t len;
+ git_object_t type;
+
+ cl_git_pass(git_repository_odb__weakptr(&odb, _repo));
+
+ cl_git_pass(git_odb_read_header(&len, &type, odb, &_existing_oid));
+
+ cl_assert_equal_i(1, _fake->read_header_calls);
+ cl_assert_equal_i(0, _fake->refresh_calls);
+}
+
+void test_odb_backend_refreshing__read_is_invoked_twice_when_revparsing_a_full_oid(void)
+{
+ git_object *obj;
+
+ cl_git_fail_with(
+ git_revparse_single(&obj, _repo, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"),
+ GIT_ENOTFOUND);
+
+ cl_assert_equal_i(2, _fake->read_calls);
+ cl_assert_equal_i(1, _fake->refresh_calls);
+}
+
+void test_odb_backend_refreshing__refresh_is_invoked(void)
+{
+ git_odb *odb;
+
+ cl_git_pass(git_repository_odb__weakptr(&odb, _repo));
+ cl_assert_equal_i(0, git_odb_refresh(odb));
+
+ cl_assert_equal_i(1, _fake->refresh_calls);
+}
+
+void test_odb_backend_refreshing__refresh_suppressed_with_no_refresh(void)
+{
+ git_odb *odb;
+
+ cl_git_pass(git_repository_odb__weakptr(&odb, _repo));
+ cl_assert_equal_b(false, git_odb_exists_ext(odb, &_nonexisting_oid, GIT_ODB_LOOKUP_NO_REFRESH));
+
+ cl_assert_equal_i(0, _fake->refresh_calls);
+}
diff --git a/tests/odb/backend/simple.c b/tests/odb/backend/simple.c
index 484dcba5a..6c9293ac0 100644
--- a/tests/odb/backend/simple.c
+++ b/tests/odb/backend/simple.c
@@ -13,7 +13,7 @@ static void setup_backend(const fake_object *objs)
{
git_odb_backend *backend;
- cl_git_pass(build_fake_backend(&backend, objs));
+ cl_git_pass(build_fake_backend(&backend, objs, false));
cl_git_pass(git_repository_odb__weakptr(&_odb, _repo));
cl_git_pass(git_odb_add_backend(_odb, backend, 10));
diff --git a/tests/odb/emptyobjects.c b/tests/odb/emptyobjects.c
index 89b22ad4a..e3ec62d3f 100644
--- a/tests/odb/emptyobjects.c
+++ b/tests/odb/emptyobjects.c
@@ -28,7 +28,7 @@ void test_odb_emptyobjects__blob_notfound(void)
cl_git_fail_with(GIT_ENOTFOUND, git_blob_lookup(&blob, g_repo, &id));
cl_git_pass(git_odb_write(&written_id, g_odb, "", 0, GIT_OBJECT_BLOB));
- cl_assert(git_path_exists(TEST_REPO_PATH "/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391"));
+ cl_assert(git_fs_path_exists(TEST_REPO_PATH "/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391"));
}
void test_odb_emptyobjects__read_tree(void)
diff --git a/tests/odb/loose.c b/tests/odb/loose.c
index 5cf567cc2..fe013a78c 100644
--- a/tests/odb/loose.c
+++ b/tests/odb/loose.c
@@ -187,7 +187,7 @@ void test_odb_loose__read_header(void)
test_read_header(&some);
}
-void test_write_object_permission(
+static void test_write_object_permission(
mode_t dir_mode, mode_t file_mode,
mode_t expected_dir_mode, mode_t expected_file_mode)
{
@@ -228,7 +228,7 @@ void test_odb_loose__permissions_standard(void)
test_write_object_permission(0, 0, GIT_OBJECT_DIR_MODE, GIT_OBJECT_FILE_MODE);
}
-void test_odb_loose_permissions_readonly(void)
+void test_odb_loose__permissions_readonly(void)
{
test_write_object_permission(0777, 0444, 0777, 0444);
}
diff --git a/tests/online/clone.c b/tests/online/clone.c
index c55cf9f95..8186dda16 100644
--- a/tests/online/clone.c
+++ b/tests/online/clone.c
@@ -194,7 +194,7 @@ void test_online_clone__can_checkout_a_cloned_repo(void)
cl_git_pass(git_clone(&g_repo, LIVE_REPO_URL, "./foo", &g_options));
cl_git_pass(git_str_joinpath(&path, git_repository_workdir(g_repo), "master.txt"));
- cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&path)));
+ cl_assert_equal_i(true, git_fs_path_isfile(git_str_cstr(&path)));
cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD"));
cl_assert_equal_i(GIT_REFERENCE_SYMBOLIC, git_reference_type(head));
@@ -361,7 +361,7 @@ void test_online_clone__cred_callback_called_again_on_auth_failure(void)
cl_assert_equal_i(3, counter);
}
-int cred_default(
+static int cred_default(
git_credential **cred,
const char *url,
const char *user_from_url,
@@ -618,7 +618,7 @@ void test_online_clone__ssh_cannot_change_username(void)
cl_git_fail(git_clone(&g_repo, "ssh://git@github.com/libgit2/TestGitRepository", "./foo", &g_options));
}
-int ssh_certificate_check(git_cert *cert, int valid, const char *host, void *payload)
+static int ssh_certificate_check(git_cert *cert, int valid, const char *host, void *payload)
{
git_cert_hostkey *key;
git_oid expected = {{0}}, actual = {{0}};
@@ -930,11 +930,11 @@ void test_online_clone__proxy_cred_callback_after_failed_url_creds(void)
void test_online_clone__azurerepos(void)
{
cl_git_pass(git_clone(&g_repo, "https://libgit2@dev.azure.com/libgit2/test/_git/test", "./foo", &g_options));
- cl_assert(git_path_exists("./foo/master.txt"));
+ cl_assert(git_fs_path_exists("./foo/master.txt"));
}
void test_online_clone__path_whitespace(void)
{
cl_git_pass(git_clone(&g_repo, "https://libgit2@dev.azure.com/libgit2/test/_git/spaces%20in%20the%20name", "./foo", &g_options));
- cl_assert(git_path_exists("./foo/master.txt"));
+ cl_assert(git_fs_path_exists("./foo/master.txt"));
}
diff --git a/tests/online/customcert.c b/tests/online/customcert.c
index 098212b14..7932a9e68 100644
--- a/tests/online/customcert.c
+++ b/tests/online/customcert.c
@@ -66,7 +66,7 @@ void test_online_customcert__file(void)
{
#if (GIT_OPENSSL || GIT_MBEDTLS)
cl_git_pass(git_clone(&g_repo, CUSTOM_CERT_ONE_URL, "./cloned", NULL));
- cl_assert(git_path_exists("./cloned/master.txt"));
+ cl_assert(git_fs_path_exists("./cloned/master.txt"));
#endif
}
@@ -74,6 +74,6 @@ void test_online_customcert__path(void)
{
#if (GIT_OPENSSL || GIT_MBEDTLS)
cl_git_pass(git_clone(&g_repo, CUSTOM_CERT_TWO_URL, "./cloned", NULL));
- cl_assert(git_path_exists("./cloned/master.txt"));
+ cl_assert(git_fs_path_exists("./cloned/master.txt"));
#endif
}
diff --git a/tests/online/push_util.c b/tests/online/push_util.c
index 94e310f3d..cd1831d4c 100644
--- a/tests/online/push_util.c
+++ b/tests/online/push_util.c
@@ -10,7 +10,7 @@ void updated_tip_free(updated_tip *t)
git__free(t);
}
-void push_status_free(push_status *s)
+static void push_status_free(push_status *s)
{
git__free(s->ref);
git__free(s->msg);
diff --git a/tests/pack/filelimit.c b/tests/pack/filelimit.c
index 2b7bf6e95..fa08485fb 100644
--- a/tests/pack/filelimit.c
+++ b/tests/pack/filelimit.c
@@ -47,7 +47,7 @@ void test_pack_filelimit__cleanup(void)
* (README.md) has the same content in all commits, but the second one
* (file.txt) has a different content in each commit.
*/
-void create_packfile_commit(
+static void create_packfile_commit(
git_repository *repo,
git_oid *out_commit_id,
git_oid *parent_id,
diff --git a/tests/pack/indexer.c b/tests/pack/indexer.c
index 5958bc4ba..954bee953 100644
--- a/tests/pack/indexer.c
+++ b/tests/pack/indexer.c
@@ -289,7 +289,7 @@ static int find_tmp_file_recurs(void *opaque, git_str *path)
return error;
if (S_ISDIR(st.st_mode))
- return git_path_direach(path, 0, find_tmp_file_recurs, opaque);
+ return git_fs_path_direach(path, 0, find_tmp_file_recurs, opaque);
/* This is the template that's used in git_futils_mktmp. */
if (strstr(git_str_cstr(path), "_git2_") != NULL)
diff --git a/tests/pack/packbuilder.c b/tests/pack/packbuilder.c
index b4c655c5e..5b1f7b9e9 100644
--- a/tests/pack/packbuilder.c
+++ b/tests/pack/packbuilder.c
@@ -156,8 +156,8 @@ void test_pack_packbuilder__write_default_path(void)
seed_packbuilder();
cl_git_pass(git_packbuilder_write(_packbuilder, NULL, 0, NULL, NULL));
- cl_assert(git_path_exists("objects/pack/pack-7f5fa362c664d68ba7221259be1cbd187434b2f0.idx"));
- cl_assert(git_path_exists("objects/pack/pack-7f5fa362c664d68ba7221259be1cbd187434b2f0.pack"));
+ cl_assert(git_fs_path_exists("objects/pack/pack-7f5fa362c664d68ba7221259be1cbd187434b2f0.idx"));
+ cl_assert(git_fs_path_exists("objects/pack/pack-7f5fa362c664d68ba7221259be1cbd187434b2f0.pack"));
}
static void test_write_pack_permission(mode_t given, mode_t expected)
diff --git a/tests/patch/print.c b/tests/patch/print.c
index b0a933943..33cf27ddb 100644
--- a/tests/patch/print.c
+++ b/tests/patch/print.c
@@ -9,7 +9,7 @@
* and then print a variety of patch files.
*/
-void patch_print_from_patchfile(const char *data, size_t len)
+static void patch_print_from_patchfile(const char *data, size_t len)
{
git_patch *patch;
git_buf buf = GIT_BUF_INIT;
diff --git a/tests/path/core.c b/tests/path/core.c
index 1d6066933..9421941c0 100644
--- a/tests/path/core.c
+++ b/tests/path/core.c
@@ -1,4 +1,5 @@
#include "clar_libgit2.h"
+#include "fs_path.h"
#include "path.h"
void test_path_core__cleanup(void)
@@ -14,7 +15,7 @@ static void test_make_relative(
{
git_str buf = GIT_STR_INIT;
git_str_puts(&buf, path);
- cl_assert_equal_i(expected_status, git_path_make_relative(&buf, parent));
+ cl_assert_equal_i(expected_status, git_fs_path_make_relative(&buf, parent));
cl_assert_equal_s(expected_path, buf.ptr);
git_str_dispose(&buf);
}
@@ -59,284 +60,252 @@ void test_path_core__make_relative(void)
void test_path_core__isvalid_standard(void)
{
- cl_assert_equal_b(true, git_path_validate(NULL, "foo/bar", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo/bar/file.txt", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo/bar/.file", 0, 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo/bar", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo/bar/file.txt", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo/bar/.file", 0));
+}
+
+/* Ensure that `is_valid_str` only reads str->size bytes */
+void test_path_core__isvalid_standard_str(void)
+{
+ git_str str = GIT_STR_INIT_CONST("foo/bar//zap", 0);
+ unsigned int flags = GIT_FS_PATH_REJECT_EMPTY_COMPONENT;
+
+ str.size = 0;
+ cl_assert_equal_b(false, git_fs_path_str_is_valid(&str, flags));
+
+ str.size = 3;
+ cl_assert_equal_b(true, git_fs_path_str_is_valid(&str, flags));
+
+ str.size = 4;
+ cl_assert_equal_b(false, git_fs_path_str_is_valid(&str, flags));
+
+ str.size = 5;
+ cl_assert_equal_b(true, git_fs_path_str_is_valid(&str, flags));
+
+ str.size = 7;
+ cl_assert_equal_b(true, git_fs_path_str_is_valid(&str, flags));
+
+ str.size = 8;
+ cl_assert_equal_b(false, git_fs_path_str_is_valid(&str, flags));
+
+ str.size = strlen(str.ptr);
+ cl_assert_equal_b(false, git_fs_path_str_is_valid(&str, flags));
}
void test_path_core__isvalid_empty_dir_component(void)
{
- cl_assert_equal_b(false, git_path_validate(NULL, "foo//bar", 0, 0));
+ unsigned int flags = GIT_FS_PATH_REJECT_EMPTY_COMPONENT;
+
+ /* empty component */
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo//bar", 0));
/* leading slash */
- cl_assert_equal_b(false, git_path_validate(NULL, "/", 0, 0));
- cl_assert_equal_b(false, git_path_validate(NULL, "/foo", 0, 0));
- cl_assert_equal_b(false, git_path_validate(NULL, "/foo/bar", 0, 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("/", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("/foo", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("/foo/bar", 0));
/* trailing slash */
- cl_assert_equal_b(false, git_path_validate(NULL, "foo/", 0, 0));
- cl_assert_equal_b(false, git_path_validate(NULL, "foo/bar/", 0, 0));
-}
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo/", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo/bar/", 0));
-void test_path_core__isvalid_dot_and_dotdot(void)
-{
- cl_assert_equal_b(true, git_path_validate(NULL, ".", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "./foo", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo/.", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "./foo", 0, 0));
-
- cl_assert_equal_b(true, git_path_validate(NULL, "..", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "../foo", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo/..", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "../foo", 0, 0));
-
- cl_assert_equal_b(false, git_path_validate(NULL, ".", 0, GIT_PATH_REJECT_TRAVERSAL));
- cl_assert_equal_b(false, git_path_validate(NULL, "./foo", 0, GIT_PATH_REJECT_TRAVERSAL));
- cl_assert_equal_b(false, git_path_validate(NULL, "foo/.", 0, GIT_PATH_REJECT_TRAVERSAL));
- cl_assert_equal_b(false, git_path_validate(NULL, "./foo", 0, GIT_PATH_REJECT_TRAVERSAL));
-
- cl_assert_equal_b(false, git_path_validate(NULL, "..", 0, GIT_PATH_REJECT_TRAVERSAL));
- cl_assert_equal_b(false, git_path_validate(NULL, "../foo", 0, GIT_PATH_REJECT_TRAVERSAL));
- cl_assert_equal_b(false, git_path_validate(NULL, "foo/..", 0, GIT_PATH_REJECT_TRAVERSAL));
- cl_assert_equal_b(false, git_path_validate(NULL, "../foo", 0, GIT_PATH_REJECT_TRAVERSAL));
+
+ /* empty component */
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo//bar", flags));
+
+ /* leading slash */
+ cl_assert_equal_b(false, git_fs_path_is_valid("/", flags));
+ cl_assert_equal_b(false, git_fs_path_is_valid("/foo", flags));
+ cl_assert_equal_b(false, git_fs_path_is_valid("/foo/bar", flags));
+
+ /* trailing slash */
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo/", flags));
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo/bar/", flags));
}
-void test_path_core__isvalid_dot_git(void)
+void test_path_core__isvalid_dot_and_dotdot(void)
{
- cl_assert_equal_b(true, git_path_validate(NULL, ".git", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, ".git/foo", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo/.git", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo/.git/bar", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo/.GIT/bar", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo/bar/.Git", 0, 0));
-
- cl_assert_equal_b(false, git_path_validate(NULL, ".git", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_validate(NULL, ".git/foo", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_validate(NULL, "foo/.git", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_validate(NULL, "foo/.git/bar", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_validate(NULL, "foo/.GIT/bar", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_validate(NULL, "foo/bar/.Git", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
-
- cl_assert_equal_b(true, git_path_validate(NULL, "!git", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo/!git", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "!git/bar", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, ".tig", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo/.tig", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, ".tig/bar", 0, 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid(".", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("./foo", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo/.", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("./foo", 0));
+
+ cl_assert_equal_b(true, git_fs_path_is_valid("..", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("../foo", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo/..", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("../foo", 0));
+
+ cl_assert_equal_b(false, git_fs_path_is_valid(".", GIT_FS_PATH_REJECT_TRAVERSAL));
+ cl_assert_equal_b(false, git_fs_path_is_valid("./foo", GIT_FS_PATH_REJECT_TRAVERSAL));
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo/.", GIT_FS_PATH_REJECT_TRAVERSAL));
+ cl_assert_equal_b(false, git_fs_path_is_valid("./foo", GIT_FS_PATH_REJECT_TRAVERSAL));
+
+ cl_assert_equal_b(false, git_fs_path_is_valid("..", GIT_FS_PATH_REJECT_TRAVERSAL));
+ cl_assert_equal_b(false, git_fs_path_is_valid("../foo", GIT_FS_PATH_REJECT_TRAVERSAL));
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo/..", GIT_FS_PATH_REJECT_TRAVERSAL));
+ cl_assert_equal_b(false, git_fs_path_is_valid("../foo", GIT_FS_PATH_REJECT_TRAVERSAL));
}
void test_path_core__isvalid_backslash(void)
{
- cl_assert_equal_b(true, git_path_validate(NULL, "foo\\file.txt", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo/bar\\file.txt", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo/bar\\", 0, 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo\\file.txt", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo/bar\\file.txt", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo/bar\\", 0));
- cl_assert_equal_b(false, git_path_validate(NULL, "foo\\file.txt", 0, GIT_PATH_REJECT_BACKSLASH));
- cl_assert_equal_b(false, git_path_validate(NULL, "foo/bar\\file.txt", 0, GIT_PATH_REJECT_BACKSLASH));
- cl_assert_equal_b(false, git_path_validate(NULL, "foo/bar\\", 0, GIT_PATH_REJECT_BACKSLASH));
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo\\file.txt", GIT_FS_PATH_REJECT_BACKSLASH));
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo/bar\\file.txt", GIT_FS_PATH_REJECT_BACKSLASH));
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo/bar\\", GIT_FS_PATH_REJECT_BACKSLASH));
}
void test_path_core__isvalid_trailing_dot(void)
{
- cl_assert_equal_b(true, git_path_validate(NULL, "foo.", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo...", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo/bar.", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo./bar", 0, 0));
-
- cl_assert_equal_b(false, git_path_validate(NULL, "foo.", 0, GIT_PATH_REJECT_TRAILING_DOT));
- cl_assert_equal_b(false, git_path_validate(NULL, "foo...", 0, GIT_PATH_REJECT_TRAILING_DOT));
- cl_assert_equal_b(false, git_path_validate(NULL, "foo/bar.", 0, GIT_PATH_REJECT_TRAILING_DOT));
- cl_assert_equal_b(false, git_path_validate(NULL, "foo./bar", 0, GIT_PATH_REJECT_TRAILING_DOT));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo.", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo...", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo/bar.", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo./bar", 0));
+
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo.", GIT_FS_PATH_REJECT_TRAILING_DOT));
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo...", GIT_FS_PATH_REJECT_TRAILING_DOT));
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo/bar.", GIT_FS_PATH_REJECT_TRAILING_DOT));
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo./bar", GIT_FS_PATH_REJECT_TRAILING_DOT));
}
void test_path_core__isvalid_trailing_space(void)
{
- cl_assert_equal_b(true, git_path_validate(NULL, "foo ", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo ", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo/bar ", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, " ", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo /bar", 0, 0));
-
- cl_assert_equal_b(false, git_path_validate(NULL, "foo ", 0, GIT_PATH_REJECT_TRAILING_SPACE));
- cl_assert_equal_b(false, git_path_validate(NULL, "foo ", 0, GIT_PATH_REJECT_TRAILING_SPACE));
- cl_assert_equal_b(false, git_path_validate(NULL, "foo/bar ", 0, GIT_PATH_REJECT_TRAILING_SPACE));
- cl_assert_equal_b(false, git_path_validate(NULL, " ", 0, GIT_PATH_REJECT_TRAILING_SPACE));
- cl_assert_equal_b(false, git_path_validate(NULL, "foo /bar", 0, GIT_PATH_REJECT_TRAILING_SPACE));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo ", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo ", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo/bar ", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid(" ", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo /bar", 0));
+
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo ", GIT_FS_PATH_REJECT_TRAILING_SPACE));
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo ", GIT_FS_PATH_REJECT_TRAILING_SPACE));
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo/bar ", GIT_FS_PATH_REJECT_TRAILING_SPACE));
+ cl_assert_equal_b(false, git_fs_path_is_valid(" ", GIT_FS_PATH_REJECT_TRAILING_SPACE));
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo /bar", GIT_FS_PATH_REJECT_TRAILING_SPACE));
}
void test_path_core__isvalid_trailing_colon(void)
{
- cl_assert_equal_b(true, git_path_validate(NULL, "foo:", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo/bar:", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, ":", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "foo:/bar", 0, 0));
-
- cl_assert_equal_b(false, git_path_validate(NULL, "foo:", 0, GIT_PATH_REJECT_TRAILING_COLON));
- cl_assert_equal_b(false, git_path_validate(NULL, "foo/bar:", 0, GIT_PATH_REJECT_TRAILING_COLON));
- cl_assert_equal_b(false, git_path_validate(NULL, ":", 0, GIT_PATH_REJECT_TRAILING_COLON));
- cl_assert_equal_b(false, git_path_validate(NULL, "foo:/bar", 0, GIT_PATH_REJECT_TRAILING_COLON));
-}
-
-void test_path_core__isvalid_dotgit_ntfs(void)
-{
- cl_assert_equal_b(true, git_path_validate(NULL, ".git", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, ".git ", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, ".git.", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, ".git.. .", 0, 0));
-
- cl_assert_equal_b(true, git_path_validate(NULL, "git~1", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "git~1 ", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "git~1.", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "git~1.. .", 0, 0));
-
- cl_assert_equal_b(false, git_path_validate(NULL, ".git", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_validate(NULL, ".git ", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_validate(NULL, ".git.", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_validate(NULL, ".git.. .", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
-
- cl_assert_equal_b(false, git_path_validate(NULL, "git~1", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_validate(NULL, "git~1 ", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_validate(NULL, "git~1.", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_validate(NULL, "git~1.. .", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo:", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo/bar:", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid(":", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo:/bar", 0));
+
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo:", GIT_FS_PATH_REJECT_TRAILING_COLON));
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo/bar:", GIT_FS_PATH_REJECT_TRAILING_COLON));
+ cl_assert_equal_b(false, git_fs_path_is_valid(":", GIT_FS_PATH_REJECT_TRAILING_COLON));
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo:/bar", GIT_FS_PATH_REJECT_TRAILING_COLON));
}
void test_path_core__isvalid_dos_paths(void)
{
- cl_assert_equal_b(true, git_path_validate(NULL, "aux", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "aux.", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "aux:", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "aux.asdf", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "aux.asdf\\zippy", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "aux:asdf\\foobar", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "con", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "prn", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "nul", 0, 0));
-
- cl_assert_equal_b(false, git_path_validate(NULL, "aux", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_validate(NULL, "aux.", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_validate(NULL, "aux:", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_validate(NULL, "aux.asdf", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_validate(NULL, "aux.asdf\\zippy", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_validate(NULL, "aux:asdf\\foobar", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_validate(NULL, "con", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_validate(NULL, "prn", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_validate(NULL, "nul", 0, GIT_PATH_REJECT_DOS_PATHS));
-
- cl_assert_equal_b(true, git_path_validate(NULL, "aux1", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "aux1", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(true, git_path_validate(NULL, "auxn", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(true, git_path_validate(NULL, "aux\\foo", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_fs_path_is_valid("aux", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("aux.", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("aux:", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("aux.asdf", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("aux.asdf\\zippy", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("aux:asdf\\foobar", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("con", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("prn", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("nul", 0));
+
+ cl_assert_equal_b(false, git_fs_path_is_valid("aux", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("aux.", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("aux:", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("aux.asdf", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("aux.asdf\\zippy", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("aux:asdf\\foobar", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("con", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("prn", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("nul", GIT_FS_PATH_REJECT_DOS_PATHS));
+
+ cl_assert_equal_b(true, git_fs_path_is_valid("aux1", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("aux1", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_fs_path_is_valid("auxn", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_fs_path_is_valid("aux\\foo", GIT_FS_PATH_REJECT_DOS_PATHS));
}
void test_path_core__isvalid_dos_paths_withnum(void)
{
- cl_assert_equal_b(true, git_path_validate(NULL, "com1", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "com1.", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "com1:", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "com1.asdf", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "com1.asdf\\zippy", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "com1:asdf\\foobar", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "com1\\foo", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "lpt1", 0, 0));
-
- cl_assert_equal_b(false, git_path_validate(NULL, "com1", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_validate(NULL, "com1.", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_validate(NULL, "com1:", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_validate(NULL, "com1.asdf", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_validate(NULL, "com1.asdf\\zippy", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_validate(NULL, "com1:asdf\\foobar", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_validate(NULL, "com1/foo", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_validate(NULL, "lpt1", 0, GIT_PATH_REJECT_DOS_PATHS));
-
- cl_assert_equal_b(true, git_path_validate(NULL, "com0", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "com0", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(true, git_path_validate(NULL, "com10", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "com10", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(true, git_path_validate(NULL, "comn", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(true, git_path_validate(NULL, "com1\\foo", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(true, git_path_validate(NULL, "lpt0", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(true, git_path_validate(NULL, "lpt10", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(true, git_path_validate(NULL, "lptn", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_fs_path_is_valid("com1", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("com1.", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("com1:", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("com1.asdf", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("com1.asdf\\zippy", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("com1:asdf\\foobar", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("com1\\foo", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("lpt1", 0));
+
+ cl_assert_equal_b(false, git_fs_path_is_valid("com1", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("com1.", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("com1:", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("com1.asdf", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("com1.asdf\\zippy", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("com1:asdf\\foobar", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("com1/foo", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("lpt1", GIT_FS_PATH_REJECT_DOS_PATHS));
+
+ cl_assert_equal_b(true, git_fs_path_is_valid("com0", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("com0", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_fs_path_is_valid("com10", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("com10", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_fs_path_is_valid("comn", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_fs_path_is_valid("com1\\foo", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_fs_path_is_valid("lpt0", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_fs_path_is_valid("lpt10", GIT_FS_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_fs_path_is_valid("lptn", GIT_FS_PATH_REJECT_DOS_PATHS));
}
void test_path_core__isvalid_nt_chars(void)
{
- cl_assert_equal_b(true, git_path_validate(NULL, "asdf\001foo", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "asdf\037bar", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "asdf<bar", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "asdf>foo", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "asdf:foo", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "asdf\"bar", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "asdf|foo", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "asdf?bar", 0, 0));
- cl_assert_equal_b(true, git_path_validate(NULL, "asdf*bar", 0, 0));
-
- cl_assert_equal_b(false, git_path_validate(NULL, "asdf\001foo", 0, GIT_PATH_REJECT_NT_CHARS));
- cl_assert_equal_b(false, git_path_validate(NULL, "asdf\037bar", 0, GIT_PATH_REJECT_NT_CHARS));
- cl_assert_equal_b(false, git_path_validate(NULL, "asdf<bar", 0, GIT_PATH_REJECT_NT_CHARS));
- cl_assert_equal_b(false, git_path_validate(NULL, "asdf>foo", 0, GIT_PATH_REJECT_NT_CHARS));
- cl_assert_equal_b(false, git_path_validate(NULL, "asdf:foo", 0, GIT_PATH_REJECT_NT_CHARS));
- cl_assert_equal_b(false, git_path_validate(NULL, "asdf\"bar", 0, GIT_PATH_REJECT_NT_CHARS));
- cl_assert_equal_b(false, git_path_validate(NULL, "asdf|foo", 0, GIT_PATH_REJECT_NT_CHARS));
- cl_assert_equal_b(false, git_path_validate(NULL, "asdf?bar", 0, GIT_PATH_REJECT_NT_CHARS));
- cl_assert_equal_b(false, git_path_validate(NULL, "asdf*bar", 0, GIT_PATH_REJECT_NT_CHARS));
-}
-
-void test_path_core__isvalid_dotgit_with_hfs_ignorables(void)
-{
- cl_assert_equal_b(false, git_path_validate(NULL, ".git", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_validate(NULL, ".git\xe2\x80\x8c", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_validate(NULL, ".gi\xe2\x80\x8dT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_validate(NULL, ".g\xe2\x80\x8eIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_validate(NULL, ".\xe2\x80\x8fgIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_validate(NULL, "\xe2\x80\xaa.gIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
-
- cl_assert_equal_b(false, git_path_validate(NULL, "\xe2\x80\xab.\xe2\x80\xacG\xe2\x80\xadI\xe2\x80\xaet", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_validate(NULL, "\xe2\x81\xab.\xe2\x80\xaaG\xe2\x81\xabI\xe2\x80\xact", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_validate(NULL, "\xe2\x81\xad.\xe2\x80\xaeG\xef\xbb\xbfIT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
-
- cl_assert_equal_b(true, git_path_validate(NULL, ".", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_validate(NULL, ".g", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_validate(NULL, ".gi", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_validate(NULL, " .git", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_validate(NULL, "..git\xe2\x80\x8c", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_validate(NULL, ".gi\xe2\x80\x8dT.", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_validate(NULL, ".g\xe2\x80It", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_validate(NULL, ".\xe2gIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_validate(NULL, "\xe2\x80\xaa.gi", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_validate(NULL, ".gi\x80\x8dT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_validate(NULL, ".gi\x8dT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_validate(NULL, ".g\xe2i\x80T\x8e", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_validate(NULL, ".git\xe2\x80\xbf", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_validate(NULL, ".git\xe2\xab\x81", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_fs_path_is_valid("asdf\001foo", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("asdf\037bar", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("asdf<bar", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("asdf>foo", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("asdf:foo", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("asdf\"bar", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("asdf|foo", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("asdf?bar", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("asdf*bar", 0));
+
+ cl_assert_equal_b(false, git_fs_path_is_valid("asdf\001foo", GIT_FS_PATH_REJECT_NT_CHARS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("asdf\037bar", GIT_FS_PATH_REJECT_NT_CHARS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("asdf<bar", GIT_FS_PATH_REJECT_NT_CHARS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("asdf>foo", GIT_FS_PATH_REJECT_NT_CHARS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("asdf:foo", GIT_FS_PATH_REJECT_NT_CHARS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("asdf\"bar", GIT_FS_PATH_REJECT_NT_CHARS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("asdf|foo", GIT_FS_PATH_REJECT_NT_CHARS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("asdf?bar", GIT_FS_PATH_REJECT_NT_CHARS));
+ cl_assert_equal_b(false, git_fs_path_is_valid("asdf*bar", GIT_FS_PATH_REJECT_NT_CHARS));
}
void test_path_core__validate_workdir(void)
{
- cl_must_pass(git_path_validate_workdir(NULL, "/foo/bar"));
- cl_must_pass(git_path_validate_workdir(NULL, "C:\\Foo\\Bar"));
- cl_must_pass(git_path_validate_workdir(NULL, "\\\\?\\C:\\Foo\\Bar"));
- cl_must_pass(git_path_validate_workdir(NULL, "\\\\?\\C:\\Foo\\Bar"));
- cl_must_pass(git_path_validate_workdir(NULL, "\\\\?\\UNC\\server\\C$\\folder"));
+ cl_must_pass(git_path_validate_length(NULL, "/foo/bar"));
+ cl_must_pass(git_path_validate_length(NULL, "C:\\Foo\\Bar"));
+ cl_must_pass(git_path_validate_length(NULL, "\\\\?\\C:\\Foo\\Bar"));
+ cl_must_pass(git_path_validate_length(NULL, "\\\\?\\C:\\Foo\\Bar"));
+ cl_must_pass(git_path_validate_length(NULL, "\\\\?\\UNC\\server\\C$\\folder"));
#ifdef GIT_WIN32
/*
* In the absense of a repo configuration, 259 character paths
* succeed. >= 260 character paths fail.
*/
- cl_must_pass(git_path_validate_workdir(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\ok.txt"));
- cl_must_pass(git_path_validate_workdir(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\260.txt"));
- cl_must_fail(git_path_validate_workdir(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\longer_than_260.txt"));
+ cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\ok.txt"));
+ cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\260.txt"));
+ cl_must_fail(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\longer_than_260.txt"));
/* count characters, not bytes */
- cl_must_pass(git_path_validate_workdir(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\260.txt"));
- cl_must_fail(git_path_validate_workdir(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\long.txt"));
+ cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\260.txt"));
+ cl_must_fail(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\long.txt"));
#else
- cl_must_pass(git_path_validate_workdir(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/ok.txt"));
- cl_must_pass(git_path_validate_workdir(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/260.txt"));
- cl_must_pass(git_path_validate_workdir(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
- cl_must_pass(git_path_validate_workdir(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\260.txt"));
- cl_must_pass(git_path_validate_workdir(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\long.txt"));
+ cl_must_pass(git_path_validate_length(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/ok.txt"));
+ cl_must_pass(git_path_validate_length(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/260.txt"));
+ cl_must_pass(git_path_validate_length(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
+ cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\260.txt"));
+ cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\long.txt"));
#endif
}
@@ -352,15 +321,15 @@ void test_path_core__validate_workdir_with_core_longpath(void)
cl_git_pass(git_repository_config(&config, repo));
/* fail by default */
- cl_must_fail(git_path_validate_workdir(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
+ cl_must_fail(git_path_validate_length(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
/* set core.longpaths explicitly on */
cl_git_pass(git_config_set_bool(config, "core.longpaths", 1));
- cl_must_pass(git_path_validate_workdir(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
+ cl_must_pass(git_path_validate_length(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
/* set core.longpaths explicitly off */
cl_git_pass(git_config_set_bool(config, "core.longpaths", 0));
- cl_must_fail(git_path_validate_workdir(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
+ cl_must_fail(git_path_validate_length(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
git_config_free(config);
git_repository_free(repo);
@@ -376,7 +345,7 @@ static void test_join_unrooted(
git_str result = GIT_STR_INIT;
ssize_t root_at;
- cl_git_pass(git_path_join_unrooted(&result, path, base, &root_at));
+ cl_git_pass(git_fs_path_join_unrooted(&result, path, base, &root_at));
cl_assert_equal_s(expected_result, result.ptr);
cl_assert_equal_i(expected_rootlen, root_at);
diff --git a/tests/path/dotgit.c b/tests/path/dotgit.c
index 2f9fcae4f..855145f42 100644
--- a/tests/path/dotgit.c
+++ b/tests/path/dotgit.c
@@ -1,4 +1,5 @@
#include "clar_libgit2.h"
+
#include "path.h"
static char *gitmodules_altnames[] = {
@@ -113,8 +114,93 @@ void test_path_dotgit__dotgit_modules(void)
void test_path_dotgit__dotgit_modules_symlink(void)
{
- cl_assert_equal_b(true, git_path_validate(NULL, ".gitmodules", 0, GIT_PATH_REJECT_DOT_GIT_HFS|GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_validate(NULL, ".gitmodules", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_validate(NULL, ".gitmodules", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_validate(NULL, ".gitmodules . .::$DATA", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".gitmodules", 0, GIT_PATH_REJECT_DOT_GIT_HFS|GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, ".gitmodules", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, ".gitmodules", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, ".gitmodules . .::$DATA", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS));
+}
+
+void test_path_dotgit__git_fs_path_is_file(void)
+{
+ cl_git_fail(git_path_is_gitfile("blob", 4, -1, GIT_PATH_FS_HFS));
+ cl_git_pass(git_path_is_gitfile("blob", 4, GIT_PATH_GITFILE_GITIGNORE, GIT_PATH_FS_HFS));
+ cl_git_pass(git_path_is_gitfile("blob", 4, GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_HFS));
+ cl_git_pass(git_path_is_gitfile("blob", 4, GIT_PATH_GITFILE_GITATTRIBUTES, GIT_PATH_FS_HFS));
+ cl_git_fail(git_path_is_gitfile("blob", 4, 3, GIT_PATH_FS_HFS));
+}
+
+void test_path_dotgit__isvalid_dot_git(void)
+{
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".git", 0, 0));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".git/foo", 0, 0));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, "foo/.git", 0, 0));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, "foo/.git/bar", 0, 0));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, "foo/.GIT/bar", 0, 0));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, "foo/bar/.Git", 0, 0));
+
+ cl_assert_equal_b(false, git_path_is_valid(NULL, ".git", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, ".git/foo", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, "foo/.git", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, "foo/.git/bar", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, "foo/.GIT/bar", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, "foo/bar/.Git", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
+
+ cl_assert_equal_b(true, git_path_is_valid(NULL, "!git", 0, 0));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, "foo/!git", 0, 0));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, "!git/bar", 0, 0));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".tig", 0, 0));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, "foo/.tig", 0, 0));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".tig/bar", 0, 0));
+}
+
+void test_path_dotgit__isvalid_dotgit_ntfs(void)
+{
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".git", 0, 0));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".git ", 0, 0));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".git.", 0, 0));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".git.. .", 0, 0));
+
+ cl_assert_equal_b(true, git_path_is_valid(NULL, "git~1", 0, 0));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, "git~1 ", 0, 0));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, "git~1.", 0, 0));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, "git~1.. .", 0, 0));
+
+ cl_assert_equal_b(false, git_path_is_valid(NULL, ".git", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, ".git ", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, ".git.", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, ".git.. .", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
+
+ cl_assert_equal_b(false, git_path_is_valid(NULL, "git~1", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, "git~1 ", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, "git~1.", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, "git~1.. .", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
+}
+
+void test_path_dotgit__isvalid_dotgit_with_hfs_ignorables(void)
+{
+ cl_assert_equal_b(false, git_path_is_valid(NULL, ".git", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, ".git\xe2\x80\x8c", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, ".gi\xe2\x80\x8dT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, ".g\xe2\x80\x8eIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, ".\xe2\x80\x8fgIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, "\xe2\x80\xaa.gIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+
+ cl_assert_equal_b(false, git_path_is_valid(NULL, "\xe2\x80\xab.\xe2\x80\xacG\xe2\x80\xadI\xe2\x80\xaet", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, "\xe2\x81\xab.\xe2\x80\xaaG\xe2\x81\xabI\xe2\x80\xact", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(false, git_path_is_valid(NULL, "\xe2\x81\xad.\xe2\x80\xaeG\xef\xbb\xbfIT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".g", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".gi", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, " .git", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, "..git\xe2\x80\x8c", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".gi\xe2\x80\x8dT.", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".g\xe2\x80It", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".\xe2gIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, "\xe2\x80\xaa.gi", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".gi\x80\x8dT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".gi\x8dT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".g\xe2i\x80T\x8e", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".git\xe2\x80\xbf", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_is_valid(NULL, ".git\xe2\xab\x81", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
}
diff --git a/tests/path/win32.c b/tests/path/win32.c
index 46b5c9f70..ff166395d 100644
--- a/tests/path/win32.c
+++ b/tests/path/win32.c
@@ -6,35 +6,27 @@
#include "win32/path_w32.h"
#endif
-void test_utf8_to_utf16(const char *utf8_in, const wchar_t *utf16_expected)
-{
#ifdef GIT_WIN32
+static void test_utf8_to_utf16(const char *utf8_in, const wchar_t *utf16_expected)
+{
git_win32_path path_utf16;
int path_utf16len;
cl_assert((path_utf16len = git_win32_path_from_utf8(path_utf16, utf8_in)) >= 0);
cl_assert_equal_wcs(utf16_expected, path_utf16);
cl_assert_equal_i(wcslen(utf16_expected), path_utf16len);
-#else
- GIT_UNUSED(utf8_in);
- GIT_UNUSED(utf16_expected);
-#endif
}
-void test_utf8_to_utf16_relative(const char* utf8_in, const wchar_t* utf16_expected)
+static void test_utf8_to_utf16_relative(const char* utf8_in, const wchar_t* utf16_expected)
{
-#ifdef GIT_WIN32
git_win32_path path_utf16;
int path_utf16len;
cl_assert((path_utf16len = git_win32_path_relative_from_utf8(path_utf16, utf8_in)) >= 0);
cl_assert_equal_wcs(utf16_expected, path_utf16);
cl_assert_equal_i(wcslen(utf16_expected), path_utf16len);
-#else
- GIT_UNUSED(utf8_in);
- GIT_UNUSED(utf16_expected);
-#endif
}
+#endif
void test_path_win32__utf8_to_utf16(void)
{
diff --git a/tests/rebase/iterator.c b/tests/rebase/iterator.c
index 49a601243..a120f28ac 100644
--- a/tests/rebase/iterator.c
+++ b/tests/rebase/iterator.c
@@ -47,7 +47,7 @@ static void test_operations(git_rebase *rebase, size_t expected_current)
}
}
-void test_iterator(bool inmemory)
+static void test_iterator(bool inmemory)
{
git_rebase *rebase;
git_rebase_options opts = GIT_REBASE_OPTIONS_INIT;
diff --git a/tests/rebase/merge.c b/tests/rebase/merge.c
index d24e4facf..5f730f750 100644
--- a/tests/rebase/merge.c
+++ b/tests/rebase/merge.c
@@ -729,7 +729,7 @@ void test_rebase_merge__copy_notes_disabled_in_config(void)
test_copy_note(NULL, 0);
}
-void rebase_checkout_progress_cb(
+static void rebase_checkout_progress_cb(
const char *path,
size_t completed_steps,
size_t total_steps,
diff --git a/tests/rebase/sign.c b/tests/rebase/sign.c
index dc99407dd..4064cf79b 100644
--- a/tests/rebase/sign.c
+++ b/tests/rebase/sign.c
@@ -86,7 +86,7 @@ committer Rebaser <rebaser@rebaser.rb> 1405694510 +0000\n";
git_rebase_free(rebase);
}
-int create_cb_signed_gpg(
+static int create_cb_signed_gpg(
git_oid *out,
const git_signature *author,
const git_signature *committer,
diff --git a/tests/refs/branches/create.c b/tests/refs/branches/create.c
index 7a49ad548..2fb11668b 100644
--- a/tests/refs/branches/create.c
+++ b/tests/refs/branches/create.c
@@ -145,7 +145,7 @@ void test_refs_branches_create__can_create_branch_with_unicode(void)
const char *expected[] = { nfc, nfd, emoji };
unsigned int i;
bool fs_decompose_unicode =
- git_path_does_fs_decompose_unicode(git_repository_path(repo));
+ git_fs_path_does_decompose_unicode(git_repository_path(repo));
retrieve_known_commit(&target, repo);
diff --git a/tests/refs/branches/delete.c b/tests/refs/branches/delete.c
index aad5c090f..077882b22 100644
--- a/tests/refs/branches/delete.c
+++ b/tests/refs/branches/delete.c
@@ -173,13 +173,13 @@ void test_refs_branches_delete__removes_empty_folders(void)
cl_git_pass(git_str_joinpath(&ref_folder, commondir, "refs/heads/some/deep"));
cl_git_pass(git_str_join3(&reflog_folder, '/', commondir, GIT_REFLOG_DIR, "refs/heads/some/deep"));
- cl_assert(git_path_exists(git_str_cstr(&ref_folder)) == true);
- cl_assert(git_path_exists(git_str_cstr(&reflog_folder)) == true);
+ cl_assert(git_fs_path_exists(git_str_cstr(&ref_folder)) == true);
+ cl_assert(git_fs_path_exists(git_str_cstr(&reflog_folder)) == true);
cl_git_pass(git_branch_delete(branch));
- cl_assert(git_path_exists(git_str_cstr(&ref_folder)) == false);
- cl_assert(git_path_exists(git_str_cstr(&reflog_folder)) == false);
+ cl_assert(git_fs_path_exists(git_str_cstr(&ref_folder)) == false);
+ cl_assert(git_fs_path_exists(git_str_cstr(&reflog_folder)) == false);
git_reference_free(branch);
git_str_dispose(&ref_folder);
diff --git a/tests/refs/branches/name.c b/tests/refs/branches/name.c
index 290916eec..efa68e32b 100644
--- a/tests/refs/branches/name.c
+++ b/tests/refs/branches/name.c
@@ -51,7 +51,7 @@ static int name_is_valid(const char *name)
return valid;
}
-void test_refs_branches_is_name_valid(void)
+void test_refs_branches_name__is_name_valid(void)
{
cl_assert_equal_i(true, name_is_valid("master"));
cl_assert_equal_i(true, name_is_valid("test/master"));
diff --git a/tests/refs/delete.c b/tests/refs/delete.c
index c76d126eb..42cc534b5 100644
--- a/tests/refs/delete.c
+++ b/tests/refs/delete.c
@@ -33,7 +33,7 @@ void test_refs_delete__packed_loose(void)
/* Ensure the loose reference exists on the file system */
cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), packed_test_head_name));
- cl_assert(git_path_exists(temp_path.ptr));
+ cl_assert(git_fs_path_exists(temp_path.ptr));
/* Lookup the reference */
cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, packed_test_head_name));
@@ -49,7 +49,7 @@ void test_refs_delete__packed_loose(void)
cl_git_fail(git_reference_lookup(&another_looked_up_ref, g_repo, packed_test_head_name));
/* Ensure the loose reference doesn't exist any longer on the file system */
- cl_assert(!git_path_exists(temp_path.ptr));
+ cl_assert(!git_fs_path_exists(temp_path.ptr));
git_reference_free(another_looked_up_ref);
git_str_dispose(&temp_path);
diff --git a/tests/refs/pack.c b/tests/refs/pack.c
index 125b1adb0..1c1cd51cb 100644
--- a/tests/refs/pack.c
+++ b/tests/refs/pack.c
@@ -63,7 +63,7 @@ void test_refs_pack__loose(void)
/* Ensure the packed-refs file exists */
cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), GIT_PACKEDREFS_FILE));
- cl_assert(git_path_exists(temp_path.ptr));
+ cl_assert(git_fs_path_exists(temp_path.ptr));
/* Ensure the known ref can still be looked up but is now packed */
cl_git_pass(git_reference_lookup(&reference, g_repo, loose_tag_ref_name));
@@ -72,7 +72,7 @@ void test_refs_pack__loose(void)
/* Ensure the known ref has been removed from the loose folder structure */
cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), loose_tag_ref_name));
- cl_assert(!git_path_exists(temp_path.ptr));
+ cl_assert(!git_fs_path_exists(temp_path.ptr));
git_reference_free(reference);
git_str_dispose(&temp_path);
diff --git a/tests/refs/ref_helpers.c b/tests/refs/ref_helpers.c
index e55364c6e..70d5d36d5 100644
--- a/tests/refs/ref_helpers.c
+++ b/tests/refs/ref_helpers.c
@@ -3,6 +3,7 @@
#include "common.h"
#include "util.h"
#include "path.h"
+#include "ref_helpers.h"
int reference_is_packed(git_reference *ref)
{
@@ -16,7 +17,7 @@ int reference_is_packed(git_reference *ref)
git_reference_name(ref)) < 0)
return -1;
- packed = !git_path_isfile(ref_path.ptr);
+ packed = !git_fs_path_isfile(ref_path.ptr);
git_str_dispose(&ref_path);
diff --git a/tests/refs/reflog/reflog.c b/tests/refs/reflog/reflog.c
index 5bb6138df..32ce7ffb7 100644
--- a/tests/refs/reflog/reflog.c
+++ b/tests/refs/reflog/reflog.c
@@ -107,15 +107,15 @@ void test_refs_reflog_reflog__renaming_the_reference_moves_the_reflog(void)
git_str_joinpath(&master_log_path, git_str_cstr(&master_log_path), "refs/heads/master");
git_str_joinpath(&moved_log_path, git_str_cstr(&moved_log_path), "refs/moved");
- cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&master_log_path)));
- cl_assert_equal_i(false, git_path_isfile(git_str_cstr(&moved_log_path)));
+ cl_assert_equal_i(true, git_fs_path_isfile(git_str_cstr(&master_log_path)));
+ cl_assert_equal_i(false, git_fs_path_isfile(git_str_cstr(&moved_log_path)));
cl_git_pass(git_reference_lookup(&master, g_repo, "refs/heads/master"));
cl_git_pass(git_reference_rename(&new_master, master, "refs/moved", 0, NULL));
git_reference_free(master);
- cl_assert_equal_i(false, git_path_isfile(git_str_cstr(&master_log_path)));
- cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&moved_log_path)));
+ cl_assert_equal_i(false, git_fs_path_isfile(git_str_cstr(&master_log_path)));
+ cl_assert_equal_i(true, git_fs_path_isfile(git_str_cstr(&moved_log_path)));
git_reference_free(new_master);
git_str_dispose(&moved_log_path);
@@ -130,13 +130,13 @@ void test_refs_reflog_reflog__deleting_the_reference_deletes_the_reflog(void)
git_str_joinpath(&master_log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
git_str_joinpath(&master_log_path, git_str_cstr(&master_log_path), "refs/heads/master");
- cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&master_log_path)));
+ cl_assert_equal_i(true, git_fs_path_isfile(git_str_cstr(&master_log_path)));
cl_git_pass(git_reference_lookup(&master, g_repo, "refs/heads/master"));
cl_git_pass(git_reference_delete(master));
git_reference_free(master);
- cl_assert_equal_i(false, git_path_isfile(git_str_cstr(&master_log_path)));
+ cl_assert_equal_i(false, git_fs_path_isfile(git_str_cstr(&master_log_path)));
git_str_dispose(&master_log_path);
}
@@ -153,7 +153,7 @@ void test_refs_reflog_reflog__removes_empty_reflog_dir(void)
git_str_joinpath(&log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
git_str_joinpath(&log_path, git_str_cstr(&log_path), "refs/heads/new-dir/new-head");
- cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&log_path)));
+ cl_assert_equal_i(true, git_fs_path_isfile(git_str_cstr(&log_path)));
cl_git_pass(git_reference_delete(ref));
git_reference_free(ref);
@@ -180,7 +180,7 @@ void test_refs_reflog_reflog__fails_gracefully_on_nonempty_reflog_dir(void)
git_str_joinpath(&log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
git_str_joinpath(&log_path, git_str_cstr(&log_path), "refs/heads/new-dir/new-head");
- cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&log_path)));
+ cl_assert_equal_i(true, git_fs_path_isfile(git_str_cstr(&log_path)));
/* delete the ref manually, leave the reflog */
cl_must_pass(p_unlink("testrepo.git/refs/heads/new-dir/new-head"));
@@ -212,7 +212,7 @@ void test_refs_reflog_reflog__reading_the_reflog_from_a_reference_with_no_log_re
git_str subtrees_log_path = GIT_STR_INIT;
git_str_join_n(&subtrees_log_path, '/', 3, git_repository_path(g_repo), GIT_REFLOG_DIR, refname);
- cl_assert_equal_i(false, git_path_isfile(git_str_cstr(&subtrees_log_path)));
+ cl_assert_equal_i(false, git_fs_path_isfile(git_str_cstr(&subtrees_log_path)));
cl_git_pass(git_reflog_read(&reflog, g_repo, refname));
diff --git a/tests/refs/reflog/reflog_helpers.c b/tests/refs/reflog/reflog_helpers.c
index 22619a4e3..2ea41ee06 100644
--- a/tests/refs/reflog/reflog_helpers.c
+++ b/tests/refs/reflog/reflog_helpers.c
@@ -2,8 +2,9 @@
#include "repository.h"
#include "reflog.h"
+#include "reflog_helpers.h"
-static int reflog_entry_tostr(git_str *out, const git_reflog_entry *entry)
+int reflog_entry_tostr(git_str *out, const git_reflog_entry *entry)
{
char old_oid[GIT_OID_HEXSZ], new_oid[GIT_OID_HEXSZ];
diff --git a/tests/refs/reflog/reflog_helpers.h b/tests/refs/reflog/reflog_helpers.h
index 80814ea28..4cd92cadc 100644
--- a/tests/refs/reflog/reflog_helpers.h
+++ b/tests/refs/reflog/reflog_helpers.h
@@ -1,10 +1,12 @@
size_t reflog_entrycount(git_repository *repo, const char *name);
#define cl_reflog_check_entry(repo, reflog, idx, old_spec, new_spec, email, message) \
- cl_reflog_check_entry_(repo, reflog, idx, old_spec, new_spec, email, message, __FILE__, __LINE__)
+ cl_reflog_check_entry_(repo, reflog, idx, old_spec, new_spec, email, message, __FILE__, __FUNCTION__, __LINE__)
void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx,
- const char *old_spec, const char *new_spec,
- const char *email, const char *message, const char *file, int line);
+ const char *old_spec, const char *new_spec,
+ const char *email, const char *message,
+ const char *file, const char *func, int line);
void reflog_print(git_repository *repo, const char *reflog_name);
+int reflog_entry_tostr(git_str *out, const git_reflog_entry *entry);
diff --git a/tests/refs/rename.c b/tests/refs/rename.c
index fa732234a..f71e65782 100644
--- a/tests/refs/rename.c
+++ b/tests/refs/rename.c
@@ -41,7 +41,7 @@ void test_refs_rename__loose(void)
/* Ensure the ref doesn't exist on the file system */
cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), new_name));
- cl_assert(!git_path_exists(temp_path.ptr));
+ cl_assert(!git_fs_path_exists(temp_path.ptr));
/* Retrieval of the reference to rename */
cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, loose_tag_ref_name));
@@ -67,7 +67,7 @@ void test_refs_rename__loose(void)
/* ...and the ref can be found in the file system */
cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), new_name));
- cl_assert(git_path_exists(temp_path.ptr));
+ cl_assert(git_fs_path_exists(temp_path.ptr));
git_reference_free(new_ref);
git_reference_free(another_looked_up_ref);
@@ -83,7 +83,7 @@ void test_refs_rename__packed(void)
/* Ensure the ref doesn't exist on the file system */
cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), packed_head_name));
- cl_assert(!git_path_exists(temp_path.ptr));
+ cl_assert(!git_fs_path_exists(temp_path.ptr));
/* The reference can however be looked-up... */
cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, packed_head_name));
@@ -109,7 +109,7 @@ void test_refs_rename__packed(void)
/* ...and the ref now happily lives in the file system */
cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), brand_new_name));
- cl_assert(git_path_exists(temp_path.ptr));
+ cl_assert(git_fs_path_exists(temp_path.ptr));
git_reference_free(new_ref);
git_reference_free(another_looked_up_ref);
@@ -125,7 +125,7 @@ void test_refs_rename__packed_doesnt_pack_others(void)
/* Ensure the other reference exists on the file system */
cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), packed_test_head_name));
- cl_assert(git_path_exists(temp_path.ptr));
+ cl_assert(git_fs_path_exists(temp_path.ptr));
/* Lookup the other reference */
cl_git_pass(git_reference_lookup(&another_looked_up_ref, g_repo, packed_test_head_name));
@@ -151,7 +151,7 @@ void test_refs_rename__packed_doesnt_pack_others(void)
cl_assert(reference_is_packed(another_looked_up_ref) == 0);
/* Ensure the other ref still exists on the file system */
- cl_assert(git_path_exists(temp_path.ptr));
+ cl_assert(git_fs_path_exists(temp_path.ptr));
git_reference_free(renamed_ref);
git_reference_free(another_looked_up_ref);
diff --git a/tests/refs/revparse.c b/tests/refs/revparse.c
index 8d3a7e057..5fb758504 100644
--- a/tests/refs/revparse.c
+++ b/tests/refs/revparse.c
@@ -329,13 +329,13 @@ static void create_fake_stash_reference_and_reflog(git_repository *repo)
git_str_joinpath(&log_path, git_repository_path(repo), "logs/refs/fakestash");
- cl_assert_equal_i(false, git_path_isfile(git_str_cstr(&log_path)));
+ cl_assert_equal_i(false, git_fs_path_isfile(git_str_cstr(&log_path)));
cl_git_pass(git_reference_lookup(&master, repo, "refs/heads/master"));
cl_git_pass(git_reference_rename(&new_master, master, "refs/fakestash", 0, NULL));
git_reference_free(master);
- cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&log_path)));
+ cl_assert_equal_i(true, git_fs_path_isfile(git_str_cstr(&log_path)));
git_str_dispose(&log_path);
git_reference_free(new_master);
diff --git a/tests/refs/shorthand.c b/tests/refs/shorthand.c
index f995d26ca..e008adc74 100644
--- a/tests/refs/shorthand.c
+++ b/tests/refs/shorthand.c
@@ -2,7 +2,7 @@
#include "repository.h"
-void assert_shorthand(git_repository *repo, const char *refname, const char *shorthand)
+static void assert_shorthand(git_repository *repo, const char *refname, const char *shorthand)
{
git_reference *ref;
diff --git a/tests/refs/tags/name.c b/tests/refs/tags/name.c
index 0ca5df7d6..1dd1760b9 100644
--- a/tests/refs/tags/name.c
+++ b/tests/refs/tags/name.c
@@ -7,7 +7,7 @@ static int name_is_valid(const char *name)
return valid;
}
-void test_refs_tags_is_name_valid(void)
+void test_refs_tags_name__is_name_valid(void)
{
cl_assert_equal_i(true, name_is_valid("sometag"));
cl_assert_equal_i(true, name_is_valid("test/sometag"));
diff --git a/tests/remote/fetch.c b/tests/remote/fetch.c
index 209c42993..370046267 100644
--- a/tests/remote/fetch.c
+++ b/tests/remote/fetch.c
@@ -62,7 +62,7 @@ void test_remote_fetch__cleanup(void) {
* @param force Whether to use a spec with '+' prefixed to force the refs
* to update
*/
-void do_time_travelling_fetch(git_oid *commit1id, git_oid *commit2id,
+static void do_time_travelling_fetch(git_oid *commit1id, git_oid *commit2id,
bool force) {
char *refspec_strs = {
force ? FORCE_FETCHSPEC : NON_FORCE_FETCHSPEC,
diff --git a/tests/remote/httpproxy.c b/tests/remote/httpproxy.c
index 8cd4371f5..f62a2545b 100644
--- a/tests/remote/httpproxy.c
+++ b/tests/remote/httpproxy.c
@@ -40,7 +40,7 @@ void test_remote_httpproxy__cleanup(void)
cl_git_sandbox_cleanup();
}
-void assert_proxy_is(const char *expected)
+static void assert_proxy_is(const char *expected)
{
git_remote *remote;
char *proxy;
@@ -57,7 +57,7 @@ void assert_proxy_is(const char *expected)
git__free(proxy);
}
-void assert_config_match(const char *config, const char *expected)
+static void assert_config_match(const char *config, const char *expected)
{
git_remote *remote;
char *proxy;
@@ -106,7 +106,7 @@ void test_remote_httpproxy__config_empty_overrides(void)
assert_config_match("remote.lg2.proxy", "");
}
-void assert_global_config_match(const char *config, const char *expected)
+static void assert_global_config_match(const char *config, const char *expected)
{
git_remote *remote;
char *proxy;
diff --git a/tests/repo/config.c b/tests/repo/config.c
index 0b9daac98..ee7e43dff 100644
--- a/tests/repo/config.c
+++ b/tests/repo/config.c
@@ -14,7 +14,7 @@ void test_repo_config__initialize(void)
git_str_clear(&path);
cl_must_pass(p_mkdir("alternate", 0777));
- cl_git_pass(git_path_prettify(&path, "alternate", NULL));
+ cl_git_pass(git_fs_path_prettify(&path, "alternate", NULL));
}
void test_repo_config__cleanup(void)
@@ -25,7 +25,7 @@ void test_repo_config__cleanup(void)
cl_git_pass(
git_futils_rmdir_r("alternate", NULL, GIT_RMDIR_REMOVE_FILES));
- cl_assert(!git_path_isdir("alternate"));
+ cl_assert(!git_fs_path_isdir("alternate"));
cl_fixture_cleanup("empty_standard_repo");
@@ -101,7 +101,7 @@ void test_repo_config__read_with_no_configs_at_all(void)
/* with none */
cl_must_pass(p_unlink("empty_standard_repo/.git/config"));
- cl_assert(!git_path_isfile("empty_standard_repo/.git/config"));
+ cl_assert(!git_fs_path_isfile("empty_standard_repo/.git/config"));
cl_git_pass(git_repository_open(&repo, "empty_standard_repo"));
git_repository__configmap_lookup_cache_clear(repo);
@@ -177,16 +177,16 @@ void test_repo_config__read_with_no_configs_at_all(void)
cl_assert_equal_i(40, val);
cl_must_pass(p_unlink("empty_standard_repo/.git/config"));
- cl_assert(!git_path_isfile("empty_standard_repo/.git/config"));
+ cl_assert(!git_fs_path_isfile("empty_standard_repo/.git/config"));
cl_must_pass(p_unlink("alternate/1/gitconfig"));
- cl_assert(!git_path_isfile("alternate/1/gitconfig"));
+ cl_assert(!git_fs_path_isfile("alternate/1/gitconfig"));
cl_must_pass(p_unlink("alternate/2/config"));
- cl_assert(!git_path_isfile("alternate/2/config"));
+ cl_assert(!git_fs_path_isfile("alternate/2/config"));
cl_must_pass(p_unlink("alternate/3/.gitconfig"));
- cl_assert(!git_path_isfile("alternate/3/.gitconfig"));
+ cl_assert(!git_fs_path_isfile("alternate/3/.gitconfig"));
git_repository__configmap_lookup_cache_clear(repo);
val = -1;
@@ -196,8 +196,8 @@ void test_repo_config__read_with_no_configs_at_all(void)
/* reopen */
- cl_assert(!git_path_isfile("empty_standard_repo/.git/config"));
- cl_assert(!git_path_isfile("alternate/3/.gitconfig"));
+ cl_assert(!git_fs_path_isfile("empty_standard_repo/.git/config"));
+ cl_assert(!git_fs_path_isfile("alternate/3/.gitconfig"));
cl_git_pass(git_repository_open(&repo, "empty_standard_repo"));
git_repository__configmap_lookup_cache_clear(repo);
@@ -206,6 +206,6 @@ void test_repo_config__read_with_no_configs_at_all(void)
cl_assert_equal_i(7, val);
git_repository_free(repo);
- cl_assert(!git_path_exists("empty_standard_repo/.git/config"));
- cl_assert(!git_path_exists("alternate/3/.gitconfig"));
+ cl_assert(!git_fs_path_exists("empty_standard_repo/.git/config"));
+ cl_assert(!git_fs_path_exists("alternate/3/.gitconfig"));
}
diff --git a/tests/repo/discover.c b/tests/repo/discover.c
index 2a24f1b29..523fdf8e3 100644
--- a/tests/repo/discover.c
+++ b/tests/repo/discover.c
@@ -33,7 +33,7 @@ static void ensure_repository_discover(const char *start_path,
git_str_attach(&resolved, p_realpath(expected_path, NULL), 0);
cl_assert(resolved.size > 0);
- cl_git_pass(git_path_to_dir(&resolved));
+ cl_git_pass(git_fs_path_to_dir(&resolved));
cl_git_pass(git_repository_discover(&found_path, start_path, 1, ceiling_dirs));
cl_assert_equal_s(found_path.ptr, resolved.ptr);
@@ -47,7 +47,7 @@ static void write_file(const char *path, const char *content)
git_file file;
int error;
- if (git_path_exists(path)) {
+ if (git_fs_path_exists(path)) {
cl_git_pass(p_unlink(path));
}
@@ -65,7 +65,7 @@ static void append_ceiling_dir(git_str *ceiling_dirs, const char *path)
git_str pretty_path = GIT_STR_INIT;
char ceiling_separator[2] = { GIT_PATH_LIST_SEPARATOR, '\0' };
- cl_git_pass(git_path_prettify_dir(&pretty_path, path, NULL));
+ cl_git_pass(git_fs_path_prettify_dir(&pretty_path, path, NULL));
if (ceiling_dirs->size > 0)
git_str_puts(ceiling_dirs, ceiling_separator);
diff --git a/tests/repo/env.c b/tests/repo/env.c
index 4bd45d1a6..e3e522480 100644
--- a/tests/repo/env.c
+++ b/tests/repo/env.c
@@ -24,11 +24,11 @@ void test_repo_env__cleanup(void)
{
cl_git_sandbox_cleanup();
- if (git_path_isdir("attr"))
+ if (git_fs_path_isdir("attr"))
git_futils_rmdir_r("attr", NULL, GIT_RMDIR_REMOVE_FILES);
- if (git_path_isdir("testrepo.git"))
+ if (git_fs_path_isdir("testrepo.git"))
git_futils_rmdir_r("testrepo.git", NULL, GIT_RMDIR_REMOVE_FILES);
- if (git_path_isdir("peeled.git"))
+ if (git_fs_path_isdir("peeled.git"))
git_futils_rmdir_r("peeled.git", NULL, GIT_RMDIR_REMOVE_FILES);
clear_git_env();
@@ -81,7 +81,7 @@ static void env_cd_(
const char *file, const char *func, int line)
{
git_str cwd_buf = GIT_STR_INIT;
- cl_git_pass(git_path_prettify_dir(&cwd_buf, ".", NULL));
+ cl_git_pass(git_fs_path_prettify_dir(&cwd_buf, ".", NULL));
cl_must_pass(p_chdir(path));
passfail_(NULL, file, func, line);
cl_must_pass(p_chdir(git_str_cstr(&cwd_buf)));
@@ -141,7 +141,7 @@ void test_repo_env__open(void)
cl_fixture_sandbox("peeled.git");
cl_git_pass(p_rename("attr/.gitted", "attr/.git"));
- cl_git_pass(git_path_prettify_dir(&repo_dir_buf, "attr", NULL));
+ cl_git_pass(git_fs_path_prettify_dir(&repo_dir_buf, "attr", NULL));
repo_dir = git_str_cstr(&repo_dir_buf);
/* GIT_DIR that doesn't exist */
diff --git a/tests/repo/init.c b/tests/repo/init.c
index b41608cca..7cf6742ca 100644
--- a/tests/repo/init.c
+++ b/tests/repo/init.c
@@ -47,7 +47,7 @@ static void ensure_repository_init(
{
const char *workdir;
- cl_assert(!git_path_isdir(working_directory));
+ cl_assert(!git_fs_path_isdir(working_directory));
cl_git_pass(git_repository_init(&g_repo, working_directory, is_bare));
@@ -103,7 +103,7 @@ void test_repo_init__bare_repo_escaping_current_workdir(void)
git_str path_repository = GIT_STR_INIT;
git_str path_current_workdir = GIT_STR_INIT;
- cl_git_pass(git_path_prettify_dir(&path_current_workdir, ".", NULL));
+ cl_git_pass(git_fs_path_prettify_dir(&path_current_workdir, ".", NULL));
cl_git_pass(git_str_joinpath(&path_repository, git_str_cstr(&path_current_workdir), "a/b/c"));
cl_git_pass(git_futils_mkdir_r(git_str_cstr(&path_repository), GIT_DIR_MODE));
@@ -176,15 +176,15 @@ void test_repo_init__additional_templates(void)
cl_git_pass(
git_str_joinpath(&path, git_repository_path(g_repo), "description"));
- cl_assert(git_path_isfile(git_str_cstr(&path)));
+ cl_assert(git_fs_path_isfile(git_str_cstr(&path)));
cl_git_pass(
git_str_joinpath(&path, git_repository_path(g_repo), "info/exclude"));
- cl_assert(git_path_isfile(git_str_cstr(&path)));
+ cl_assert(git_fs_path_isfile(git_str_cstr(&path)));
cl_git_pass(
git_str_joinpath(&path, git_repository_path(g_repo), "hooks"));
- cl_assert(git_path_isdir(git_str_cstr(&path)));
+ cl_assert(git_fs_path_isdir(git_str_cstr(&path)));
/* won't confirm specific contents of hooks dir since it may vary */
git_str_dispose(&path);
@@ -257,7 +257,7 @@ void test_repo_init__symlinks_win32_enabled_by_global_config(void)
git_config *config, *repo_config;
int val;
- if (!git_path_supports_symlinks("link"))
+ if (!git_fs_path_supports_symlinks("link"))
cl_skip();
create_tmp_global_config("tmp_global_config", "core.symlinks", "true");
@@ -303,7 +303,7 @@ void test_repo_init__symlinks_posix_detected(void)
cl_skip();
#else
assert_config_entry_on_init(
- "core.symlinks", git_path_supports_symlinks("link") ? GIT_ENOTFOUND : false);
+ "core.symlinks", git_fs_path_supports_symlinks("link") ? GIT_ENOTFOUND : false);
#endif
}
@@ -418,12 +418,12 @@ void test_repo_init__extended_1(void)
cl_assert(!git__suffixcmp(git_repository_workdir(g_repo), "/c_wd/"));
cl_assert(!git__suffixcmp(git_repository_path(g_repo), "/c.git/"));
- cl_assert(git_path_isfile("root/b/c_wd/.git"));
+ cl_assert(git_fs_path_isfile("root/b/c_wd/.git"));
cl_assert(!git_repository_is_bare(g_repo));
/* repo will not be counted as empty because we set head to "development" */
cl_assert(!git_repository_is_empty(g_repo));
- cl_git_pass(git_path_lstat(git_repository_path(g_repo), &st));
+ cl_git_pass(git_fs_path_lstat(git_repository_path(g_repo), &st));
cl_assert(S_ISDIR(st.st_mode));
if (cl_is_chmod_supported())
cl_assert((S_ISGID & st.st_mode) == S_ISGID);
@@ -482,7 +482,7 @@ void test_repo_init__relative_gitdir_2(void)
git_str dot_git_content = GIT_STR_INIT;
git_str full_path = GIT_STR_INIT;
- cl_git_pass(git_path_prettify(&full_path, ".", NULL));
+ cl_git_pass(git_fs_path_prettify(&full_path, ".", NULL));
cl_git_pass(git_str_joinpath(&full_path, full_path.ptr, "root/b/c_wd"));
opts.workdir_path = full_path.ptr;
@@ -604,16 +604,16 @@ void test_repo_init__at_filesystem_root(void)
if (!cl_is_env_set("GITTEST_INVASIVE_FS_STRUCTURE"))
cl_skip();
- root_len = git_path_root(sandbox);
+ root_len = git_fs_path_root(sandbox);
cl_assert(root_len >= 0);
git_str_put(&root, sandbox, root_len+1);
git_str_joinpath(&root, root.ptr, "libgit2_test_dir");
- cl_assert(!git_path_exists(root.ptr));
+ cl_assert(!git_fs_path_exists(root.ptr));
cl_git_pass(git_repository_init(&repo, root.ptr, 0));
- cl_assert(git_path_isdir(root.ptr));
+ cl_assert(git_fs_path_isdir(root.ptr));
cl_git_pass(git_futils_rmdir_r(root.ptr, NULL, GIT_RMDIR_REMOVE_FILES));
git_str_dispose(&root);
diff --git a/tests/repo/open.c b/tests/repo/open.c
index 6558805c8..f7ed2c373 100644
--- a/tests/repo/open.c
+++ b/tests/repo/open.c
@@ -8,7 +8,7 @@ void test_repo_open__cleanup(void)
{
cl_git_sandbox_cleanup();
- if (git_path_isdir("alternate"))
+ if (git_fs_path_isdir("alternate"))
git_futils_rmdir_r("alternate", NULL, GIT_RMDIR_REMOVE_FILES);
}
@@ -147,7 +147,7 @@ void test_repo_open__with_symlinked_config(void)
cl_git_pass(git_futils_mkdir_r("home", 0777));
cl_git_mkfile("home/.gitconfig.linked", "[global]\ntest = 4567\n");
cl_must_pass(symlink(".gitconfig.linked", "home/.gitconfig"));
- cl_git_pass(git_path_prettify(&path, "home", NULL));
+ cl_git_pass(git_fs_path_prettify(&path, "home", NULL));
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, path.ptr));
cl_git_pass(git_repository_open(&repo, "empty_standard_repo"));
@@ -191,7 +191,7 @@ void test_repo_open__from_git_new_workdir(void)
for (scan = links; *scan != NULL; scan++) {
git_str_joinpath(&link_tgt, "empty_standard_repo/.git", *scan);
- if (git_path_exists(link_tgt.ptr)) {
+ if (git_fs_path_exists(link_tgt.ptr)) {
git_str_joinpath(&link_tgt, "../../empty_standard_repo/.git", *scan);
git_str_joinpath(&link, "alternate/.git", *scan);
if (strchr(*scan, '/'))
@@ -201,7 +201,7 @@ void test_repo_open__from_git_new_workdir(void)
}
for (scan = copies; *scan != NULL; scan++) {
git_str_joinpath(&link_tgt, "empty_standard_repo/.git", *scan);
- if (git_path_exists(link_tgt.ptr)) {
+ if (git_fs_path_exists(link_tgt.ptr)) {
git_str_joinpath(&link, "alternate/.git", *scan);
cl_git_pass(git_futils_readbuffer(&body, link_tgt.ptr));
@@ -381,7 +381,7 @@ void test_repo_open__no_config(void)
/* isolate from system level configs */
cl_must_pass(p_mkdir("alternate", 0777));
- cl_git_pass(git_path_prettify(&path, "alternate", NULL));
+ cl_git_pass(git_fs_path_prettify(&path, "alternate", NULL));
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, path.ptr));
cl_git_pass(git_libgit2_opts(
diff --git a/tests/repo/setters.c b/tests/repo/setters.c
index 2c33db0db..9a965dec6 100644
--- a/tests/repo/setters.c
+++ b/tests/repo/setters.c
@@ -50,7 +50,7 @@ void test_repo_setters__setting_a_workdir_creates_a_gitlink(void)
cl_git_pass(git_repository_set_workdir(repo, "./new_workdir", true));
- cl_assert(git_path_isfile("./new_workdir/.git"));
+ cl_assert(git_fs_path_isfile("./new_workdir/.git"));
cl_git_pass(git_futils_readbuffer(&content, "./new_workdir/.git"));
cl_assert(git__prefixcmp(git_str_cstr(&content), "gitdir: ") == 0);
diff --git a/tests/repo/template.c b/tests/repo/template.c
index 6f369c6d6..e8fe266cf 100644
--- a/tests/repo/template.c
+++ b/tests/repo/template.c
@@ -56,10 +56,10 @@ static void assert_hooks_match(
struct stat expected_st, st;
cl_git_pass(git_str_joinpath(&expected, template_dir, hook_path));
- cl_git_pass(git_path_lstat(expected.ptr, &expected_st));
+ cl_git_pass(git_fs_path_lstat(expected.ptr, &expected_st));
cl_git_pass(git_str_joinpath(&actual, repo_dir, hook_path));
- cl_git_pass(git_path_lstat(actual.ptr, &st));
+ cl_git_pass(git_fs_path_lstat(actual.ptr, &st));
cl_assert(expected_st.st_size == st.st_size);
@@ -88,7 +88,7 @@ static void assert_mode_seems_okay(
struct stat st;
cl_git_pass(git_str_joinpath(&full, base, path));
- cl_git_pass(git_path_lstat(full.ptr, &st));
+ cl_git_pass(git_fs_path_lstat(full.ptr, &st));
git_str_dispose(&full);
if (!core_filemode) {
@@ -293,3 +293,13 @@ void test_repo_template__empty_template_path(void)
setup_repo("foo", &opts);
}
+
+void test_repo_template__nonexistent_template_path(void)
+{
+ git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
+
+ opts.flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE;
+ opts.template_path = "/tmp/path/that/does/not/exist/for/libgit2/test";
+
+ setup_repo("bar", &opts);
+}
diff --git a/tests/reset/hard.c b/tests/reset/hard.c
index 36e8f1470..9d177c021 100644
--- a/tests/reset/hard.c
+++ b/tests/reset/hard.c
@@ -79,7 +79,7 @@ void test_reset_hard__resetting_reverts_modified_files(void)
cl_git_pass(git_futils_readbuffer(&content, path.ptr));
cl_assert(strequal_ignore_eol(after[i], content.ptr));
} else {
- cl_assert(!git_path_exists(path.ptr));
+ cl_assert(!git_fs_path_exists(path.ptr));
}
}
@@ -154,7 +154,7 @@ void test_reset_hard__resetting_reverts_unmerged(void)
cl_git_pass(git_revparse_single(&target, repo, "26a125e"));
cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL));
- cl_assert(git_path_exists("status/conflicting_file") == 0);
+ cl_assert(git_fs_path_exists("status/conflicting_file") == 0);
git_object_free(target);
target = NULL;
@@ -185,11 +185,11 @@ void test_reset_hard__cleans_up_merge(void)
cl_git_pass(git_revparse_single(&target, repo, "0017bd4"));
cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL));
- cl_assert(!git_path_exists(git_str_cstr(&merge_head_path)));
- cl_assert(!git_path_exists(git_str_cstr(&merge_msg_path)));
- cl_assert(!git_path_exists(git_str_cstr(&merge_mode_path)));
+ cl_assert(!git_fs_path_exists(git_str_cstr(&merge_head_path)));
+ cl_assert(!git_fs_path_exists(git_str_cstr(&merge_msg_path)));
+ cl_assert(!git_fs_path_exists(git_str_cstr(&merge_mode_path)));
- cl_assert(git_path_exists(git_str_cstr(&orig_head_path)));
+ cl_assert(git_fs_path_exists(git_str_cstr(&orig_head_path)));
cl_git_pass(p_unlink(git_str_cstr(&orig_head_path)));
git_str_dispose(&merge_head_path);
diff --git a/tests/revert/workdir.c b/tests/revert/workdir.c
index 36824044b..0c9810814 100644
--- a/tests/revert/workdir.c
+++ b/tests/revert/workdir.c
@@ -111,7 +111,7 @@ void test_revert_workdir__conflicts(void)
"File one\n" \
">>>>>>> parent of 72333f4... automergeable changes\n") == 0);
- cl_assert(git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
+ cl_assert(git_fs_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
cl_git_pass(git_futils_readbuffer(&mergemsg_buf,
TEST_REPO_PATH "/.git/MERGE_MSG"));
cl_assert(strcmp(mergemsg_buf.ptr,
@@ -498,8 +498,8 @@ void test_revert_workdir__nonmerge_fails_mainline_specified(void)
opts.mainline = 1;
cl_must_fail(git_revert(repo, commit, &opts));
- cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
- cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/REVERT_HEAD"));
+ cl_assert(!git_fs_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
+ cl_assert(!git_fs_path_exists(TEST_REPO_PATH "/.git/REVERT_HEAD"));
git_reference_free(head);
git_commit_free(commit);
@@ -517,8 +517,8 @@ void test_revert_workdir__merge_fails_without_mainline_specified(void)
cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL));
cl_must_fail(git_revert(repo, head, NULL));
- cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
- cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/REVERT_HEAD"));
+ cl_assert(!git_fs_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
+ cl_assert(!git_fs_path_exists(TEST_REPO_PATH "/.git/REVERT_HEAD"));
git_commit_free(head);
}
diff --git a/tests/stash/apply.c b/tests/stash/apply.c
index c3d1ef0c2..5125ae639 100644
--- a/tests/stash/apply.c
+++ b/tests/stash/apply.c
@@ -316,7 +316,7 @@ struct seen_paths {
bool when;
};
-int checkout_notify(
+static int checkout_notify(
git_checkout_notify_t why,
const char *path,
const git_diff_file *baseline,
@@ -368,7 +368,7 @@ void test_stash_apply__executes_notify_cb(void)
cl_assert_equal_b(true, seen_paths.when);
}
-int progress_cb(
+static int progress_cb(
git_stash_apply_progress_t progress,
void *payload)
{
@@ -393,7 +393,7 @@ void test_stash_apply__calls_progress_cb(void)
cl_assert_equal_i(progress, GIT_STASH_APPLY_PROGRESS_DONE);
}
-int aborting_progress_cb(
+static int aborting_progress_cb(
git_stash_apply_progress_t progress,
void *payload)
{
diff --git a/tests/stash/drop.c b/tests/stash/drop.c
index 6b0895ba8..a57147172 100644
--- a/tests/stash/drop.c
+++ b/tests/stash/drop.c
@@ -37,26 +37,26 @@ static void push_three_states(void)
cl_git_pass(git_repository_index(&index, repo));
cl_git_pass(git_index_add_bypath(index, "zero.txt"));
cl_repo_commit_from_index(NULL, repo, signature, 0, "Initial commit");
- cl_assert(git_path_exists("stash/zero.txt"));
+ cl_assert(git_fs_path_exists("stash/zero.txt"));
git_index_free(index);
cl_git_mkfile("stash/one.txt", "content\n");
cl_git_pass(git_stash_save(
&oid, repo, signature, "First", GIT_STASH_INCLUDE_UNTRACKED));
- cl_assert(!git_path_exists("stash/one.txt"));
- cl_assert(git_path_exists("stash/zero.txt"));
+ cl_assert(!git_fs_path_exists("stash/one.txt"));
+ cl_assert(git_fs_path_exists("stash/zero.txt"));
cl_git_mkfile("stash/two.txt", "content\n");
cl_git_pass(git_stash_save(
&oid, repo, signature, "Second", GIT_STASH_INCLUDE_UNTRACKED));
- cl_assert(!git_path_exists("stash/two.txt"));
- cl_assert(git_path_exists("stash/zero.txt"));
+ cl_assert(!git_fs_path_exists("stash/two.txt"));
+ cl_assert(git_fs_path_exists("stash/zero.txt"));
cl_git_mkfile("stash/three.txt", "content\n");
cl_git_pass(git_stash_save(
&oid, repo, signature, "Third", GIT_STASH_INCLUDE_UNTRACKED));
- cl_assert(!git_path_exists("stash/three.txt"));
- cl_assert(git_path_exists("stash/zero.txt"));
+ cl_assert(!git_fs_path_exists("stash/three.txt"));
+ cl_assert(git_fs_path_exists("stash/zero.txt"));
}
void test_stash_drop__cannot_drop_a_non_existing_stashed_state(void)
@@ -140,7 +140,7 @@ void test_stash_drop__dropping_the_last_entry_removes_the_stash(void)
git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE), GIT_ENOTFOUND);
}
-void retrieve_top_stash_id(git_oid *out)
+static void retrieve_top_stash_id(git_oid *out)
{
git_object *top_stash;
diff --git a/tests/stash/save.c b/tests/stash/save.c
index 1fbcf0957..f574211d7 100644
--- a/tests/stash/save.c
+++ b/tests/stash/save.c
@@ -161,16 +161,16 @@ void test_stash_save__untracked_skips_ignored(void)
cl_must_pass(p_mkdir("stash/bundle/vendor", 0777));
cl_git_mkfile("stash/bundle/vendor/blah", "contents\n");
- cl_assert(git_path_exists("stash/when")); /* untracked */
- cl_assert(git_path_exists("stash/just.ignore")); /* ignored */
- cl_assert(git_path_exists("stash/bundle/vendor/blah")); /* ignored */
+ cl_assert(git_fs_path_exists("stash/when")); /* untracked */
+ cl_assert(git_fs_path_exists("stash/just.ignore")); /* ignored */
+ cl_assert(git_fs_path_exists("stash/bundle/vendor/blah")); /* ignored */
cl_git_pass(git_stash_save(
&stash_tip_oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED));
- cl_assert(!git_path_exists("stash/when"));
- cl_assert(git_path_exists("stash/bundle/vendor/blah"));
- cl_assert(git_path_exists("stash/just.ignore"));
+ cl_assert(!git_fs_path_exists("stash/when"));
+ cl_assert(git_fs_path_exists("stash/bundle/vendor/blah"));
+ cl_assert(git_fs_path_exists("stash/just.ignore"));
}
void test_stash_save__can_include_untracked_and_ignored_files(void)
@@ -185,7 +185,7 @@ void test_stash_save__can_include_untracked_and_ignored_files(void)
assert_blob_oid("refs/stash^3:when", "b6ed15e81e2593d7bb6265eb4a991d29dc3e628b");
assert_blob_oid("refs/stash^3:just.ignore", "78925fb1236b98b37a35e9723033e627f97aa88b");
- cl_assert(!git_path_exists("stash/just.ignore"));
+ cl_assert(!git_fs_path_exists("stash/just.ignore"));
}
/*
@@ -450,9 +450,9 @@ void test_stash_save__ignored_directory(void)
cl_git_pass(git_stash_save(&stash_tip_oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED | GIT_STASH_INCLUDE_IGNORED));
- cl_assert(!git_path_exists("stash/ignored_directory/sub/some_file"));
- cl_assert(!git_path_exists("stash/ignored_directory/sub"));
- cl_assert(!git_path_exists("stash/ignored_directory"));
+ cl_assert(!git_fs_path_exists("stash/ignored_directory/sub/some_file"));
+ cl_assert(!git_fs_path_exists("stash/ignored_directory/sub"));
+ cl_assert(!git_fs_path_exists("stash/ignored_directory"));
}
void test_stash_save__skip_submodules(void)
diff --git a/tests/status/submodules.c b/tests/status/submodules.c
index 38a39471a..d223657b4 100644
--- a/tests/status/submodules.c
+++ b/tests/status/submodules.c
@@ -36,9 +36,9 @@ void test_status_submodules__0(void)
g_repo = setup_fixture_submodules();
- cl_assert(git_path_isdir("submodules/.git"));
- cl_assert(git_path_isdir("submodules/testrepo/.git"));
- cl_assert(git_path_isfile("submodules/.gitmodules"));
+ cl_assert(git_fs_path_isdir("submodules/.git"));
+ cl_assert(git_fs_path_isdir("submodules/testrepo/.git"));
+ cl_assert(git_fs_path_isfile("submodules/.gitmodules"));
cl_git_pass(
git_status_foreach(g_repo, cb_status__count, &counts)
@@ -89,9 +89,9 @@ void test_status_submodules__1(void)
g_repo = setup_fixture_submodules();
- cl_assert(git_path_isdir("submodules/.git"));
- cl_assert(git_path_isdir("submodules/testrepo/.git"));
- cl_assert(git_path_isfile("submodules/.gitmodules"));
+ cl_assert(git_fs_path_isdir("submodules/.git"));
+ cl_assert(git_fs_path_isdir("submodules/testrepo/.git"));
+ cl_assert(git_fs_path_isfile("submodules/.gitmodules"));
status_counts_init(counts, expected_files, expected_status);
diff --git a/tests/status/worktree.c b/tests/status/worktree.c
index 4ab04094a..00c6ec2d5 100644
--- a/tests/status/worktree.c
+++ b/tests/status/worktree.c
@@ -43,7 +43,7 @@ void test_status_worktree__whole_repository(void)
cl_assert_equal_i(0, counts.wrong_sorted_path);
}
-void assert_show(
+static void assert_show(
const int entry_counts,
const char *entry_paths[],
const unsigned int entry_statuses[],
@@ -109,7 +109,7 @@ static int remove_file_cb(void *data, git_str *file)
if (git__suffixcmp(filename, ".git") == 0)
return 0;
- if (git_path_isdir(filename))
+ if (git_fs_path_isdir(filename))
cl_git_pass(git_futils_rmdir_r(filename, NULL, GIT_RMDIR_REMOVE_FILES));
else
cl_git_pass(p_unlink(git_str_cstr(file)));
@@ -126,7 +126,7 @@ void test_status_worktree__purged_worktree(void)
/* first purge the contents of the worktree */
cl_git_pass(git_str_sets(&workdir, git_repository_workdir(repo)));
- cl_git_pass(git_path_direach(&workdir, 0, remove_file_cb, NULL));
+ cl_git_pass(git_fs_path_direach(&workdir, 0, remove_file_cb, NULL));
git_str_dispose(&workdir);
/* now get status */
@@ -374,7 +374,7 @@ void test_status_worktree__issue_592(void)
repo = cl_git_sandbox_init("issue_592");
cl_git_pass(git_str_joinpath(&path, git_repository_workdir(repo), "l.txt"));
cl_git_pass(p_unlink(git_str_cstr(&path)));
- cl_assert(!git_path_exists("issue_592/l.txt"));
+ cl_assert(!git_fs_path_exists("issue_592/l.txt"));
cl_git_pass(git_status_foreach(repo, cb_status__check_592, "l.txt"));
@@ -389,7 +389,7 @@ void test_status_worktree__issue_592_2(void)
repo = cl_git_sandbox_init("issue_592");
cl_git_pass(git_str_joinpath(&path, git_repository_workdir(repo), "c/a.txt"));
cl_git_pass(p_unlink(git_str_cstr(&path)));
- cl_assert(!git_path_exists("issue_592/c/a.txt"));
+ cl_assert(!git_fs_path_exists("issue_592/c/a.txt"));
cl_git_pass(git_status_foreach(repo, cb_status__check_592, "c/a.txt"));
@@ -405,7 +405,7 @@ void test_status_worktree__issue_592_3(void)
cl_git_pass(git_str_joinpath(&path, git_repository_workdir(repo), "c"));
cl_git_pass(git_futils_rmdir_r(git_str_cstr(&path), NULL, GIT_RMDIR_REMOVE_FILES));
- cl_assert(!git_path_exists("issue_592/c/a.txt"));
+ cl_assert(!git_fs_path_exists("issue_592/c/a.txt"));
cl_git_pass(git_status_foreach(repo, cb_status__check_592, "c/a.txt"));
diff --git a/tests/submodule/add.c b/tests/submodule/add.c
index b564123dd..ae5507d7f 100644
--- a/tests/submodule/add.c
+++ b/tests/submodule/add.c
@@ -46,11 +46,11 @@ void test_submodule_add__url_absolute(void)
);
git_submodule_free(sm);
- cl_assert(git_path_isfile("submod2/" "sm_libgit2" "/.git"));
+ cl_assert(git_fs_path_isfile("submod2/" "sm_libgit2" "/.git"));
- cl_assert(git_path_isdir("submod2/.git/modules"));
- cl_assert(git_path_isdir("submod2/.git/modules/" "sm_libgit2"));
- cl_assert(git_path_isfile("submod2/.git/modules/" "sm_libgit2" "/HEAD"));
+ cl_assert(git_fs_path_isdir("submod2/.git/modules"));
+ cl_assert(git_fs_path_isdir("submod2/.git/modules/" "sm_libgit2"));
+ cl_assert(git_fs_path_isfile("submod2/.git/modules/" "sm_libgit2" "/HEAD"));
assert_submodule_url("sm_libgit2", "https://github.com/libgit2/libgit2.git");
cl_git_pass(git_repository_open(&repo, "submod2/" "sm_libgit2"));
@@ -72,9 +72,9 @@ void test_submodule_add__url_absolute(void)
);
git_submodule_free(sm);
- cl_assert(git_path_isdir("submod2/" "sm_libgit2b" "/.git"));
- cl_assert(git_path_isfile("submod2/" "sm_libgit2b" "/.git/HEAD"));
- cl_assert(!git_path_exists("submod2/.git/modules/" "sm_libgit2b"));
+ cl_assert(git_fs_path_isdir("submod2/" "sm_libgit2b" "/.git"));
+ cl_assert(git_fs_path_isfile("submod2/" "sm_libgit2b" "/.git/HEAD"));
+ cl_assert(!git_fs_path_exists("submod2/.git/modules/" "sm_libgit2b"));
assert_submodule_url("sm_libgit2b", "https://github.com/libgit2/libgit2.git");
}
@@ -227,7 +227,7 @@ void test_submodule_add__submodule_clone_into_nonempty_dir_succeeds(void)
cl_git_pass(git_submodule_clone(NULL, sm, NULL));
cl_git_pass(git_submodule_add_finalize(sm));
- cl_assert(git_path_exists("empty_standard_repo/sm/foobar"));
+ cl_assert(git_fs_path_exists("empty_standard_repo/sm/foobar"));
assert_submodule_exists(g_repo, "sm");
diff --git a/tests/submodule/init.c b/tests/submodule/init.c
index bf865a9e8..a8e1291c4 100644
--- a/tests/submodule/init.c
+++ b/tests/submodule/init.c
@@ -20,7 +20,7 @@ void test_submodule_init__absolute_url(void)
g_repo = setup_fixture_submodule_simple();
- cl_assert(git_path_dirname_r(&absolute_url, git_repository_workdir(g_repo)) > 0);
+ cl_assert(git_fs_path_dirname_r(&absolute_url, git_repository_workdir(g_repo)) > 0);
cl_git_pass(git_str_joinpath(&absolute_url, absolute_url.ptr, "testrepo.git"));
/* write the absolute url to the .gitmodules file*/
@@ -53,7 +53,7 @@ void test_submodule_init__relative_url(void)
g_repo = setup_fixture_submodule_simple();
- cl_assert(git_path_dirname_r(&absolute_url, git_repository_workdir(g_repo)) > 0);
+ cl_assert(git_fs_path_dirname_r(&absolute_url, git_repository_workdir(g_repo)) > 0);
cl_git_pass(git_str_joinpath(&absolute_url, absolute_url.ptr, "testrepo.git"));
cl_git_pass(git_submodule_lookup(&sm, g_repo, "testrepo"));
@@ -91,7 +91,7 @@ void test_submodule_init__relative_url_detached_head(void)
cl_git_pass(git_repository_set_head_detached(g_repo, git_commit_id((git_commit *)head_commit)));
- cl_assert(git_path_dirname_r(&absolute_url, git_repository_workdir(g_repo)) > 0);
+ cl_assert(git_fs_path_dirname_r(&absolute_url, git_repository_workdir(g_repo)) > 0);
cl_git_pass(git_str_joinpath(&absolute_url, absolute_url.ptr, "testrepo.git"));
cl_git_pass(git_submodule_lookup(&sm, g_repo, "testrepo"));
diff --git a/tests/submodule/modify.c b/tests/submodule/modify.c
index fd3b0f80b..7e7f0ca15 100644
--- a/tests/submodule/modify.c
+++ b/tests/submodule/modify.c
@@ -128,7 +128,7 @@ void test_submodule_modify__sync(void)
git_submodule_free(sm3);
}
-void assert_ignore_change(git_submodule_ignore_t ignore)
+static void assert_ignore_change(git_submodule_ignore_t ignore)
{
git_submodule *sm;
@@ -146,7 +146,7 @@ void test_submodule_modify__set_ignore(void)
assert_ignore_change(GIT_SUBMODULE_IGNORE_ALL);
}
-void assert_update_change(git_submodule_update_t update)
+static void assert_update_change(git_submodule_update_t update)
{
git_submodule *sm;
@@ -164,7 +164,7 @@ void test_submodule_modify__set_update(void)
assert_update_change(GIT_SUBMODULE_UPDATE_CHECKOUT);
}
-void assert_recurse_change(git_submodule_recurse_t recurse)
+static void assert_recurse_change(git_submodule_recurse_t recurse)
{
git_submodule *sm;
diff --git a/tests/submodule/open.c b/tests/submodule/open.c
index 4f31feedf..e6883d208 100644
--- a/tests/submodule/open.c
+++ b/tests/submodule/open.c
@@ -27,9 +27,9 @@ static void assert_sm_valid(git_repository *parent, git_repository *child, const
/* assert working directory */
cl_git_pass(git_str_joinpath(&expected, git_repository_workdir(parent), sm_name));
- cl_git_pass(git_path_prettify_dir(&expected, expected.ptr, NULL));
+ cl_git_pass(git_fs_path_prettify_dir(&expected, expected.ptr, NULL));
cl_git_pass(git_str_sets(&actual, git_repository_workdir(child)));
- cl_git_pass(git_path_prettify_dir(&actual, actual.ptr, NULL));
+ cl_git_pass(git_fs_path_prettify_dir(&actual, actual.ptr, NULL));
cl_assert_equal_s(expected.ptr, actual.ptr);
git_str_clear(&expected);
@@ -38,14 +38,14 @@ static void assert_sm_valid(git_repository *parent, git_repository *child, const
/* assert common directory */
cl_git_pass(git_str_joinpath(&expected, git_repository_commondir(parent), "modules"));
cl_git_pass(git_str_joinpath(&expected, expected.ptr, sm_name));
- cl_git_pass(git_path_prettify_dir(&expected, expected.ptr, NULL));
+ cl_git_pass(git_fs_path_prettify_dir(&expected, expected.ptr, NULL));
cl_git_pass(git_str_sets(&actual, git_repository_commondir(child)));
- cl_git_pass(git_path_prettify_dir(&actual, actual.ptr, NULL));
+ cl_git_pass(git_fs_path_prettify_dir(&actual, actual.ptr, NULL));
cl_assert_equal_s(expected.ptr, actual.ptr);
/* assert git directory */
cl_git_pass(git_str_sets(&actual, git_repository_path(child)));
- cl_git_pass(git_path_prettify_dir(&actual, actual.ptr, NULL));
+ cl_git_pass(git_fs_path_prettify_dir(&actual, actual.ptr, NULL));
cl_assert_equal_s(expected.ptr, actual.ptr);
git_str_dispose(&expected);
diff --git a/tests/submodule/repository_init.c b/tests/submodule/repository_init.c
index 3927afc2e..39b55c403 100644
--- a/tests/submodule/repository_init.c
+++ b/tests/submodule/repository_init.c
@@ -26,11 +26,11 @@ void test_submodule_repository_init__basic(void)
cl_git_pass(git_futils_readbuffer(&dot_git_content, "submod2/" "sm_gitmodules_only" "/.git"));
cl_assert_equal_s("gitdir: ../.git/modules/sm_gitmodules_only/", dot_git_content.ptr);
- cl_assert(git_path_isfile("submod2/" "sm_gitmodules_only" "/.git"));
+ cl_assert(git_fs_path_isfile("submod2/" "sm_gitmodules_only" "/.git"));
- cl_assert(git_path_isdir("submod2/.git/modules"));
- cl_assert(git_path_isdir("submod2/.git/modules/" "sm_gitmodules_only"));
- cl_assert(git_path_isfile("submod2/.git/modules/" "sm_gitmodules_only" "/HEAD"));
+ cl_assert(git_fs_path_isdir("submod2/.git/modules"));
+ cl_assert(git_fs_path_isdir("submod2/.git/modules/" "sm_gitmodules_only"));
+ cl_assert(git_fs_path_isfile("submod2/.git/modules/" "sm_gitmodules_only" "/HEAD"));
git_submodule_free(sm);
git_repository_free(repo);
diff --git a/tests/submodule/submodule_helpers.c b/tests/submodule/submodule_helpers.c
index 95d20a009..b8fc9f60d 100644
--- a/tests/submodule/submodule_helpers.c
+++ b/tests/submodule/submodule_helpers.c
@@ -65,7 +65,7 @@ void rewrite_gitmodules(const char *workdir)
continue;
}
- git_path_prettify(&path, path.ptr, NULL);
+ git_fs_path_prettify(&path, path.ptr, NULL);
git_str_putc(&path, '\n');
cl_assert(!git_str_oom(&path));
diff --git a/tests/worktree/merge.c b/tests/worktree/merge.c
index 8bb95d1f7..5b7e2a837 100644
--- a/tests/worktree/merge.c
+++ b/tests/worktree/merge.c
@@ -73,7 +73,7 @@ void test_worktree_merge__merge_setup(void)
cl_git_pass(git_str_joinpath(&path,
fixture.worktree->gitdir,
merge_files[i]));
- cl_assert(git_path_exists(path.ptr));
+ cl_assert(git_fs_path_exists(path.ptr));
}
git_str_dispose(&path);
diff --git a/tests/worktree/refs.c b/tests/worktree/refs.c
index 5ae17ca19..557726aaf 100644
--- a/tests/worktree/refs.c
+++ b/tests/worktree/refs.c
@@ -181,14 +181,14 @@ void test_worktree_refs__creating_refs_uses_commondir(void)
cl_git_pass(git_str_joinpath(&refpath,
git_repository_commondir(fixture.worktree), "refs/heads/testbranch"));
- cl_assert(!git_path_exists(refpath.ptr));
+ cl_assert(!git_fs_path_exists(refpath.ptr));
cl_git_pass(git_repository_head(&head, fixture.worktree));
cl_git_pass(git_commit_lookup(&commit, fixture.worktree, git_reference_target(head)));
cl_git_pass(git_branch_create(&branch, fixture.worktree, "testbranch", commit, 0));
cl_git_pass(git_branch_lookup(&lookup, fixture.worktree, "testbranch", GIT_BRANCH_LOCAL));
cl_assert(git_reference_cmp(branch, lookup) == 0);
- cl_assert(git_path_exists(refpath.ptr));
+ cl_assert(git_fs_path_exists(refpath.ptr));
git_reference_free(lookup);
git_reference_free(branch);
diff --git a/tests/worktree/submodule.c b/tests/worktree/submodule.c
index 4c6c657d3..6b0c07452 100644
--- a/tests/worktree/submodule.c
+++ b/tests/worktree/submodule.c
@@ -67,7 +67,7 @@ void test_worktree_submodule__resolve_relative_url(void)
git_worktree *wt;
cl_git_pass(git_futils_mkdir("subdir", 0755, GIT_MKDIR_PATH));
- cl_git_pass(git_path_prettify_dir(&wt_path, "subdir", NULL));
+ cl_git_pass(git_fs_path_prettify_dir(&wt_path, "subdir", NULL));
cl_git_pass(git_str_joinpath(&wt_path, wt_path.ptr, "wt"));
/* Open child repository, which is a submodule */
diff --git a/tests/worktree/worktree.c b/tests/worktree/worktree.c
index a9a50fbf1..6f14b17f1 100644
--- a/tests/worktree/worktree.c
+++ b/tests/worktree/worktree.c
@@ -330,7 +330,7 @@ void test_worktree_worktree__init_existing_path(void)
for (i = 0; i < ARRAY_SIZE(wtfiles); i++) {
cl_git_pass(git_str_joinpath(&path,
fixture.worktree->gitdir, wtfiles[i]));
- cl_assert(!git_path_exists(path.ptr));
+ cl_assert(!git_fs_path_exists(path.ptr));
}
git_str_dispose(&path);
@@ -351,9 +351,9 @@ void test_worktree_worktree__init_submodule(void)
cl_git_pass(git_worktree_add(&worktree, sm, "repo-worktree", path.ptr, NULL));
cl_git_pass(git_repository_open_from_worktree(&wt, worktree));
- cl_git_pass(git_path_prettify_dir(&path, path.ptr, NULL));
+ cl_git_pass(git_fs_path_prettify_dir(&path, path.ptr, NULL));
cl_assert_equal_s(path.ptr, wt->workdir);
- cl_git_pass(git_path_prettify_dir(&path, sm->commondir, NULL));
+ cl_git_pass(git_fs_path_prettify_dir(&path, sm->commondir, NULL));
cl_assert_equal_s(sm->commondir, wt->commondir);
cl_git_pass(git_str_joinpath(&path, sm->gitdir, "worktrees/repo-worktree/"));
@@ -560,8 +560,8 @@ void test_worktree_worktree__prune_gitdir_only(void)
cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
cl_git_pass(git_worktree_prune(wt, &opts));
- cl_assert(!git_path_exists(wt->gitdir_path));
- cl_assert(git_path_exists(wt->gitlink_path));
+ cl_assert(!git_fs_path_exists(wt->gitdir_path));
+ cl_assert(git_fs_path_exists(wt->gitlink_path));
git_worktree_free(wt);
}
@@ -576,8 +576,8 @@ void test_worktree_worktree__prune_worktree(void)
cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
cl_git_pass(git_worktree_prune(wt, &opts));
- cl_assert(!git_path_exists(wt->gitdir_path));
- cl_assert(!git_path_exists(wt->gitlink_path));
+ cl_assert(!git_fs_path_exists(wt->gitdir_path));
+ cl_assert(!git_fs_path_exists(wt->gitlink_path));
git_worktree_free(wt);
}