mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-23 09:10:46 +00:00
Stat files with full pathnames
Call gitfo_lstat with the full pathname instead of the relative one, which fails in case the current working directory is different from the workdir. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
This commit is contained in:
parent
cdb6f9bf5e
commit
4cea2f0369
12
src/blob.c
12
src/blob.c
@ -88,15 +88,19 @@ int git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *pat
|
|||||||
git_odb_stream *stream;
|
git_odb_stream *stream;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
gitfo_lstat(path, &st);
|
|
||||||
|
|
||||||
islnk = S_ISLNK(st.st_mode);
|
|
||||||
|
|
||||||
if (repo->path_workdir == NULL)
|
if (repo->path_workdir == NULL)
|
||||||
return git__throw(GIT_ENOTFOUND, "Failed to create blob. (No working directory found)");
|
return git__throw(GIT_ENOTFOUND, "Failed to create blob. (No working directory found)");
|
||||||
|
|
||||||
git__joinpath(full_path, repo->path_workdir, path);
|
git__joinpath(full_path, repo->path_workdir, path);
|
||||||
|
|
||||||
|
error = gitfo_lstat(full_path, &st);
|
||||||
|
if (error < 0) {
|
||||||
|
return git__throw(GIT_EOSERR, "Failed to stat blob. %s", strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
islnk = S_ISLNK(st.st_mode);
|
||||||
|
|
||||||
|
|
||||||
if (!islnk) {
|
if (!islnk) {
|
||||||
if ((fd = gitfo_open(full_path, O_RDONLY)) < 0)
|
if ((fd = gitfo_open(full_path, O_RDONLY)) < 0)
|
||||||
return git__throw(GIT_ENOTFOUND, "Failed to create blob. Could not open '%s'", full_path);
|
return git__throw(GIT_ENOTFOUND, "Failed to create blob. Could not open '%s'", full_path);
|
||||||
|
Loading…
Reference in New Issue
Block a user