Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dir: fix treat_leading_path() to return false on non-directories
If treat_leading_path() encounters a non-directory in its loop over each leading path component, it should return false. This bug was introduced in commit b9670c1 ("dir: fix checks on common prefix directory", 2019-12-19) where the check for `is_directory(sb.buf)` still breaks out of the loop but doesn't return false anymore. Instead, the loop is broken out and the last state result in the loop is used in the return conditional: `state == path_recurse`. This prevents the warning "warning: could not open directory" errors from occurring in `git status` or `git ls-files -o` calls on non-directory pathspecs. The warning was introduced in commit b673155 ("dir.c: stop ignoring opendir() error in open_cached_dir()", 2018-02-02). Signed-off-by: Ivan Tse <ivan.tse1@gmail.com>
- Loading branch information