diff --git a/dir.c b/dir.c index 7d255227b1..5d4c92d3aa 100644 --- a/dir.c +++ b/dir.c @@ -2383,6 +2383,10 @@ static int treat_leading_path(struct dir_struct *dir, (dir->flags & DIR_SHOW_IGNORED_TOO || do_match_pathspec(istate, pathspec, sb.buf, sb.len, baselen, NULL, DO_MATCH_LEADING_PATHSPEC) == MATCHED_RECURSIVELY_LEADING_PATHSPEC)) { + if (!match_pathspec(istate, pathspec, sb.buf, sb.len, + 0 /* prefix */, NULL, + 0 /* do NOT special case dirs */)) + state = path_none; add_path_to_appropriate_result_list(dir, NULL, &cdir, istate, &sb, baselen, diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh index 782e125c89..cb5e34d94c 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -737,7 +737,7 @@ test_expect_success MINGW 'handle clean & core.longpaths = false nicely' ' test_i18ngrep "too long" .git/err ' -test_expect_failure 'clean untracked paths by pathspec' ' +test_expect_success 'clean untracked paths by pathspec' ' git init untracked && mkdir untracked/dir && echo >untracked/dir/file.txt &&