summaryrefslogtreecommitdiff
path: root/src/path.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-07-25 17:49:20 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-07-25 17:49:20 +0200
commit02f03b7fd6d06fce85e5337b17b6778951bac971 (patch)
tree05866d1916ddefdc746fa3a8f342ad3a1f75c72f /src/path.c
parent42156d561723e92ffe597885719aa63abfe0795c (diff)
downloadlibgit2-cmn/diriter-notfound.tar.gz
path: convert diropen's ENOENT to GIT_ENOTFOUNDcmn/diriter-notfound
If a directory is removed between the listing of its parent and the attempt to traverse it, we need to indicate that through our error code so the caller knows to continue.
Diffstat (limited to 'src/path.c')
-rw-r--r--src/path.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/path.c b/src/path.c
index 2558058dd..c8f674c74 100644
--- a/src/path.c
+++ b/src/path.c
@@ -1260,10 +1260,15 @@ int git_path_diriter_init(
}
if ((diriter->dir = opendir(diriter->path.ptr)) == NULL) {
+ int error = -1;
+
git_buf_free(&diriter->path);
+ if (errno == ENOENT)
+ error = GIT_ENOTFOUND;
+
giterr_set(GITERR_OS, "Failed to open directory '%s'", path);
- return -1;
+ return error;
}
#ifdef GIT_USE_ICONV