@@ -4579,6 +4579,7 @@ fn in_repo_hidden_worktree() -> crate::Result {
4579
4579
& root,
4580
4580
ctx,
4581
4581
walk:: Options {
4582
+ for_deletion : None ,
4582
4583
worktree_relative_worktree_dirs : Some ( & BTreeSet :: from ( [ "hidden/subdir/worktree" . into ( ) ] ) ) ,
4583
4584
..options_emit_all ( )
4584
4585
} ,
@@ -4601,7 +4602,48 @@ fn in_repo_hidden_worktree() -> crate::Result {
4601
4602
entry( "dir/file" , Tracked , File ) ,
4602
4603
entry( "hidden" , Ignored ( Expendable ) , Directory ) ,
4603
4604
] ,
4604
- "Currently, worktrees can't be found in ignored directories, even though hit should "
4605
+ "Without the intend to delete, the worktree remains hidden, which is what we want to see in a `status` for example "
4605
4606
) ;
4607
+
4608
+ for ignored_emission_mode in [ Matching , CollapseDirectory ] {
4609
+ for deletion_mode in [
4610
+ ForDeletionMode :: IgnoredDirectoriesCanHideNestedRepositories ,
4611
+ ForDeletionMode :: FindRepositoriesInIgnoredDirectories ,
4612
+ ForDeletionMode :: FindNonBareRepositoriesInIgnoredDirectories ,
4613
+ ] {
4614
+ let ( ( out, _root) , entries) = collect ( & root, None , |keep, ctx| {
4615
+ walk (
4616
+ & root,
4617
+ ctx,
4618
+ walk:: Options {
4619
+ emit_ignored : Some ( ignored_emission_mode) ,
4620
+ for_deletion : Some ( deletion_mode) ,
4621
+ worktree_relative_worktree_dirs : Some ( & BTreeSet :: from ( [ "hidden/subdir/worktree" . into ( ) ] ) ) ,
4622
+ ..options_emit_all ( )
4623
+ } ,
4624
+ keep,
4625
+ )
4626
+ } ) ;
4627
+ assert_eq ! (
4628
+ out,
4629
+ walk:: Outcome {
4630
+ read_dir_calls: 4 ,
4631
+ returned_entries: entries. len( ) ,
4632
+ seen_entries: 5 ,
4633
+ }
4634
+ ) ;
4635
+ assert_eq ! (
4636
+ entries,
4637
+ & [
4638
+ entry_nokind( ".git" , Pruned ) . with_property( DotGit ) . with_match( Always ) ,
4639
+ entry( ".gitignore" , Untracked , File ) ,
4640
+ entry( "dir/file" , Tracked , File ) ,
4641
+ entry( "hidden/file" , Ignored ( Expendable ) , File ) ,
4642
+ entry( "hidden/subdir/worktree" , Tracked , Repository ) . no_index_kind( ) ,
4643
+ ] ,
4644
+ "Worktrees within hidden directories are also detected and protected by counting them as tracked (like submodules)"
4645
+ ) ;
4646
+ }
4647
+ }
4606
4648
Ok ( ( ) )
4607
4649
}
0 commit comments