Commit 95117d47 by Edward Thomson Committed by Edward Thomson

path: separate git-specific path functions from util

Introduce `git_fs_path`, which operates on generic filesystem paths.
`git_path` will be kept for only git-specific path functionality (for
example, checking for `.git` in a path).
parent 44ec8b5c
......@@ -52,7 +52,7 @@ int main(int argc, char **argv)
fprintf(stderr, "Running %s against %s\n", argv[0], argv[1]);
LLVMFuzzerInitialize(&argc, &argv);
if (git_path_dirload(&corpus_files, argv[1], 0, 0x0) < 0) {
if (git_fs_path_dirload(&corpus_files, argv[1], 0, 0x0) < 0) {
fprintf(stderr, "Failed to scan corpus directory '%s': %s\n",
argv[1], git_error_last()->message);
error = -1;
......
......@@ -629,7 +629,7 @@ static int collect_attr_files(
const char *workdir = git_repository_workdir(repo);
attr_walk_up_info info = { NULL };
GIT_ASSERT(!git_path_is_absolute(path));
GIT_ASSERT(!git_fs_path_is_absolute(path));
if ((error = attr_setup(repo, attr_session, opts)) < 0)
return error;
......@@ -637,10 +637,10 @@ static int collect_attr_files(
/* Resolve path in a non-bare repo */
if (workdir != NULL) {
if (!(error = git_repository_workdir_path(&dir, repo, path)))
error = git_path_find_dir(&dir);
error = git_fs_path_find_dir(&dir);
}
else {
error = git_path_dirname_r(&dir, path);
error = git_fs_path_dirname_r(&dir, path);
}
if (error < 0)
......@@ -670,7 +670,7 @@ static int collect_attr_files(
if (!strcmp(dir.ptr, "."))
error = push_one_attr(&info, "");
else
error = git_path_walk_up(&dir, workdir, push_one_attr, &info);
error = git_fs_path_walk_up(&dir, workdir, push_one_attr, &info);
if (error < 0)
goto cleanup;
......
......@@ -345,7 +345,7 @@ int git_attr_file__parse_buffer(
int error = 0;
/* If subdir file path, convert context for file paths */
if (attrs->entry && git_path_root(attrs->entry->path) < 0 &&
if (attrs->entry && git_fs_path_root(attrs->entry->path) < 0 &&
!git__suffixcmp(attrs->entry->path, "/" GIT_ATTR_FILE))
context = attrs->entry->path;
......@@ -560,7 +560,7 @@ int git_attr_path__init(
/* build full path as best we can */
git_str_init(&info->full, 0);
if (git_path_join_unrooted(&info->full, path, base, &root) < 0)
if (git_fs_path_join_unrooted(&info->full, path, base, &root) < 0)
return -1;
info->path = info->full.ptr + root;
......@@ -596,7 +596,7 @@ int git_attr_path__init(
case GIT_DIR_FLAG_UNKNOWN:
default:
info->is_dir = (int)git_path_isdir(info->full.ptr);
info->is_dir = (int)git_fs_path_isdir(info->full.ptr);
break;
}
......
......@@ -47,7 +47,7 @@ int git_attr_cache__alloc_file_entry(
size_t cachesize = sizeof(git_attr_file_entry) + pathlen + 1;
git_attr_file_entry *ce;
if (base != NULL && git_path_root(path) < 0) {
if (base != NULL && git_fs_path_root(path) < 0) {
baselen = strlen(base);
cachesize += baselen;
......@@ -66,7 +66,7 @@ int git_attr_cache__alloc_file_entry(
}
memcpy(&ce->fullpath[baselen], path, pathlen);
if (git_path_validate_workdir_with_len(repo, ce->fullpath, pathlen + baselen) < 0)
if (git_fs_path_validate_workdir_with_len(repo, ce->fullpath, pathlen + baselen) < 0)
return -1;
ce->path = &ce->fullpath[baselen];
......@@ -169,11 +169,11 @@ static int attr_cache_lookup(
git_attr_file *file = NULL;
/* join base and path as needed */
if (source->base != NULL && git_path_root(source->filename) < 0) {
if (source->base != NULL && git_fs_path_root(source->filename) < 0) {
git_str *p = attr_session ? &attr_session->tmp : &path;
if (git_str_joinpath(p, source->base, source->filename) < 0 ||
git_path_validate_workdir_buf(repo, p) < 0)
git_fs_path_validate_workdir_buf(repo, p) < 0)
return -1;
filename = p->ptr;
......
......@@ -205,7 +205,7 @@ int git_blob__create_from_paths(
content_path = path.ptr;
}
if ((error = git_path_lstat(content_path, &st)) < 0 ||
if ((error = git_fs_path_lstat(content_path, &st)) < 0 ||
(error = git_repository_odb(&odb, repo)) < 0)
goto done;
......@@ -280,7 +280,7 @@ int git_blob_create_from_disk(
git_str full_path = GIT_STR_INIT;
const char *workdir, *hintpath = NULL;
if ((error = git_path_prettify(&full_path, path, NULL)) < 0) {
if ((error = git_fs_path_prettify(&full_path, path, NULL)) < 0) {
git_str_dispose(&full_path);
return error;
}
......
......@@ -27,10 +27,11 @@
#include "diff_generate.h"
#include "pathspec.h"
#include "diff_xdiff.h"
#include "path.h"
#include "fs_path.h"
#include "attr.h"
#include "pool.h"
#include "strmap.h"
#include "path.h"
/* See docs/checkout-internals.md for more information */
......@@ -328,7 +329,7 @@ static int checkout_target_fullpath(
if (path && git_str_puts(&data->target_path, path) < 0)
return -1;
if (git_path_validate_workdir_buf(data->repo, &data->target_path) < 0)
if (git_fs_path_validate_workdir_buf(data->repo, &data->target_path) < 0)
return -1;
*out = &data->target_path;
......@@ -347,7 +348,7 @@ static bool wd_item_is_removable(
if (checkout_target_fullpath(&full, data, wd->path) < 0)
return false;
return !full || !git_path_contains(full, DOT_GIT);
return !full || !git_fs_path_contains(full, DOT_GIT);
}
static int checkout_queue_remove(checkout_data *data, const char *path)
......@@ -481,7 +482,7 @@ static bool checkout_is_empty_dir(checkout_data *data, const char *path)
if (checkout_target_fullpath(&fullpath, data, path) < 0)
return false;
return git_path_is_empty_dir(fullpath->ptr);
return git_fs_path_is_empty_dir(fullpath->ptr);
}
static int checkout_action_with_wd(
......@@ -1201,12 +1202,12 @@ static int checkout_conflicts_mark_directoryfile(
goto done;
}
prefixed = git_path_equal_or_prefixed(path, entry->path, NULL);
prefixed = git_fs_path_equal_or_prefixed(path, entry->path, NULL);
if (prefixed == GIT_PATH_EQUAL)
if (prefixed == GIT_FS_PATH_EQUAL)
continue;
if (prefixed == GIT_PATH_PREFIX)
if (prefixed == GIT_FS_PATH_PREFIX)
conflict->directoryfile = 1;
break;
......@@ -1949,7 +1950,7 @@ static int checkout_path_suffixed(git_str *path, const char *suffix)
path_len = git_str_len(path);
while (git_path_exists(git_str_cstr(path)) && i < INT_MAX) {
while (git_fs_path_exists(git_str_cstr(path)) && i < INT_MAX) {
git_str_truncate(path, path_len);
if ((error = git_str_putc(path, '_')) < 0 ||
......@@ -2034,7 +2035,7 @@ static int checkout_merge_path(
int error = 0;
if ((error = git_str_joinpath(out, data->opts.target_directory, result->path)) < 0 ||
(error = git_path_validate_workdir_buf(data->repo, out)) < 0)
(error = git_fs_path_validate_workdir_buf(data->repo, out)) < 0)
return error;
/* Most conflicts simply use the filename in the index */
......@@ -2337,10 +2338,10 @@ static int validate_target_directory(checkout_data *data)
{
int error;
if ((error = git_path_validate_workdir(data->repo, data->opts.target_directory)) < 0)
if ((error = git_fs_path_validate_workdir(data->repo, data->opts.target_directory)) < 0)
return error;
if (git_path_isdir(data->opts.target_directory))
if (git_fs_path_isdir(data->opts.target_directory))
return 0;
error = checkout_mkdir(data, data->opts.target_directory, NULL,
......@@ -2507,7 +2508,7 @@ static int checkout_data_init(
(error = git_vector_init(&data->remove_conflicts, 0, NULL)) < 0 ||
(error = git_vector_init(&data->update_conflicts, 0, NULL)) < 0 ||
(error = git_str_puts(&data->target_path, data->opts.target_directory)) < 0 ||
(error = git_path_to_dir(&data->target_path)) < 0 ||
(error = git_fs_path_to_dir(&data->target_path)) < 0 ||
(error = git_strmap_new(&data->mkdir_map)) < 0)
goto cleanup;
......
......@@ -19,7 +19,7 @@
#include "remote.h"
#include "futils.h"
#include "refs.h"
#include "path.h"
#include "fs_path.h"
#include "repository.h"
#include "odb.h"
......@@ -333,7 +333,7 @@ static int create_and_configure_origin(
void *payload = options->remote_cb_payload;
/* If the path exists and is a dir, the url should be the absolute path */
if (git_path_root(url) < 0 && git_path_exists(url) && git_path_isdir(url)) {
if (git_fs_path_root(url) < 0 && git_fs_path_exists(url) && git_fs_path_isdir(url)) {
if (p_realpath(url, buf) == NULL)
return -1;
......@@ -433,8 +433,8 @@ int git_clone__should_clone_local(const char *url_or_path, git_clone_local_t loc
if (local == GIT_CLONE_NO_LOCAL)
return 0;
if ((is_url = git_path_is_local_file_url(url_or_path)) != 0) {
if (git_path_fromurl(&fromurl, url_or_path) < 0) {
if ((is_url = git_fs_path_is_local_file_url(url_or_path)) != 0) {
if (git_fs_path_fromurl(&fromurl, url_or_path) < 0) {
is_local = -1;
goto done;
}
......@@ -443,7 +443,7 @@ int git_clone__should_clone_local(const char *url_or_path, git_clone_local_t loc
}
is_local = (!is_url || local != GIT_CLONE_LOCAL_AUTO) &&
git_path_isdir(path);
git_fs_path_isdir(path);
done:
git_str_dispose(&fromurl);
......@@ -474,14 +474,14 @@ static int git__clone(
GIT_ERROR_CHECK_VERSION(&options, GIT_CLONE_OPTIONS_VERSION, "git_clone_options");
/* Only clone to a new directory or an empty directory */
if (git_path_exists(local_path) && !use_existing && !git_path_is_empty_dir(local_path)) {
if (git_fs_path_exists(local_path) && !use_existing && !git_fs_path_is_empty_dir(local_path)) {
git_error_set(GIT_ERROR_INVALID,
"'%s' exists and is not an empty directory", local_path);
return GIT_EEXISTS;
}
/* Only remove the root directory on failure if we create it */
if (git_path_exists(local_path))
if (git_fs_path_exists(local_path))
rmdir_flags |= GIT_RMDIR_SKIP_ROOT;
if (options.repository_cb)
......@@ -602,7 +602,7 @@ static int clone_local_into(git_repository *repo, git_remote *remote, const git_
* repo, if it's not rooted, the path should be relative to
* the repository's worktree/gitdir.
*/
if ((error = git_path_from_url_or_path(&src_path, git_remote_url(remote))) < 0)
if ((error = git_fs_path_from_url_or_path(&src_path, git_remote_url(remote))) < 0)
return error;
/* Copy .git/objects/ from the source to the target */
......
......@@ -1177,7 +1177,7 @@ int git_config__find_programdata(git_str *path)
if (ret != GIT_OK)
return ret;
return git_path_validate_system_file_ownership(path->ptr);
return git_fs_path_validate_system_file_ownership(path->ptr);
}
int git_config__global_location(git_str *buf)
......
......@@ -108,7 +108,7 @@ static int config_file_open(git_config_backend *cfg, git_config_level_t level, c
if ((res = git_config_entries_new(&b->entries)) < 0)
return res;
if (!git_path_exists(b->file.path))
if (!git_fs_path_exists(b->file.path))
return 0;
/*
......@@ -529,7 +529,7 @@ static int included_path(git_str *out, const char *dir, const char *path)
if (path[0] == '~' && path[1] == '/')
return git_sysdir_expand_global_file(out, &path[1]);
return git_path_join_unrooted(out, path, dir, NULL);
return git_fs_path_join_unrooted(out, path, dir, NULL);
}
/* Escape the values to write them to the file */
......@@ -574,7 +574,7 @@ static int parse_include(config_file_parse_data *parse_data, const char *file)
if (!file)
return 0;
if ((result = git_path_dirname_r(&path, parse_data->file->path)) < 0)
if ((result = git_fs_path_dirname_r(&path, parse_data->file->path)) < 0)
return result;
dir = git_str_detach(&path);
......@@ -611,17 +611,17 @@ static int do_match_gitdir(
git_str pattern = GIT_STR_INIT, gitdir = GIT_STR_INIT;
int error;
if (condition[0] == '.' && git_path_is_dirsep(condition[1])) {
git_path_dirname_r(&pattern, cfg_file);
if (condition[0] == '.' && git_fs_path_is_dirsep(condition[1])) {
git_fs_path_dirname_r(&pattern, cfg_file);
git_str_joinpath(&pattern, pattern.ptr, condition + 2);
} else if (condition[0] == '~' && git_path_is_dirsep(condition[1]))
} else if (condition[0] == '~' && git_fs_path_is_dirsep(condition[1]))
git_sysdir_expand_global_file(&pattern, condition + 1);
else if (!git_path_is_absolute(condition))
else if (!git_fs_path_is_absolute(condition))
git_str_joinpath(&pattern, "**", condition);
else
git_str_sets(&pattern, condition);
if (git_path_is_dirsep(condition[strlen(condition) - 1]))
if (git_fs_path_is_dirsep(condition[strlen(condition) - 1]))
git_str_puts(&pattern, "**");
if (git_str_oom(&pattern)) {
......@@ -632,7 +632,7 @@ static int do_match_gitdir(
if ((error = git_repository__item_path(&gitdir, repo, GIT_REPOSITORY_ITEM_GITDIR)) < 0)
goto out;
if (git_path_is_dirsep(gitdir.ptr[gitdir.size - 1]))
if (git_fs_path_is_dirsep(gitdir.ptr[gitdir.size - 1]))
git_str_truncate(&gitdir, gitdir.size - 1);
*matches = wildmatch(pattern.ptr, gitdir.ptr,
......@@ -699,7 +699,7 @@ static int conditional_match_onbranch(
*/
if ((error = git_str_sets(&buf, condition)) < 0)
goto out;
if (git_path_is_dirsep(condition[strlen(condition) - 1]) &&
if (git_fs_path_is_dirsep(condition[strlen(condition) - 1]) &&
(error = git_str_puts(&buf, "**")) < 0)
goto out;
......@@ -861,7 +861,7 @@ static int config_file_read(
int error;
if (p_stat(file->path, &st) < 0) {
error = git_path_set_error(errno, file->path, "stat");
error = git_fs_path_set_error(errno, file->path, "stat");
goto out;
}
......
......@@ -605,7 +605,7 @@ int git_diff__oid_for_entry(
diff->base.perf.stat_calls++;
if (p_stat(full_path.ptr, &st) < 0) {
error = git_path_set_error(errno, entry.path, "stat");
error = git_fs_path_set_error(errno, entry.path, "stat");
git_str_dispose(&full_path);
return error;
}
......@@ -1026,7 +1026,7 @@ static int handle_unmatched_new_item(
git_str *full = NULL;
if (git_iterator_current_workdir_path(&full, info->new_iter) < 0)
return -1;
if (full && git_path_contains(full, DOT_GIT)) {
if (full && git_fs_path_contains(full, DOT_GIT)) {
/* TODO: warning if not a valid git repository */
recurse_into_dir = false;
}
......
......@@ -70,7 +70,7 @@ static int diff_file_stats_full_to_buf(
padding = stats->max_name - strlen(old_path) - strlen(new_path);
if ((common_dirlen = git_path_common_dirlen(old_path, new_path)) &&
if ((common_dirlen = git_fs_path_common_dirlen(old_path, new_path)) &&
common_dirlen <= INT_MAX) {
error = git_str_printf(out, " %.*s{%s"DIFF_RENAME_FILE_SEPARATOR"%s}",
(int) common_dirlen, old_path,
......
......@@ -13,7 +13,7 @@
#include "diff.h"
#include "diff_generate.h"
#include "path.h"
#include "fs_path.h"
#include "futils.h"
#include "config.h"
......@@ -481,7 +481,7 @@ static int similarity_sig(
return error;
/* if path is not a regular file, just skip this item */
if (!git_path_isfile(info->data.ptr))
if (!git_fs_path_isfile(info->data.ptr))
return 0;
/* TODO: apply wd-to-odb filters to file data if necessary */
......
......@@ -43,7 +43,7 @@ static int verify_last_error(git_filebuf *file)
static int lock_file(git_filebuf *file, int flags, mode_t mode)
{
if (git_path_exists(file->path_lock) == true) {
if (git_fs_path_exists(file->path_lock) == true) {
git_error_clear(); /* actual OS error code just confuses */
git_error_set(GIT_ERROR_OS,
"failed to lock file '%s' for writing", file->path_lock);
......@@ -63,7 +63,7 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode)
file->fd_is_open = true;
if ((flags & GIT_FILEBUF_APPEND) && git_path_exists(file->path_original) == true) {
if ((flags & GIT_FILEBUF_APPEND) && git_fs_path_exists(file->path_original) == true) {
git_file source;
char buffer[FILEIO_BUFSIZE];
ssize_t read_bytes;
......@@ -103,7 +103,7 @@ void git_filebuf_cleanup(git_filebuf *file)
if (file->fd_is_open && file->fd >= 0)
p_close(file->fd);
if (file->created_lock && !file->did_rename && file->path_lock && git_path_exists(file->path_lock))
if (file->created_lock && !file->did_rename && file->path_lock && git_fs_path_exists(file->path_lock))
p_unlink(file->path_lock);
if (file->compute_digest) {
......@@ -241,20 +241,20 @@ static int resolve_symlink(git_str *out, const char *path)
target.ptr[ret] = '\0';
target.size = ret;
root = git_path_root(target.ptr);
root = git_fs_path_root(target.ptr);
if (root >= 0) {
if ((error = git_str_sets(&curpath, target.ptr)) < 0)
goto cleanup;
} else {
git_str dir = GIT_STR_INIT;
if ((error = git_path_dirname_r(&dir, curpath.ptr)) < 0)
if ((error = git_fs_path_dirname_r(&dir, curpath.ptr)) < 0)
goto cleanup;
git_str_swap(&curpath, &dir);
git_str_dispose(&dir);
if ((error = git_path_apply_relative(&curpath, target.ptr)) < 0)
if ((error = git_fs_path_apply_relative(&curpath, target.ptr)) < 0)
goto cleanup;
}
}
......@@ -366,7 +366,7 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo
memcpy(file->path_lock, file->path_original, path_len);
memcpy(file->path_lock + path_len, GIT_FILELOCK_EXTENSION, GIT_FILELOCK_EXTLENGTH);
if (git_path_isdir(file->path_original)) {
if (git_fs_path_isdir(file->path_original)) {
git_error_set(GIT_ERROR_FILESYSTEM, "path '%s' is a directory", file->path_original);
error = GIT_EDIRECTORY;
goto cleanup;
......
......@@ -1094,8 +1094,8 @@ int git_filter_list_stream_file(
if ((error = stream_list_init(
&stream_start, &filter_streams, filters, target)) < 0 ||
(error = git_path_join_unrooted(&abspath, path, base, NULL)) < 0 ||
(error = git_path_validate_workdir_buf(repo, &abspath)) < 0)
(error = git_fs_path_join_unrooted(&abspath, path, base, NULL)) < 0 ||
(error = git_fs_path_validate_workdir_buf(repo, &abspath)) < 0)
goto done;
initialized = 1;
......
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
......@@ -99,7 +99,7 @@ int git_futils_open_ro(const char *path)
{
int fd = p_open(path, O_RDONLY);
if (fd < 0)
return git_path_set_error(errno, path, "open");
return git_fs_path_set_error(errno, path, "open");
return fd;
}
......@@ -107,7 +107,7 @@ int git_futils_truncate(const char *path, int mode)
{
int fd = p_open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, mode);
if (fd < 0)
return git_path_set_error(errno, path, "open");
return git_fs_path_set_error(errno, path, "open");
close(fd);
return 0;
......@@ -195,7 +195,7 @@ int git_futils_readbuffer_updated(
*updated = 0;
if (p_stat(path, &st) < 0)
return git_path_set_error(errno, path, "stat");
return git_fs_path_set_error(errno, path, "stat");
if (S_ISDIR(st.st_mode)) {
......@@ -429,7 +429,7 @@ GIT_INLINE(int) mkdir_canonicalize(
}
/* Trim trailing slashes (except the root) */
if ((root_len = git_path_root(path->ptr)) < 0)
if ((root_len = git_fs_path_root(path->ptr)) < 0)
root_len = 0;
else
root_len++;
......@@ -439,11 +439,11 @@ GIT_INLINE(int) mkdir_canonicalize(
/* if we are not supposed to made the last element, truncate it */
if ((flags & GIT_MKDIR_SKIP_LAST2) != 0) {
git_path_dirname_r(path, path->ptr);
git_fs_path_dirname_r(path, path->ptr);
flags |= GIT_MKDIR_SKIP_LAST;
}
if ((flags & GIT_MKDIR_SKIP_LAST) != 0) {
git_path_dirname_r(path, path->ptr);
git_fs_path_dirname_r(path, path->ptr);
}
/* We were either given the root path (or trimmed it to
......@@ -473,7 +473,7 @@ int git_futils_mkdir(
make_path.size == 0)
goto done;
root_len = git_path_root(make_path.ptr);
root_len = git_fs_path_root(make_path.ptr);
/* find the first parent directory that exists. this will be used
* as the base to dirname_relative.
......@@ -492,7 +492,7 @@ int git_futils_mkdir(
depth++;
/* examine the parent of the current path */
if ((len = git_path_dirname_r(&parent_path, parent_path.ptr)) < 0) {
if ((len = git_fs_path_dirname_r(&parent_path, parent_path.ptr)) < 0) {
error = len;
goto done;
}
......@@ -569,7 +569,7 @@ int git_futils_mkdir_relative(
opts = &empty_opts;
/* build path and find "root" where we should start calling mkdir */
if (git_path_join_unrooted(&make_path, relative_path, base, &root) < 0)
if (git_fs_path_join_unrooted(&make_path, relative_path, base, &root) < 0)
return -1;
if ((error = mkdir_canonicalize(&make_path, flags)) < 0 ||
......@@ -581,7 +581,7 @@ int git_futils_mkdir_relative(
root = git_str_rfind(&make_path, '/');
/* advance root past drive name or network mount prefix */
min_root_len = git_path_root(make_path.ptr);
min_root_len = git_fs_path_root(make_path.ptr);
if (root < min_root_len)
root = min_root_len;
while (root >= 0 && make_path.ptr[root] == '/')
......@@ -744,13 +744,13 @@ static int futils__rmdir_recurs_foreach(void *opaque, git_str *path)
path->ptr, "parent is not directory");
}
else
error = git_path_set_error(errno, path->ptr, "rmdir");
error = git_fs_path_set_error(errno, path->ptr, "rmdir");
}
else if (S_ISDIR(st.st_mode)) {
data->depth++;
error = git_path_direach(path, 0, futils__rmdir_recurs_foreach, data);
error = git_fs_path_direach(path, 0, futils__rmdir_recurs_foreach, data);
data->depth--;
......@@ -765,13 +765,13 @@ static int futils__rmdir_recurs_foreach(void *opaque, git_str *path)
(errno == ENOTEMPTY || errno == EEXIST || errno == EBUSY))
error = 0;
else
error = git_path_set_error(errno, path->ptr, "rmdir");
error = git_fs_path_set_error(errno, path->ptr, "rmdir");
}
}
else if ((data->flags & GIT_RMDIR_REMOVE_FILES) != 0) {
if (p_unlink(path->ptr) < 0)
error = git_path_set_error(errno, path->ptr, "remove");
error = git_fs_path_set_error(errno, path->ptr, "remove");
}
else if ((data->flags & GIT_RMDIR_SKIP_NONEMPTY) == 0)
......@@ -795,11 +795,11 @@ static int futils__rmdir_empty_parent(void *opaque, const char *path)
/* do nothing */
} else if ((data->flags & GIT_RMDIR_SKIP_NONEMPTY) == 0 &&
en == EBUSY) {
error = git_path_set_error(errno, path, "rmdir");
error = git_fs_path_set_error(errno, path, "rmdir");
} else if (en == ENOTEMPTY || en == EEXIST || en == EBUSY) {
error = GIT_ITEROVER;
} else {
error = git_path_set_error(errno, path, "rmdir");
error = git_fs_path_set_error(errno, path, "rmdir");
}
}
......@@ -814,7 +814,7 @@ int git_futils_rmdir_r(
futils__rmdir_data data;
/* build path and find "root" where we should start calling mkdir */
if (git_path_join_unrooted(&fullpath, path, base, NULL) < 0)
if (git_fs_path_join_unrooted(&fullpath, path, base, NULL) < 0)
return -1;
memset(&data, 0, sizeof(data));
......@@ -826,7 +826,7 @@ int git_futils_rmdir_r(
/* remove now-empty parents if requested */
if (!error && (flags & GIT_RMDIR_EMPTY_PARENTS) != 0)
error = git_path_walk_up(
error = git_fs_path_walk_up(
&fullpath, base, futils__rmdir_empty_parent, &data);
if (error == GIT_ITEROVER) {
......@@ -887,7 +887,7 @@ int git_futils_cp(const char *from, const char *to, mode_t filemode)
if ((ofd = p_open(to, O_WRONLY | O_CREAT | O_EXCL, filemode)) < 0) {
p_close(ifd);
return git_path_set_error(errno, to, "open for writing");
return git_fs_path_set_error(errno, to, "open for writing");
}
return cp_by_fd(ifd, ofd, true);
......@@ -903,7 +903,7 @@ int git_futils_touch(const char *path, time_t *when)
ret = p_utimes(path, times);
return (ret < 0) ? git_path_set_error(errno, path, "touch") : 0;
return (ret < 0) ? git_fs_path_set_error(errno, path, "touch") : 0;
}
static int cp_link(const char *from, const char *to, size_t link_size)
......@@ -977,14 +977,14 @@ static int _cp_r_callback(void *ref, git_str *from)
bool exists = false;
if ((info->flags & GIT_CPDIR_COPY_DOTFILES) == 0 &&
from->ptr[git_path_basename_offset(from)] == '.')
from->ptr[git_fs_path_basename_offset(from)] == '.')
return 0;
if ((error = git_str_joinpath(
&info->to, info->to_root, from->ptr + info->from_prefix)) < 0)
return error;
if (!(error = git_path_lstat(info->to.ptr, &to_st)))
if (!(error = git_fs_path_lstat(info->to.ptr, &to_st)))
exists = true;
else if (error != GIT_ENOTFOUND)
return error;
......@@ -993,7 +993,7 @@ static int _cp_r_callback(void *ref, git_str *from)
error = 0;
}
if ((error = git_path_lstat(from->ptr, &from_st)) < 0)
if ((error = git_fs_path_lstat(from->ptr, &from_st)) < 0)
return error;
if (S_ISDIR(from_st.st_mode)) {
......@@ -1009,7 +1009,7 @@ static int _cp_r_callback(void *ref, git_str *from)
/* recurse onto target directory */
if (!error && (!exists || S_ISDIR(to_st.st_mode)))
error = git_path_direach(from, 0, _cp_r_callback, info);
error = git_fs_path_direach(from, 0, _cp_r_callback, info);
if (oldmode != 0)
info->dirmode = oldmode;
......@@ -1182,7 +1182,7 @@ int git_futils_fsync_parent(const char *path)
char *parent;
int error;
if ((parent = git_path_dirname(path)) == NULL)
if ((parent = git_fs_path_dirname(path)) == NULL)
return -1;
error = git_futils_fsync_dir(parent);
......
......@@ -11,7 +11,7 @@
#include "map.h"
#include "posix.h"
#include "path.h"
#include "fs_path.h"
#include "pool.h"
#include "strmap.h"
#include "hash.h"
......
......@@ -10,7 +10,7 @@
#include "git2/ignore.h"
#include "common.h"
#include "attrcache.h"
#include "path.h"
#include "fs_path.h"
#include "config.h"
#include "wildmatch.h"
......@@ -181,7 +181,7 @@ static int parse_ignore_file(
/* if subdir file path, convert context for file paths */
if (attrs->entry &&
git_path_root(attrs->entry->path) < 0 &&
git_fs_path_root(attrs->entry->path) < 0 &&
!git__suffixcmp(attrs->entry->path, "/" GIT_IGNORE_FILE))
context = attrs->entry->path;
......@@ -313,21 +313,21 @@ int git_ignore__for_path(
goto cleanup;
/* given a unrooted path in a non-bare repo, resolve it */
if (workdir && git_path_root(path) < 0) {
if (workdir && git_fs_path_root(path) < 0) {
git_str local = GIT_STR_INIT;
if ((error = git_path_dirname_r(&local, path)) < 0 ||
(error = git_path_resolve_relative(&local, 0)) < 0 ||
(error = git_path_to_dir(&local)) < 0 ||
if ((error = git_fs_path_dirname_r(&local, path)) < 0 ||
(error = git_fs_path_resolve_relative(&local, 0)) < 0 ||
(error = git_fs_path_to_dir(&local)) < 0 ||
(error = git_str_joinpath(&ignores->dir, workdir, local.ptr)) < 0 ||
(error = git_path_validate_workdir_buf(repo, &ignores->dir)) < 0) {
(error = git_fs_path_validate_workdir_buf(repo, &ignores->dir)) < 0) {
/* Nothing, we just want to stop on the first error */
}
git_str_dispose(&local);
} else {
if (!(error = git_str_joinpath(&ignores->dir, path, "")))
error = git_path_validate_filesystem(ignores->dir.ptr, ignores->dir.size);
error = git_fs_path_validate_filesystem(ignores->dir.ptr, ignores->dir.size);
}
if (error < 0)
......@@ -342,7 +342,7 @@ int git_ignore__for_path(
/* load .gitignore up the path */
if (workdir != NULL) {
error = git_path_walk_up(
error = git_fs_path_walk_up(
&ignores->dir, workdir, push_one_ignore, ignores);
if (error < 0)
goto cleanup;
......@@ -410,7 +410,7 @@ int git_ignore__pop_dir(git_ignores *ign)
if (--ign->depth > 0) {
git_str_rtruncate_at_char(&ign->dir, '/');
git_path_to_dir(&ign->dir);
git_fs_path_to_dir(&ign->dir);
}
return 0;
......@@ -629,7 +629,7 @@ int git_ignore__check_pathspec_for_exact_ignores(
break;
/* is there a file on disk that matches this exactly? */
if (!git_path_isfile(path.ptr))
if (!git_fs_path_isfile(path.ptr))
continue;
/* is that file ignored? */
......
......@@ -20,6 +20,7 @@
#include "idxmap.h"
#include "diff.h"
#include "varint.h"
#include "path.h"
#include "git2/odb.h"
#include "git2/oid.h"
......@@ -420,7 +421,7 @@ int git_index_open(git_index **index_out, const char *index_path)
goto fail;
/* Check if index file is stored on disk already */
if (git_path_exists(index->index_file_path) == true)
if (git_fs_path_exists(index->index_file_path) == true)
index->on_disk = 1;
}
......@@ -648,7 +649,7 @@ int git_index_read(git_index *index, int force)
return create_index_error(-1,
"failed to read index: The index is in-memory only");
index->on_disk = git_path_exists(index->index_file_path);
index->on_disk = git_fs_path_exists(index->index_file_path);
if (!index->on_disk) {
if (force && (error = git_index_clear(index)) < 0)
......@@ -991,7 +992,7 @@ static int index_entry_init(
if (git_repository_workdir_path(&path, repo, rel_path) < 0)
return -1;
error = git_path_lstat(path.ptr, &st);
error = git_fs_path_lstat(path.ptr, &st);
git_str_dispose(&path);
if (error < 0)
......@@ -1728,7 +1729,7 @@ int git_index_remove_directory(git_index *index, const char *dir, int stage)
git_index_entry *entry;
if (!(error = git_str_sets(&pfx, dir)) &&
!(error = git_path_to_dir(&pfx)))
!(error = git_fs_path_to_dir(&pfx)))
index_find(&pos, index, pfx.ptr, pfx.size, GIT_INDEX_STAGE_ANY);
while (!error) {
......
......@@ -472,7 +472,7 @@ GIT_INLINE(tree_iterator_frame *) tree_iterator_current_frame(
GIT_INLINE(int) tree_entry_cmp(
const git_tree_entry *a, const git_tree_entry *b, bool icase)
{
return git_path_cmp(
return git_fs_path_cmp(
a->filename, a->filename_len, a->attr == GIT_FILEMODE_TREE,
b->filename, b->filename_len, b->attr == GIT_FILEMODE_TREE,
icase ? git__strncasecmp : git__strncmp);
......@@ -1279,7 +1279,7 @@ static int filesystem_iterator_entry_hash(
iter->base.repo, entry->path, GIT_OBJECT_BLOB, NULL);
if (!(error = git_str_joinpath(&fullpath, iter->root, entry->path)) &&
!(error = git_path_validate_workdir_buf(iter->base.repo, &fullpath)))
!(error = git_fs_path_validate_workdir_buf(iter->base.repo, &fullpath)))
error = git_odb_hashfile(&entry->id, fullpath.ptr, GIT_OBJECT_BLOB);
git_str_dispose(&fullpath);
......@@ -1336,7 +1336,7 @@ static int filesystem_iterator_frame_push(
filesystem_iterator_entry *frame_entry)
{
filesystem_iterator_frame *new_frame = NULL;
git_path_diriter diriter = GIT_PATH_DIRITER_INIT;
git_fs_path_diriter diriter = GIT_FS_PATH_DIRITER_INIT;
git_str root = GIT_STR_INIT;
const char *path;
filesystem_iterator_entry *entry;
......@@ -1361,7 +1361,7 @@ static int filesystem_iterator_frame_push(
git_str_puts(&root, iter->root);
if (git_str_oom(&root) ||
git_path_validate_workdir_buf(iter->base.repo, &root) < 0) {
git_fs_path_validate_workdir_buf(iter->base.repo, &root) < 0) {
error = -1;
goto done;
}
......@@ -1369,7 +1369,7 @@ static int filesystem_iterator_frame_push(
new_frame->path_len = frame_entry ? frame_entry->path_len : 0;
/* Any error here is equivalent to the dir not existing, skip over it */
if ((error = git_path_diriter_init(
if ((error = git_fs_path_diriter_init(
&diriter, root.ptr, iter->dirload_flags)) < 0) {
error = GIT_ENOTFOUND;
goto done;
......@@ -1387,12 +1387,12 @@ static int filesystem_iterator_frame_push(
/* check if this directory is ignored */
filesystem_iterator_frame_push_ignores(iter, frame_entry, new_frame);
while ((error = git_path_diriter_next(&diriter)) == 0) {
while ((error = git_fs_path_diriter_next(&diriter)) == 0) {
iterator_pathlist_search_t pathlist_match = ITERATOR_PATHLIST_FULL;
bool dir_expected = false;
if ((error = git_path_diriter_fullpath(&path, &path_len, &diriter)) < 0 ||
(error = git_path_validate_workdir_with_len(iter->base.repo, path, path_len)) < 0)
if ((error = git_fs_path_diriter_fullpath(&path, &path_len, &diriter)) < 0 ||
(error = git_fs_path_validate_workdir_with_len(iter->base.repo, path, path_len)) < 0)
goto done;
GIT_ASSERT(path_len > iter->root_len);
......@@ -1414,7 +1414,7 @@ static int filesystem_iterator_frame_push(
* we have an index, we can just copy the data out of it.
*/
if ((error = git_path_diriter_stat(&statbuf, &diriter)) < 0) {
if ((error = git_fs_path_diriter_stat(&statbuf, &diriter)) < 0) {
/* file was removed between readdir and lstat */
if (error == GIT_ENOTFOUND)
continue;
......@@ -1472,7 +1472,7 @@ done:
git_array_pop(iter->frames);
git_str_dispose(&root);
git_path_diriter_free(&diriter);
git_fs_path_diriter_free(&diriter);
return error;
}
......@@ -1565,7 +1565,7 @@ static int filesystem_iterator_is_dir(
}
if ((error = git_str_joinpath(&fullpath, iter->root, entry->path)) < 0 ||
(error = git_path_validate_workdir_buf(iter->base.repo, &fullpath)) < 0 ||
(error = git_fs_path_validate_workdir_buf(iter->base.repo, &fullpath)) < 0 ||
(error = p_stat(fullpath.ptr, &st)) < 0)
goto done;
......@@ -1961,9 +1961,10 @@ static int iterator_for_filesystem(
iter->index = index;
iter->dirload_flags =
(iterator__ignore_case(&iter->base) ? GIT_PATH_DIR_IGNORE_CASE : 0) |
(iterator__ignore_case(&iter->base) ?
GIT_FS_PATH_DIR_IGNORE_CASE : 0) |
(iterator__flag(&iter->base, PRECOMPOSE_UNICODE) ?
GIT_PATH_DIR_PRECOMPOSE_UNICODE : 0);
GIT_FS_PATH_DIR_PRECOMPOSE_UNICODE : 0);
if ((error = filesystem_iterator_init(iter)) < 0)
goto on_error;
......@@ -2058,7 +2059,7 @@ static bool index_iterator_create_pseudotree(
prev_path = iter->entry ? iter->entry->path : "";
/* determine if the new path is in a different directory from the old */
common_len = git_path_common_dirlen(prev_path, path);
common_len = git_fs_path_common_dirlen(prev_path, path);
relative_path = path + common_len;
if ((dirsep = strchr(relative_path, '/')) == NULL)
......
......@@ -9,7 +9,7 @@
#include "common.h"
#include "config.h"
#include "path.h"
#include "fs_path.h"
#include "repository.h"
#include "signature.h"
#include "git2/config.h"
......@@ -327,11 +327,11 @@ static int mailmap_add_file_ondisk(
git_str content = GIT_STR_INIT;
int error;
error = git_path_join_unrooted(&fullpath, path, base, NULL);
error = git_fs_path_join_unrooted(&fullpath, path, base, NULL);
if (error < 0)
goto cleanup;
error = git_path_validate_workdir_buf(repo, &fullpath);
error = git_fs_path_validate_workdir_buf(repo, &fullpath);
if (error < 0)
goto cleanup;
......
......@@ -12,7 +12,7 @@
#include "repository.h"
#include "revwalk.h"
#include "commit_list.h"
#include "path.h"
#include "fs_path.h"
#include "refs.h"
#include "object.h"
#include "iterator.h"
......
......@@ -14,7 +14,7 @@
#include "hash.h"
#include "odb.h"
#include "pack.h"
#include "path.h"
#include "fs_path.h"
#include "repository.h"
#include "str.h"
......@@ -502,7 +502,7 @@ int git_midx_writer_new(
git__free(w);
return -1;
}
git_path_squash_slashes(&w->pack_dir);
git_fs_path_squash_slashes(&w->pack_dir);
if (git_vector_init(&w->packs, 0, packfile__cmp) < 0) {
git_str_dispose(&w->pack_dir);
......@@ -537,7 +537,7 @@ int git_midx_writer_add(
int error;
struct git_pack_file *p;
error = git_path_prettify(&idx_path_buf, idx_path, git_str_cstr(&w->pack_dir));
error = git_fs_path_prettify(&idx_path_buf, idx_path, git_str_cstr(&w->pack_dir));
if (error < 0)
return error;
......@@ -687,7 +687,7 @@ static int midx_write(
error = git_str_sets(&relative_index, p->pack_name);
if (error < 0)
goto cleanup;
error = git_path_make_relative(&relative_index, git_str_cstr(&w->pack_dir));
error = git_fs_path_make_relative(&relative_index, git_str_cstr(&w->pack_dir));
if (error < 0) {
git_str_dispose(&relative_index);
goto cleanup;
......
......@@ -277,7 +277,7 @@ int git_odb__hashlink(git_oid *out, const char *path)
int size;
int result;
if (git_path_lstat(path, &st) < 0)
if (git_fs_path_lstat(path, &st) < 0)
return -1;
if (!git__is_int(st.st_size) || (int)st.st_size < 0) {
......@@ -649,7 +649,7 @@ static int load_alternates(git_odb *odb, const char *objects_dir, int alternate_
if (git_str_joinpath(&alternates_path, objects_dir, GIT_ALTERNATES_FILE) < 0)
return -1;
if (git_path_exists(alternates_path.ptr) == false) {
if (git_fs_path_exists(alternates_path.ptr) == false) {
git_str_dispose(&alternates_path);
return 0;
}
......
......@@ -87,7 +87,7 @@ static int object_file_name(
return -1;
git_str_set(name, be->objects_dir, be->objects_dirlen);
git_path_to_dir(name);
git_fs_path_to_dir(name);
/* loose object filename: aa/aaa... (41 bytes) */
git_oid_pathfmt(name->ptr + name->size, id);
......@@ -452,7 +452,7 @@ static int locate_object(
{
int error = object_file_name(object_location, backend, oid);
if (!error && !git_path_exists(object_location->ptr))
if (!error && !git_fs_path_exists(object_location->ptr))
return GIT_ENOTFOUND;
return error;
......@@ -467,7 +467,7 @@ static int fn_locate_object_short_oid(void *state, git_str *pathbuf) {
return 0;
}
if (git_path_isdir(pathbuf->ptr) == false) {
if (git_fs_path_isdir(pathbuf->ptr) == false) {
/* We are already in the directory matching the 2 first hex characters,
* compare the first ncmp characters of the oids */
if (!memcmp(sstate->short_oid + 2,
......@@ -509,7 +509,7 @@ static int locate_object_short_oid(
return -1;
git_str_set(object_location, objects_dir, dir_len);
git_path_to_dir(object_location);
git_fs_path_to_dir(object_location);
/* save adjusted position at end of dir so it can be restored later */
dir_len = git_str_len(object_location);
......@@ -523,7 +523,7 @@ static int locate_object_short_oid(
object_location->ptr[object_location->size - 1] = '/';
/* Check that directory exists */
if (git_path_isdir(object_location->ptr) == false)
if (git_fs_path_isdir(object_location->ptr) == false)
return git_odb__error_notfound("no matching loose object for prefix",
short_oid, len);
......@@ -532,7 +532,7 @@ static int locate_object_short_oid(
state.found = 0;
/* Explore directory to find a unique object matching short_oid */
error = git_path_direach(
error = git_fs_path_direach(
object_location, 0, fn_locate_object_short_oid, &state);
if (error < 0 && error != GIT_EAMBIGUOUS)
return error;
......@@ -753,10 +753,10 @@ static int foreach_cb(void *_state, git_str *path)
struct foreach_state *state = (struct foreach_state *) _state;
/* non-dir is some stray file, ignore it */
if (!git_path_isdir(git_str_cstr(path)))
if (!git_fs_path_isdir(git_str_cstr(path)))
return 0;
return git_path_direach(path, 0, foreach_object_dir_cb, state);
return git_fs_path_direach(path, 0, foreach_object_dir_cb, state);
}
static int loose_backend__foreach(git_odb_backend *_backend, git_odb_foreach_cb cb, void *data)
......@@ -773,7 +773,7 @@ static int loose_backend__foreach(git_odb_backend *_backend, git_odb_foreach_cb
objects_dir = backend->objects_dir;
git_str_sets(&buf, objects_dir);
git_path_to_dir(&buf);
git_fs_path_to_dir(&buf);
if (git_str_oom(&buf))
return -1;
......@@ -782,7 +782,7 @@ static int loose_backend__foreach(git_odb_backend *_backend, git_odb_foreach_cb
state.data = data;
state.dir_len = git_str_len(&buf);
error = git_path_direach(&buf, 0, foreach_cb, &state);
error = git_fs_path_direach(&buf, 0, foreach_cb, &state);
git_str_dispose(&buf);
......
......@@ -524,7 +524,7 @@ static int pack_backend__refresh(git_odb_backend *backend_)
/* reload all packs */
git_str_sets(&path, backend->pack_folder);
error = git_path_direach(&path, 0, packfile_load__cb, backend);
error = git_fs_path_direach(&path, 0, packfile_load__cb, backend);
git_str_dispose(&path);
git_vector_sort(&backend->packs);
......@@ -750,7 +750,7 @@ static int get_idx_path(
size_t path_len;
int error;
error = git_path_prettify(idx_path, p->pack_name, backend->pack_folder);
error = git_fs_path_prettify(idx_path, p->pack_name, backend->pack_folder);
if (error < 0)
return error;
path_len = git_str_len(idx_path);
......@@ -902,7 +902,7 @@ int git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir)
return -1;
if (!(error = git_str_joinpath(&path, objects_dir, "pack")) &&
git_path_isdir(git_str_cstr(&path)))
git_fs_path_isdir(git_str_cstr(&path)))
{
backend->pack_folder = git_str_detach(&path);
error = pack_backend__refresh((git_odb_backend *)backend);
......
......@@ -1198,7 +1198,7 @@ int git_packfile_alloc(struct git_pack_file **pack_out, const char *path)
if (!git_disable_pack_keep_file_checks) {
memcpy(p->pack_name + root_len, ".keep", sizeof(".keep"));
if (git_path_exists(p->pack_name) == true)
if (git_fs_path_exists(p->pack_name) == true)
p->pack_keep = 1;
}
......
......@@ -10,7 +10,7 @@
#include "git2/patch.h"
#include "patch.h"
#include "diff_parse.h"
#include "path.h"
#include "fs_path.h"
typedef struct {
git_patch base;
......@@ -80,7 +80,7 @@ static int parse_header_path_buf(git_str *path, git_patch_parse_ctx *ctx, size_t
(error = git_str_unquote(path)) < 0)
return error;
git_path_squash_slashes(path);
git_fs_path_squash_slashes(path);
if (!path->size)
return git_parse_err("patch contains empty path at line %"PRIuZ,
......
......@@ -7,7 +7,7 @@
#include "posix.h"
#include "path.h"
#include "fs_path.h"
#include <stdio.h>
#include <ctype.h>
......@@ -144,8 +144,8 @@ int p_getcwd(char *buffer_out, size_t size)
if (cwd_buffer == NULL)
return -1;
git_path_mkposix(buffer_out);
git_path_string_to_dir(buffer_out, size); /* append trailing slash */
git_fs_path_mkposix(buffer_out);
git_fs_path_string_to_dir(buffer_out, size); /* append trailing slash */
return 0;
}
......
......@@ -97,7 +97,7 @@ static int rebase_state_type(
if (git_str_joinpath(&path, repo->gitdir, REBASE_APPLY_DIR) < 0)
return -1;
if (git_path_isdir(git_str_cstr(&path))) {
if (git_fs_path_isdir(git_str_cstr(&path))) {
type = GIT_REBASE_APPLY;
goto done;
}
......@@ -106,7 +106,7 @@ static int rebase_state_type(
if (git_str_joinpath(&path, repo->gitdir, REBASE_MERGE_DIR) < 0)
return -1;
if (git_path_isdir(git_str_cstr(&path))) {
if (git_fs_path_isdir(git_str_cstr(&path))) {
type = GIT_REBASE_MERGE;
goto done;
}
......@@ -340,7 +340,7 @@ int git_rebase_open(
if ((error = git_str_joinpath(&path, path.ptr, ORIG_HEAD_FILE)) < 0)
goto done;
if (!git_path_isfile(path.ptr)) {
if (!git_fs_path_isfile(path.ptr)) {
/* Previous versions of git.git used 'head' here; support that. */
git_str_truncate(&path, state_path_len);
......@@ -404,7 +404,7 @@ static int rebase_cleanup(git_rebase *rebase)
if (!rebase || rebase->inmemory)
return 0;
return git_path_isdir(rebase->state_path) ?
return git_fs_path_isdir(rebase->state_path) ?
git_futils_rmdir_r(rebase->state_path, NULL, GIT_RMDIR_REMOVE_FILES) :
0;
}
......
......@@ -18,6 +18,7 @@
#include "sortedcache.h"
#include "signature.h"
#include "wildmatch.h"
#include "path.h"
#include <git2/tag.h>
#include <git2/object.h>
......@@ -76,7 +77,7 @@ GIT_INLINE(int) loose_path(
if (git_str_joinpath(out, base, refname) < 0)
return -1;
return git_path_validate_filesystem_with_suffix(out->ptr, out->size,
return git_fs_path_validate_filesystem_with_suffix(out->ptr, out->size,
CONST_STRLEN(".lock"));
}
......@@ -307,8 +308,8 @@ static int _dirent_loose_load(void *payload, git_str *full_path)
if (git__suffixcmp(full_path->ptr, ".lock") == 0)
return 0;
if (git_path_isdir(full_path->ptr)) {
int error = git_path_direach(
if (git_fs_path_isdir(full_path->ptr)) {
int error = git_fs_path_direach(
full_path, backend->direach_flags, _dirent_loose_load, backend);
/* Race with the filesystem, ignore it */
if (error == GIT_ENOTFOUND) {
......@@ -343,7 +344,7 @@ static int packed_loadloose(refdb_fs_backend *backend)
* This will overwrite any old packed entries with their
* updated loose versions
*/
error = git_path_direach(
error = git_fs_path_direach(
&refs_path, backend->direach_flags, _dirent_loose_load, backend);
git_str_dispose(&refs_path);
......@@ -367,7 +368,7 @@ static int refdb_fs_backend__exists(
if ((error = loose_path(&ref_path, backend->gitpath, ref_name)) < 0)
goto out;
if (git_path_isfile(ref_path.ptr)) {
if (git_fs_path_isfile(ref_path.ptr)) {
*exists = 1;
goto out;
}
......@@ -817,7 +818,7 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
GIT_ASSERT_ARG(backend);
GIT_ASSERT_ARG(name);
if (!git_path_validate(backend->repo, name, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
if (!git_path_validate(backend->repo, name, 0, GIT_FS_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", name);
return GIT_EINVALIDSPEC;
}
......@@ -1344,10 +1345,10 @@ static int refdb_fs_backend__prune_refs(
if ((error = git_str_sets(&relative_path, ref_name)) < 0)
goto cleanup;
git_path_squash_slashes(&relative_path);
if ((commonlen = git_path_common_dirlen("refs/heads/", git_str_cstr(&relative_path))) == strlen("refs/heads/") ||
(commonlen = git_path_common_dirlen("refs/tags/", git_str_cstr(&relative_path))) == strlen("refs/tags/") ||
(commonlen = git_path_common_dirlen("refs/remotes/", git_str_cstr(&relative_path))) == strlen("refs/remotes/")) {
git_fs_path_squash_slashes(&relative_path);
if ((commonlen = git_fs_path_common_dirlen("refs/heads/", git_str_cstr(&relative_path))) == strlen("refs/heads/") ||
(commonlen = git_fs_path_common_dirlen("refs/tags/", git_str_cstr(&relative_path))) == strlen("refs/tags/") ||
(commonlen = git_fs_path_common_dirlen("refs/remotes/", git_str_cstr(&relative_path))) == strlen("refs/remotes/")) {
git_str_truncate(&relative_path, commonlen);
......@@ -1361,7 +1362,7 @@ static int refdb_fs_backend__prune_refs(
git_str_cstr(&relative_path));
if (!error)
error = git_path_validate_filesystem(base_path.ptr, base_path.size);
error = git_fs_path_validate_filesystem(base_path.ptr, base_path.size);
if (error < 0)
goto cleanup;
......@@ -1741,7 +1742,7 @@ static int has_reflog(git_repository *repo, const char *name)
if (reflog_path(&path, repo, name) < 0)
goto cleanup;
ret = git_path_isfile(git_str_cstr(&path));
ret = git_fs_path_isfile(git_str_cstr(&path));
cleanup:
git_str_dispose(&path);
......@@ -1856,7 +1857,7 @@ static int lock_reflog(git_filebuf *file, refdb_fs_backend *backend, const char
repo = backend->repo;
if (!git_path_validate(backend->repo, refname, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
if (!git_path_validate(backend->repo, refname, 0, GIT_FS_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", refname);
return GIT_EINVALIDSPEC;
}
......@@ -1864,7 +1865,7 @@ static int lock_reflog(git_filebuf *file, refdb_fs_backend *backend, const char
if (reflog_path(&log_path, repo, refname) < 0)
return -1;
if (!git_path_isfile(git_str_cstr(&log_path))) {
if (!git_fs_path_isfile(git_str_cstr(&log_path))) {
git_error_set(GIT_ERROR_INVALID,
"log file for reference '%s' doesn't exist", refname);
error = -1;
......@@ -1973,11 +1974,11 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
/* If the new branch matches part of the namespace of a previously deleted branch,
* there maybe an obsolete/unused directory (or directory hierarchy) in the way.
*/
if (git_path_isdir(git_str_cstr(&path))) {
if (git_fs_path_isdir(git_str_cstr(&path))) {
if ((error = git_futils_rmdir_r(git_str_cstr(&path), NULL, GIT_RMDIR_SKIP_NONEMPTY)) < 0) {
if (error == GIT_ENOTFOUND)
error = 0;
} else if (git_path_isdir(git_str_cstr(&path))) {
} else if (git_fs_path_isdir(git_str_cstr(&path))) {
git_error_set(GIT_ERROR_REFERENCE, "cannot create reflog at '%s', there are reflogs beneath that folder",
ref->name);
error = GIT_EDIRECTORY;
......@@ -2031,7 +2032,7 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
if ((error = loose_path(&new_path, git_str_cstr(&temp_path), git_str_cstr(&normalized))) < 0)
return error;
if (!git_path_exists(git_str_cstr(&old_path))) {
if (!git_fs_path_exists(git_str_cstr(&old_path))) {
error = GIT_ENOTFOUND;
goto cleanup;
}
......@@ -2059,7 +2060,7 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
goto cleanup;
}
if (git_path_isdir(git_str_cstr(&new_path)) &&
if (git_fs_path_isdir(git_str_cstr(&new_path)) &&
(git_futils_rmdir_r(git_str_cstr(&new_path), NULL, GIT_RMDIR_SKIP_NONEMPTY) < 0)) {
error = -1;
goto cleanup;
......@@ -2096,7 +2097,7 @@ static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name
if ((error = reflog_path(&path, backend->repo, name)) < 0)
goto out;
if (!git_path_exists(path.ptr))
if (!git_fs_path_exists(path.ptr))
goto out;
if ((error = p_unlink(path.ptr)) < 0)
......@@ -2150,11 +2151,11 @@ int git_refdb_backend_fs(
if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_IGNORECASE) && t) {
backend->iterator_flags |= GIT_ITERATOR_IGNORE_CASE;
backend->direach_flags |= GIT_PATH_DIR_IGNORE_CASE;
backend->direach_flags |= GIT_FS_PATH_DIR_IGNORE_CASE;
}
if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_PRECOMPOSE) && t) {
backend->iterator_flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE;
backend->direach_flags |= GIT_PATH_DIR_PRECOMPOSE_UNICODE;
backend->direach_flags |= GIT_FS_PATH_DIR_PRECOMPOSE_UNICODE;
}
if ((!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_FSYNCOBJECTFILES) && t) ||
git_repository__fsync_gitdir)
......
......@@ -902,7 +902,7 @@ int git_reference__normalize_name(
bool validate = (flags & GIT_REFERENCE_FORMAT__VALIDATION_DISABLE) == 0;
#ifdef GIT_USE_ICONV
git_path_iconv_t ic = GIT_PATH_ICONV_INIT;
git_fs_path_iconv_t ic = GIT_PATH_ICONV_INIT;
#endif
GIT_ASSERT_ARG(name);
......@@ -919,8 +919,8 @@ int git_reference__normalize_name(
#ifdef GIT_USE_ICONV
if ((flags & GIT_REFERENCE_FORMAT__PRECOMPOSE_UNICODE) != 0) {
size_t namelen = strlen(current);
if ((error = git_path_iconv_init_precompose(&ic)) < 0 ||
(error = git_path_iconv(&ic, &current, &namelen)) < 0)
if ((error = git_fs_path_iconv_init_precompose(&ic)) < 0 ||
(error = git_fs_path_iconv(&ic, &current, &namelen)) < 0)
goto cleanup;
error = GIT_EINVALIDSPEC;
}
......@@ -1011,7 +1011,7 @@ cleanup:
git_str_dispose(buf);
#ifdef GIT_USE_ICONV
git_path_iconv_clear(&ic);
git_fs_path_iconv_clear(&ic);
#endif
return error;
......
......@@ -16,11 +16,12 @@
#include "repository.h"
#include "tree.h"
#include "iterator.h"
#include "path.h"
#include "fs_path.h"
#include "str.h"
#include "index.h"
#include "worktree.h"
#include "clone.h"
#include "path.h"
#include "git2/config.h"
#include "git2/sys/config.h"
......@@ -149,7 +150,7 @@ static int is_path_occupied(bool *occupied, git_repository *repo, const char *pa
if ((error = git_str_sets(&dir, path)) < 0)
goto out;
if ((error = git_path_to_dir(&dir)) < 0)
if ((error = git_fs_path_to_dir(&dir)) < 0)
goto out;
if ((error = git_index_find_prefix(NULL, index, dir.ptr)) != GIT_ENOTFOUND) {
......@@ -385,10 +386,10 @@ int git_submodule__lookup_with_cache(
if (git_str_join3(&path, '/',
git_repository_workdir(repo),
name, DOT_GIT) < 0 ||
git_path_validate_workdir_buf(NULL, &path) < 0)
git_fs_path_validate_workdir_buf(NULL, &path) < 0)
return -1;
if (git_path_exists(path.ptr))
if (git_fs_path_exists(path.ptr))
error = GIT_EEXISTS;
git_str_dispose(&path);
......@@ -412,17 +413,17 @@ int git_submodule_name_is_valid(git_repository *repo, const char *name, int flag
int error, isvalid;
if (flags == 0)
flags = GIT_PATH_REJECT_FILESYSTEM_DEFAULTS;
flags = GIT_FS_PATH_REJECT_FILESYSTEM_DEFAULTS;
/* Avoid allocating a new string if we can avoid it */
if (strchr(name, '\\') != NULL) {
if ((error = git_path_normalize_slashes(&buf, name)) < 0)
if ((error = git_fs_path_normalize_slashes(&buf, name)) < 0)
return error;
} else {
git_str_attach_notowned(&buf, name, strlen(name));
}
isvalid = git_path_validate(repo, buf.ptr, 0, flags);
isvalid = git_path_validate(repo, buf.ptr, 0, flags);
git_str_dispose(&buf);
return isvalid;
......@@ -743,16 +744,16 @@ static int git_submodule__resolve_url(
/* We do this in all platforms in case someone on Windows created the .gitmodules */
if (strchr(url, '\\')) {
if ((error = git_path_normalize_slashes(&normalized, url)) < 0)
if ((error = git_fs_path_normalize_slashes(&normalized, url)) < 0)
return error;
url = normalized.ptr;
}
if (git_path_is_relative(url)) {
if (git_fs_path_is_relative(url)) {
if (!(error = get_url_base(out, repo)))
error = git_path_apply_relative(out, url);
error = git_fs_path_apply_relative(out, url);
} else if (strchr(url, ':') != NULL || url[0] == '/') {
error = git_str_sets(out, url);
} else {
......@@ -805,7 +806,7 @@ int git_submodule_add_setup(
if (git__prefixcmp(path, git_repository_workdir(repo)) == 0)
path += strlen(git_repository_workdir(repo));
if (git_path_root(path) >= 0) {
if (git_fs_path_root(path) >= 0) {
git_error_set(GIT_ERROR_SUBMODULE, "submodule path must be a relative path");
error = -1;
goto cleanup;
......@@ -846,8 +847,8 @@ int git_submodule_add_setup(
/* if the repo does not already exist, then init a new repo and add it.
* Otherwise, just add the existing repo.
*/
if (!(git_path_exists(name.ptr) &&
git_path_contains(&name, DOT_GIT))) {
if (!(git_fs_path_exists(name.ptr) &&
git_fs_path_contains(&name, DOT_GIT))) {
/* resolve the actual URL to use */
if ((error = git_submodule__resolve_url(&real_url, repo, url)) < 0)
......@@ -1568,13 +1569,13 @@ static int git_submodule__open(
sm->flags |= GIT_SUBMODULE_STATUS__WD_OID_VALID;
else
git_error_clear();
} else if (git_path_exists(path.ptr)) {
} else if (git_fs_path_exists(path.ptr)) {
sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED |
GIT_SUBMODULE_STATUS_IN_WD;
} else {
git_str_rtruncate_at_char(&path, '/'); /* remove "/.git" */
if (git_path_isdir(path.ptr))
if (git_fs_path_isdir(path.ptr))
sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED;
}
......@@ -2105,10 +2106,10 @@ static int submodule_load_from_wd_lite(git_submodule *sm)
if (git_repository_workdir_path(&path, sm->repo, sm->path) < 0)
return -1;
if (git_path_isdir(path.ptr))
if (git_fs_path_isdir(path.ptr))
sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED;
if (git_path_contains(&path, DOT_GIT))
if (git_fs_path_contains(&path, DOT_GIT))
sm->flags |= GIT_SUBMODULE_STATUS_IN_WD;
git_str_dispose(&path);
......@@ -2160,7 +2161,7 @@ static git_config_backend *open_gitmodules(
if (git_repository_workdir_path(&path, repo, GIT_MODULES_FILE) != 0)
return NULL;
if (okay_to_create || git_path_isfile(path.ptr)) {
if (okay_to_create || git_fs_path_isfile(path.ptr)) {
/* git_config_backend_from_file should only fail if OOM */
if (git_config_backend_from_file(&mods, path.ptr) < 0)
mods = NULL;
......
......@@ -9,7 +9,7 @@
#include "runtime.h"
#include "str.h"
#include "path.h"
#include "fs_path.h"
#include <ctype.h>
#if GIT_WIN32
#include "win32/findfile.h"
......@@ -291,7 +291,7 @@ static int git_sysdir_find_in_dirlist(
if (name)
GIT_ERROR_CHECK_ERROR(git_str_joinpath(path, path->ptr, name));
if (git_path_exists(path->ptr))
if (git_fs_path_exists(path->ptr))
return 0;
}
......
......@@ -12,7 +12,7 @@
#include "git2/net.h"
#include "git2/transport.h"
#include "git2/sys/transport.h"
#include "path.h"
#include "fs_path.h"
typedef struct transport_definition {
char *prefix;
......@@ -82,7 +82,7 @@ static int transport_find_fn(
* to a directory and if so assume local path, else assume SSH */
/* Check to see if the path points to a file on the local file system */
if (!definition && git_path_exists(url) && git_path_isdir(url))
if (!definition && git_fs_path_exists(url) && git_fs_path_isdir(url))
definition = &local_transport_definition;
#endif
......@@ -98,7 +98,7 @@ static int transport_find_fn(
#ifndef GIT_WIN32
/* Check to see if the path points to a file on the local file system */
if (!definition && git_path_exists(url) && git_path_isdir(url))
if (!definition && git_fs_path_exists(url) && git_fs_path_isdir(url))
definition = &local_transport_definition;
#endif
......
......@@ -10,7 +10,7 @@
#include "pack-objects.h"
#include "refs.h"
#include "posix.h"
#include "path.h"
#include "fs_path.h"
#include "repository.h"
#include "odb.h"
#include "push.h"
......@@ -226,7 +226,7 @@ static int local_connect(
t->flags = flags;
/* 'url' may be a url or path; convert to a path */
if ((error = git_path_from_url_or_path(&buf, url)) < 0) {
if ((error = git_fs_path_from_url_or_path(&buf, url)) < 0) {
git_str_dispose(&buf);
return error;
}
......@@ -352,7 +352,7 @@ static int local_push(
GIT_UNUSED(cbs);
/* 'push->remote->url' may be a url or path; convert to a path */
if ((error = git_path_from_url_or_path(&buf, push->remote->url)) < 0) {
if ((error = git_fs_path_from_url_or_path(&buf, push->remote->url)) < 0) {
git_str_dispose(&buf);
return error;
}
......
......@@ -13,6 +13,7 @@
#include "futils.h"
#include "tree-cache.h"
#include "index.h"
#include "path.h"
#define DEFAULT_TREE_SIZE 16
#define MAX_FILEMODE_BYTES 6
......@@ -55,7 +56,7 @@ static int valid_entry_name(git_repository *repo, const char *filename)
{
return *filename != '\0' &&
git_path_validate(repo, filename, 0,
GIT_PATH_REJECT_TRAVERSAL | GIT_PATH_REJECT_DOT_GIT | GIT_PATH_REJECT_SLASH);
GIT_FS_PATH_REJECT_TRAVERSAL | GIT_PATH_REJECT_DOT_GIT | GIT_FS_PATH_REJECT_SLASH);
}
static int entry_sort_cmp(const void *a, const void *b)
......@@ -63,7 +64,7 @@ static int entry_sort_cmp(const void *a, const void *b)
const git_tree_entry *e1 = (const git_tree_entry *)a;
const git_tree_entry *e2 = (const git_tree_entry *)b;
return git_path_cmp(
return git_fs_path_cmp(
e1->filename, e1->filename_len, git_tree_entry__is_tree(e1),
e2->filename, e2->filename_len, git_tree_entry__is_tree(e2),
git__strncmp);
......@@ -1171,7 +1172,7 @@ int git_tree_create_updated(git_oid *out, git_repository *repo, git_tree *baseli
/* Figure out how much we need to change from the previous tree */
if (last_update)
common_prefix = git_path_common_dirlen(last_update->path, update->path);
common_prefix = git_fs_path_common_dirlen(last_update->path, update->path);
/*
* The entries are sorted, so when we find we're no
......@@ -1233,7 +1234,7 @@ int git_tree_create_updated(git_oid *out, git_repository *repo, git_tree *baseli
{
/* Make sure we're replacing something of the same type */
tree_stack_entry *last = git_array_last(stack);
char *basename = git_path_basename(update->path);
char *basename = git_fs_path_basename(update->path);
const git_tree_entry *e = git_treebuilder_get(last->bld, basename);
if (e && git_tree_entry_type(e) != git_object__type_from_filemode(update->filemode)) {
git__free(basename);
......@@ -1252,7 +1253,7 @@ int git_tree_create_updated(git_oid *out, git_repository *repo, git_tree *baseli
case GIT_TREE_UPDATE_REMOVE:
{
tree_stack_entry *last = git_array_last(stack);
char *basename = git_path_basename(update->path);
char *basename = git_fs_path_basename(update->path);
error = git_treebuilder_remove(last->bld, basename);
git__free(basename);
break;
......
......@@ -44,7 +44,7 @@ static int win32_path_to_8(git_str *dest, const wchar_t *src)
}
/* Convert backslashes to forward slashes */
git_path_mkposix(utf8_path);
git_fs_path_mkposix(utf8_path);
return git_str_sets(dest, utf8_path);
}
......
......@@ -57,7 +57,7 @@ static wchar_t *path__skip_server(wchar_t *path)
wchar_t *c;
for (c = path; *c; c++) {
if (git_path_is_dirsep(*c))
if (git_fs_path_is_dirsep(*c))
return c + 1;
}
......@@ -71,9 +71,9 @@ static wchar_t *path__skip_prefix(wchar_t *path)
if (wcsncmp(path, L"UNC\\", 4) == 0)
path = path__skip_server(path + 4);
else if (git_path_is_absolute(path))
else if (git_fs_path_is_absolute(path))
path += PATH__ABSOLUTE_LEN;
} else if (git_path_is_absolute(path)) {
} else if (git_fs_path_is_absolute(path)) {
path += PATH__ABSOLUTE_LEN;
} else if (path__is_unc(path)) {
path = path__skip_server(path + 2);
......@@ -204,7 +204,7 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src)
dest += PATH__NT_NAMESPACE_LEN;
/* See if this is an absolute path (beginning with a drive letter) */
if (git_path_is_absolute(src)) {
if (git_fs_path_is_absolute(src)) {
if (git__utf8_to_16(dest, GIT_WIN_PATH_MAX, src) < 0)
goto on_error;
}
......@@ -228,7 +228,7 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src)
if (path__cwd(dest, GIT_WIN_PATH_MAX) < 0)
goto on_error;
if (!git_path_is_absolute(dest)) {
if (!git_fs_path_is_absolute(dest)) {
errno = ENOENT;
goto on_error;
}
......@@ -266,7 +266,7 @@ int git_win32_path_relative_from_utf8(git_win32_path out, const char *src)
int len;
/* Handle absolute paths */
if (git_path_is_absolute(src) ||
if (git_fs_path_is_absolute(src) ||
path__is_nt_namespace(src) ||
path__is_unc(src) ||
path__startswith_slash(src)) {
......@@ -305,7 +305,7 @@ int git_win32_path_to_utf8(git_win32_utf8_path dest, const wchar_t *src)
if ((len = git__utf16_to_8(out, GIT_WIN_PATH_UTF8, src)) < 0)
return len;
git_path_mkposix(dest);
git_fs_path_mkposix(dest);
return len;
}
......
......@@ -418,10 +418,10 @@ static bool target_is_dir(const char *target, const char *path)
git_win32_path resolved_w;
bool isdir = true;
if (git_path_is_absolute(target))
if (git_fs_path_is_absolute(target))
git_win32_path_from_utf8(resolved_w, target);
else if (git_path_dirname_r(&resolved, path) < 0 ||
git_path_apply_relative(&resolved, target) < 0 ||
else if (git_fs_path_dirname_r(&resolved, path) < 0 ||
git_fs_path_apply_relative(&resolved, target) < 0 ||
git_win32_path_from_utf8(resolved_w, resolved.ptr) < 0)
goto out;
......@@ -661,7 +661,7 @@ int p_getcwd(char *buffer_out, size_t size)
return -1;
}
git_path_mkposix(buffer_out);
git_fs_path_mkposix(buffer_out);
return 0;
}
......@@ -821,7 +821,7 @@ char *p_realpath(const char *orig_path, char *buffer)
if (git_win32_path_to_utf8(buffer, buffer_w) < 0)
return NULL;
git_path_mkposix(buffer);
git_fs_path_mkposix(buffer);
return buffer;
}
......
......@@ -22,9 +22,9 @@ static bool is_worktree_dir(const char *dir)
if (git_str_sets(&buf, dir) < 0)
return -1;
error = git_path_contains_file(&buf, "commondir")
&& git_path_contains_file(&buf, "gitdir")
&& git_path_contains_file(&buf, "HEAD");
error = git_fs_path_contains_file(&buf, "commondir")
&& git_fs_path_contains_file(&buf, "gitdir")
&& git_fs_path_contains_file(&buf, "HEAD");
git_str_dispose(&buf);
return error;
......@@ -46,9 +46,9 @@ int git_worktree_list(git_strarray *wts, git_repository *repo)
if ((error = git_str_joinpath(&path, repo->commondir, "worktrees/")) < 0)
goto exit;
if (!git_path_exists(path.ptr) || git_path_is_empty_dir(path.ptr))
if (!git_fs_path_exists(path.ptr) || git_fs_path_is_empty_dir(path.ptr))
goto exit;
if ((error = git_path_dirload(&worktrees, path.ptr, path.size, 0x0)) < 0)
if ((error = git_fs_path_dirload(&worktrees, path.ptr, path.size, 0x0)) < 0)
goto exit;
len = path.size;
......@@ -86,12 +86,12 @@ char *git_worktree__read_link(const char *base, const char *file)
git_str_rtrim(&buf);
if (!git_path_is_relative(buf.ptr))
if (!git_fs_path_is_relative(buf.ptr))
return git_str_detach(&buf);
if (git_str_sets(&path, base) < 0)
goto err;
if (git_path_apply_relative(&path, buf.ptr) < 0)
if (git_fs_path_apply_relative(&path, buf.ptr) < 0)
goto err;
git_str_dispose(&buf);
......@@ -136,7 +136,7 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
goto out;
}
if ((error = git_path_validate_workdir(NULL, dir)) < 0)
if ((error = git_fs_path_validate_workdir(NULL, dir)) < 0)
goto out;
if ((wt = git__calloc(1, sizeof(*wt))) == NULL) {
......@@ -148,12 +148,12 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
(wt->commondir_path = git_worktree__read_link(dir, "commondir")) == NULL ||
(wt->gitlink_path = git_worktree__read_link(dir, "gitdir")) == NULL ||
(parent && (wt->parent_path = git__strdup(parent)) == NULL) ||
(wt->worktree_path = git_path_dirname(wt->gitlink_path)) == NULL) {
(wt->worktree_path = git_fs_path_dirname(wt->gitlink_path)) == NULL) {
error = -1;
goto out;
}
if ((error = git_path_prettify_dir(&gitdir, dir, NULL)) < 0)
if ((error = git_fs_path_prettify_dir(&gitdir, dir, NULL)) < 0)
goto out;
wt->gitdir_path = git_str_detach(&gitdir);
......@@ -214,11 +214,11 @@ int git_worktree_open_from_repository(git_worktree **out, git_repository *repo)
gitdir = git_repository_path(repo);
commondir = git_repository_commondir(repo);
if ((error = git_path_prettify_dir(&parent, "..", commondir)) < 0)
if ((error = git_fs_path_prettify_dir(&parent, "..", commondir)) < 0)
goto out;
/* The name is defined by the last component in '.git/worktree/%s' */
name = git_path_basename(gitdir);
name = git_fs_path_basename(gitdir);
if ((error = open_worktree_dir(out, parent.ptr, gitdir, name)) < 0)
goto out;
......@@ -255,21 +255,21 @@ int git_worktree_validate(const git_worktree *wt)
return GIT_ERROR;
}
if (wt->parent_path && !git_path_exists(wt->parent_path)) {
if (wt->parent_path && !git_fs_path_exists(wt->parent_path)) {
git_error_set(GIT_ERROR_WORKTREE,
"worktree parent directory ('%s') does not exist ",
wt->parent_path);
return GIT_ERROR;
}
if (!git_path_exists(wt->commondir_path)) {
if (!git_fs_path_exists(wt->commondir_path)) {
git_error_set(GIT_ERROR_WORKTREE,
"worktree common directory ('%s') does not exist ",
wt->commondir_path);
return GIT_ERROR;
}
if (!git_path_exists(wt->worktree_path)) {
if (!git_fs_path_exists(wt->worktree_path)) {
git_error_set(GIT_ERROR_WORKTREE,
"worktree directory '%s' does not exist",
wt->worktree_path);
......@@ -337,20 +337,20 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
/* Create gitdir directory ".git/worktrees/<name>" */
if ((err = git_str_joinpath(&gitdir, repo->commondir, "worktrees")) < 0)
goto out;
if (!git_path_exists(gitdir.ptr))
if (!git_fs_path_exists(gitdir.ptr))
if ((err = git_futils_mkdir(gitdir.ptr, 0755, GIT_MKDIR_EXCL)) < 0)
goto out;
if ((err = git_str_joinpath(&gitdir, gitdir.ptr, name)) < 0)
goto out;
if ((err = git_futils_mkdir(gitdir.ptr, 0755, GIT_MKDIR_EXCL)) < 0)
goto out;
if ((err = git_path_prettify_dir(&gitdir, gitdir.ptr, NULL)) < 0)
if ((err = git_fs_path_prettify_dir(&gitdir, gitdir.ptr, NULL)) < 0)
goto out;
/* Create worktree work dir */
if ((err = git_futils_mkdir(worktree, 0755, GIT_MKDIR_EXCL)) < 0)
goto out;
if ((err = git_path_prettify_dir(&wddir, worktree, NULL)) < 0)
if ((err = git_fs_path_prettify_dir(&wddir, worktree, NULL)) < 0)
goto out;
if (wtopts.lock) {
......@@ -375,7 +375,7 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
goto out;
/* Create gitdir files */
if ((err = git_path_prettify_dir(&buf, repo->commondir, NULL) < 0)
if ((err = git_fs_path_prettify_dir(&buf, repo->commondir, NULL) < 0)
|| (err = git_str_putc(&buf, '\n')) < 0
|| (err = write_wtfile(gitdir.ptr, "commondir", &buf)) < 0)
goto out;
......@@ -494,7 +494,7 @@ static int git_worktree__is_locked(git_str *reason, const git_worktree *wt)
if ((error = git_str_joinpath(&path, wt->gitdir_path, "locked")) < 0)
goto out;
locked = git_path_exists(path.ptr);
locked = git_fs_path_exists(path.ptr);
if (locked && reason &&
(error = git_futils_readbuffer(reason, path.ptr)) < 0)
goto out;
......@@ -614,7 +614,7 @@ int git_worktree_prune(git_worktree *wt,
/* Delete gitdir in parent repository */
if ((err = git_str_join3(&path, '/', wt->commondir_path, "worktrees", wt->name)) < 0)
goto out;
if (!git_path_exists(path.ptr))
if (!git_fs_path_exists(path.ptr))
{
git_error_set(GIT_ERROR_WORKTREE, "worktree gitdir '%s' does not exist", path.ptr);
err = -1;
......@@ -626,15 +626,15 @@ int git_worktree_prune(git_worktree *wt,
/* Skip deletion of the actual working tree if it does
* not exist or deletion was not requested */
if ((popts.flags & GIT_WORKTREE_PRUNE_WORKING_TREE) == 0 ||
!git_path_exists(wt->gitlink_path))
!git_fs_path_exists(wt->gitlink_path))
{
goto out;
}
if ((wtpath = git_path_dirname(wt->gitlink_path)) == NULL)
if ((wtpath = git_fs_path_dirname(wt->gitlink_path)) == NULL)
goto out;
git_str_attach(&path, wtpath, 0);
if (!git_path_exists(path.ptr))
if (!git_fs_path_exists(path.ptr))
{
git_error_set(GIT_ERROR_WORKTREE, "working tree '%s' does not exist", path.ptr);
err = -1;
......
......@@ -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));
......
......@@ -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(
......
......@@ -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);
......
......@@ -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)
......
......@@ -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");
}
......
......@@ -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;
......
......@@ -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
......
......@@ -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)));
......
......@@ -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);
......
#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(
......
......@@ -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)
......@@ -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)
......
......@@ -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"));
......
#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);
......
......@@ -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"));
}
......@@ -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"));
......@@ -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);
......
......@@ -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,12 +37,12 @@ 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)
......@@ -50,7 +50,7 @@ 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);
}
......@@ -74,73 +74,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");
......
......@@ -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);
}
......@@ -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.
......
......@@ -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));
......
......@@ -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"));
......
#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
......
......@@ -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));
......
#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));
}
......@@ -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();
/*
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......@@ -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;
......
......@@ -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");
......
......@@ -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") &&
......
......@@ -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");
......
......@@ -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(
......
......@@ -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;
......
......@@ -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;
......
......@@ -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)
......
......@@ -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);
......
......@@ -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)
......
......@@ -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));
......
......@@ -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)
......
......@@ -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));
......@@ -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"));
}
......@@ -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
}
......@@ -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)
......
......@@ -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)
......
#include "clar_libgit2.h"
#include "path.h"
static char *gitmodules_altnames[] = {
......@@ -118,3 +119,88 @@ void test_path_dotgit__dotgit_modules_symlink(void)
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));
}
void test_core_path__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_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));
}
void test_path_dotgit__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));
}
void test_path_dotgit__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));
}
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -16,7 +16,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);
......
......@@ -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));
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment