summaryrefslogtreecommitdiff
path: root/src/index.c
diff options
context:
space:
mode:
authorRussell Belfer <arrbee@arrbee.com>2011-12-18 12:08:50 -0800
committerRussell Belfer <arrbee@arrbee.com>2011-12-18 12:08:50 -0800
commit86e356ee51b07049202078b1ad2f23ac7136075e (patch)
tree6d31a7bd6c6cff8d33e0030677751f231fa517f1 /src/index.c
parent3e72809b5ec73b3aa416f3b12d6fd066f83dcb79 (diff)
downloadlibgit2-86e356ee51b07049202078b1ad2f23ac7136075e.tar.gz
Restore missing lstat in index_entry_init
In an effort to remove duplicate code, I accidentally left the stat structure uninitialized in this function. This patch restores that data gathering.
Diffstat (limited to 'src/index.c')
-rw-r--r--src/index.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/index.c b/src/index.c
index 9baab16a9..43e8efa57 100644
--- a/src/index.c
+++ b/src/index.c
@@ -297,6 +297,8 @@ static int index_entry_init(git_index_entry **entry_out, git_index *index, const
git_index_entry *entry = NULL;
struct stat st;
git_oid oid;
+ const char *workdir;
+ git_buf full_path = GIT_BUF_INIT;
int error;
if (INDEX_OWNER(index) == NULL)
@@ -307,6 +309,23 @@ static int index_entry_init(git_index_entry **entry_out, git_index *index, const
return git__throw(GIT_ERROR,
"Failed to initialize entry. Invalid stage %i", stage);
+ workdir = git_repository_workdir(INDEX_OWNER(index));
+ if (workdir == NULL)
+ return git__throw(GIT_EBAREINDEX,
+ "Failed to initialize entry. Cannot resolved workdir");
+
+ error = git_buf_joinpath(&full_path, workdir, rel_path);
+ if (error < GIT_SUCCESS)
+ return error;
+
+ if (p_lstat(full_path.ptr, &st) < 0) {
+ error = git__throw(GIT_ENOTFOUND, "Failed to initialize entry. '%s' cannot be opened. %s", full_path.ptr, strerror(errno));
+ git_buf_free(&full_path);
+ return error;
+ }
+
+ git_buf_free(&full_path); /* done with full path */
+
/* There is no need to validate the rel_path here, since it will be
* immediately validated by the call to git_blob_create_fromfile.
*/