diff options
author | Vicent Marti <tanoku@gmail.com> | 2011-12-09 01:38:46 +0100 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2011-12-09 01:38:46 +0100 |
commit | 40e73d6f8886d27ae9c7df059d995221e6d84710 (patch) | |
tree | 4a6136463adbaa22a9aea3eb605d6c0dfbc97a7e /src/index.c | |
parent | e92386876606c734fae9d2f5bd6c80861ccfe409 (diff) | |
parent | 97769280ba9938ae27f6e06cbd0d5e8a768a86b9 (diff) | |
download | libgit2-40e73d6f8886d27ae9c7df059d995221e6d84710.tar.gz |
Merge remote-tracking branch 'arrbee/git-buf-for-paths' into development
Conflicts:
tests-clay/clay_main.c
Diffstat (limited to 'src/index.c')
-rw-r--r-- | src/index.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/index.c b/src/index.c index 9f336ba0a..9baab16a9 100644 --- a/src/index.c +++ b/src/index.c @@ -294,40 +294,30 @@ git_index_entry *git_index_get(git_index *index, unsigned int n) static int index_entry_init(git_index_entry **entry_out, git_index *index, const char *rel_path, int stage) { - git_index_entry *entry; - char full_path[GIT_PATH_MAX]; + git_index_entry *entry = NULL; struct stat st; git_oid oid; int error; - const char *workdir; if (INDEX_OWNER(index) == NULL) return git__throw(GIT_EBAREINDEX, "Failed to initialize entry. Repository is bare"); - workdir = git_repository_workdir(INDEX_OWNER(index)); - if (workdir == NULL) - return git__throw(GIT_EBAREINDEX, - "Failed to initialize entry. Cannot resolved workdir"); - - git_path_join(full_path, workdir, rel_path); - - if (p_lstat(full_path, &st) < 0) - return git__throw(GIT_ENOTFOUND, - "Failed to initialize entry. '%s' cannot be opened", full_path); - if (stage < 0 || stage > 3) return git__throw(GIT_ERROR, "Failed to initialize entry. Invalid stage %i", stage); + /* There is no need to validate the rel_path here, since it will be + * immediately validated by the call to git_blob_create_fromfile. + */ + /* write the blob to disk and get the oid */ if ((error = git_blob_create_fromfile(&oid, INDEX_OWNER(index), rel_path)) < GIT_SUCCESS) return git__rethrow(error, "Failed to initialize index entry"); - entry = git__malloc(sizeof(git_index_entry)); + entry = git__calloc(1, sizeof(git_index_entry)); if (!entry) return GIT_ENOMEM; - memset(entry, 0x0, sizeof(git_index_entry)); entry->ctime.seconds = (git_time_t)st.st_ctime; entry->mtime.seconds = (git_time_t)st.st_mtime; |