X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=dir.c;h=0a78d00b545ac4f302ea89b6393773669907599e;hb=bd193f46b70fd3f8a55e2a8dcbb1fb2b4eec13d6;hp=6c0d7825799f6c35a2c1f1830767ab6203e2da92;hpb=84a9ea90e1d704bcac9d26837dff9e3cd7609376;p=git.git diff --git a/dir.c b/dir.c index 6c0d78257..0a78d00b5 100644 --- a/dir.c +++ b/dir.c @@ -968,34 +968,34 @@ static int read_directory_recursive(struct dir_struct *dir, { DIR *fdir = opendir(*base ? base : "."); int contents = 0; + struct dirent *de; + char path[PATH_MAX + 1]; - if (fdir) { - struct dirent *de; - char path[PATH_MAX + 1]; - memcpy(path, base, baselen); - - while ((de = readdir(fdir)) != NULL) { - int len; - switch (treat_path(dir, de, path, sizeof(path), - baselen, simplify, &len)) { - case path_recurse: - contents += read_directory_recursive - (dir, path, len, 0, simplify); - continue; - case path_ignored: - continue; - case path_handled: - break; - } - contents++; - if (check_only) - goto exit_early; - else - dir_add_name(dir, path, len); + if (!fdir) + return 0; + + memcpy(path, base, baselen); + + while ((de = readdir(fdir)) != NULL) { + int len; + switch (treat_path(dir, de, path, sizeof(path), + baselen, simplify, &len)) { + case path_recurse: + contents += read_directory_recursive(dir, path, len, 0, simplify); + continue; + case path_ignored: + continue; + case path_handled: + break; } -exit_early: - closedir(fdir); + contents++; + if (check_only) + goto exit_early; + else + dir_add_name(dir, path, len); } +exit_early: + closedir(fdir); return contents; }