Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a4ded36

Browse files
committed
iterator: skip over errors in diriter init
An error here will typically mean that the directory was removed between the time we iterated the parent and the time we wanted to visit it in which case we should ignore it. Other kinds of errors such as permissions (or transient errors) also better dealt with by pretending we didn't see it.
1 parent 6a0d569 commit a4ded36

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/iterator.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,8 +1027,11 @@ static int dirload_with_stat(
10271027
strncomp = (flags & GIT_PATH_DIR_IGNORE_CASE) != 0 ?
10281028
git__strncasecmp : git__strncmp;
10291029

1030-
if ((error = git_path_diriter_init(&diriter, dirpath, flags)) < 0)
1030+
/* Any error here is equivalent to the dir not existing, skip over it */
1031+
if ((error = git_path_diriter_init(&diriter, dirpath, flags)) < 0) {
1032+
error = GIT_ENOTFOUND;
10311033
goto done;
1034+
}
10321035

10331036
while ((error = git_path_diriter_next(&diriter)) == 0) {
10341037
if ((error = git_path_diriter_fullpath(&path, &path_len, &diriter)) < 0)

0 commit comments

Comments
 (0)