Fix incorrect usage of `WalkState::Skip` with explanations

This commit is contained in:
cyqsimon 2023-03-02 17:01:11 +08:00
parent 7d49fb9e29
commit 75b612f4fc
No known key found for this signature in database
GPG Key ID: 1D8CE2F297390D65
1 changed files with 10 additions and 3 deletions

View File

@ -538,9 +538,16 @@ fn spawn_senders(
.iter()
.any(|glob| glob.is_match(&path))
{
// emulate Git's behavior of skipping any matched directory entirely
// see https://git-scm.com/docs/gitignore#_pattern_format
return ignore::WalkState::Skip;
// Ideally we want to return `WalkState::Skip` to emulate gitignore's
// behavior of skipping any matched directory entirely
// Unfortunately this will make the search behaviour inconsistent
// because this filter happens outside of the directory walker
//
// E.g. Given directory structure `/foo/bar/` and CWD `/`:
// - `fd --exclude-absolute '/foo'` will return nothing
// - `fd --exclude-absolute '/foo' bar` will return '/foo/bar'
// Obviously this makes no sense
return ignore::WalkState::Continue;
}
}
Err(err) => {