summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Penny <jasonpenny4@gmail.com>2011-07-09 00:08:52 -0400
committerVicent Marti <tanoku@gmail.com>2011-07-09 13:49:50 +0200
commit3b2a423c3fb9e434c427b819d3281ae9e277091d (patch)
tree4c2a88c1f85a5c804cd2bce80ccd6f636aecaca8 /src
parent2b90cc26de1c6b71059a7fc43be32a3be7fb35b9 (diff)
downloadlibgit2-3b2a423c3fb9e434c427b819d3281ae9e277091d.tar.gz
status: nonexistent file with git_status_file()
Throws GIT_ENOTFOUND error if given a filename that is not in HEAD, index, nor the work tree.
Diffstat (limited to 'src')
-rw-r--r--src/status.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/status.c b/src/status.c
index e42184292..9f826e0bc 100644
--- a/src/status.c
+++ b/src/status.c
@@ -258,6 +258,9 @@ static int set_status_flags(struct status_entry *e)
index_zero = git_oid_cmp(&zero, &e->index_oid);
wt_zero = git_oid_cmp(&zero, &e->wt_oid);
+ if (head_zero == 0 && index_zero == 0 && wt_zero == 0)
+ return GIT_ENOTFOUND;
+
if (head_zero == 0 && index_zero != 0)
e->status_flags |= GIT_STATUS_INDEX_NEW;
else if (index_zero == 0 && head_zero != 0)
@@ -345,7 +348,7 @@ int git_status_file(unsigned int *status_flags, git_repository *repo, const char
git_index *index;
git_index_entry *index_entry;
char temp_path[GIT_PATH_MAX];
- int idx;
+ int idx, error;
git_tree *tree;
git_reference *head_ref, *resolved_head_ref;
git_commit *head_commit;
@@ -377,7 +380,9 @@ int git_status_file(unsigned int *status_flags, git_repository *repo, const char
strcpy(temp_path, repo->path_workdir);
git_futils_direach(temp_path, GIT_PATH_MAX, single_dirent_cb, &e);
- set_status_flags(e);
+ if ((error = set_status_flags(e)) < GIT_SUCCESS)
+ return git__throw(error, "Nonexistent file");
+
*status_flags = e->status_flags;
free(e);