summaryrefslogtreecommitdiff
path: root/src/blob.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@elego.de>2011-06-20 17:53:21 +0200
committerCarlos Martín Nieto <cmn@elego.de>2011-06-20 17:53:21 +0200
commit4cea2f0369238008100e00a5b2bc74eded24b6ee (patch)
treee12600d9de4b2989db4a6f5ce34ac7b15dec56d3 /src/blob.c
parentcdb6f9bf5e77b6e83d4bdc6cd75c31d0d3377800 (diff)
downloadlibgit2-4cea2f0369238008100e00a5b2bc74eded24b6ee.tar.gz
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>
Diffstat (limited to 'src/blob.c')
-rw-r--r--src/blob.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/blob.c b/src/blob.c
index ceb2c9c44..d18aa5c36 100644
--- a/src/blob.c
+++ b/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;
struct stat st;
- gitfo_lstat(path, &st);
-
- islnk = S_ISLNK(st.st_mode);
-
if (repo->path_workdir == NULL)
return git__throw(GIT_ENOTFOUND, "Failed to create blob. (No working directory found)");
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 ((fd = gitfo_open(full_path, O_RDONLY)) < 0)
return git__throw(GIT_ENOTFOUND, "Failed to create blob. Could not open '%s'", full_path);