mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-06 11:19:47 +00:00
fileops: Allow differentiation between deep and shallow exists()
When calling gitfo_exists() on a symbolic link, sometimes we need to simply check whether the link exists and sometimes we need to check whether the file pointed to by the symlink exists. Introduce a new function gitfo_shallow_exists that only checks if the link exists and revert gitfo_exists to the original functionality of checking whether the file pointed to by the link exists.
This commit is contained in:
parent
ee4912bf79
commit
fdd1e04ce7
@ -170,6 +170,12 @@ int gitfo_isfile(const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int gitfo_exists(const char *path)
|
int gitfo_exists(const char *path)
|
||||||
|
{
|
||||||
|
assert(path);
|
||||||
|
return access(path, F_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
int gitfo_shallow_exists(const char *path)
|
||||||
{
|
{
|
||||||
assert(path);
|
assert(path);
|
||||||
|
|
||||||
|
@ -411,7 +411,7 @@ static int index_init_entry(git_index_entry *entry, git_index *index, const char
|
|||||||
|
|
||||||
git__joinpath(full_path, index->repository->path_workdir, rel_path);
|
git__joinpath(full_path, index->repository->path_workdir, rel_path);
|
||||||
|
|
||||||
if (gitfo_exists(full_path) < 0)
|
if (gitfo_shallow_exists(full_path) < 0)
|
||||||
return git__throw(GIT_ENOTFOUND, "Failed to initialize entry. %s does not exist", full_path);
|
return git__throw(GIT_ENOTFOUND, "Failed to initialize entry. %s does not exist", full_path);
|
||||||
|
|
||||||
if (gitfo_lstat(full_path, &st) < 0)
|
if (gitfo_lstat(full_path, &st) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user