File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -32,11 +32,16 @@ impl ignore::ParallelVisitor for WalkVisitor {
3232 fn visit ( & mut self , entry : Result < ignore:: DirEntry , ignore:: Error > ) -> ignore:: WalkState {
3333 match entry {
3434 Ok ( entry) => {
35- // Skip if we can't get file type or if it's a directory
36- if let Some ( file_type) = entry. file_type ( )
37- && !file_type. is_dir ( )
38- && let Some ( source_type) = get_supported_source_type ( entry. path ( ) )
39- {
35+ let Some ( file_type) = entry. file_type ( ) else {
36+ return ignore:: WalkState :: Continue ;
37+ } ;
38+ if file_type. is_dir ( ) {
39+ // Skip traversing `.git` directories because `.git` is not a special case for `.hidden(false)`.
40+ // <https://github.com/BurntSushi/ripgrep/issues/3099#issuecomment-3052460027>
41+ if entry. file_name ( ) == ".git" {
42+ return ignore:: WalkState :: Skip ;
43+ }
44+ } else if let Some ( source_type) = get_supported_source_type ( entry. path ( ) ) {
4045 let walk_entry =
4146 WalkEntry { path : entry. path ( ) . as_os_str ( ) . into ( ) , source_type } ;
4247 // Send each entry immediately through the channel
Original file line number Diff line number Diff line change @@ -52,6 +52,11 @@ impl ignore::ParallelVisitor for WalkCollector {
5252 fn visit ( & mut self , entry : Result < ignore:: DirEntry , ignore:: Error > ) -> ignore:: WalkState {
5353 match entry {
5454 Ok ( entry) => {
55+ // Skip traversing `.git` directories because `.git` is not a special case for `.hidden(false)`.
56+ // <https://github.com/BurntSushi/ripgrep/issues/3099#issuecomment-3052460027>
57+ if entry. file_type ( ) . is_some_and ( |ty| ty. is_dir ( ) ) && entry. file_name ( ) == ".git" {
58+ return ignore:: WalkState :: Skip ;
59+ }
5560 if Walk :: is_wanted_entry ( & entry, & self . extensions ) {
5661 self . paths . push ( entry. path ( ) . as_os_str ( ) . into ( ) ) ;
5762 }
You can’t perform that action at this time.
0 commit comments