| @@ -4550,3 +4550,58 @@ fn in_repo_worktree() -> crate::Result { · 4549 unmodified lines |
| 4550 | 4550 | ); |
| 4551 | 4551 | Ok(()) |
| 4552 | 4552 | } |
| 4553 | + |
| 4554 | +#[test] |
| 4555 | +fn in_repo_hidden_worktree() -> crate::Result { |
| 4556 | + let root = fixture("in-repo-hidden-worktree"); |
| 4557 | + let ((out, _root), entries) = collect(&root, None, |keep, ctx| walk(&root, ctx, options_emit_all(), keep)); |
| 4558 | + assert_eq!( |
| 4559 | + out, |
| 4560 | + walk::Outcome { |
| 4561 | + read_dir_calls: 2, |
| 4562 | + returned_entries: entries.len(), |
| 4563 | + seen_entries: 4, |
| 4564 | + } |
| 4565 | + ); |
| 4566 | + assert_eq!( |
| 4567 | + entries, |
| 4568 | + &[ |
| 4569 | + entry_nokind(".git", Pruned).with_property(DotGit).with_match(Always), |
| 4570 | + entry(".gitignore", Untracked, File), |
| 4571 | + entry("dir/file", Tracked, File), |
| 4572 | + entry("hidden", Ignored(Expendable), Directory), |
| 4573 | + ], |
| 4574 | + "if worktree information isn't provided, they would not be discovered in hidden directories" |
| 4575 | + ); |
| 4576 | + |
| 4577 | + let ((out, _root), entries) = collect(&root, None, |keep, ctx| { |
| 4578 | + walk( |
| 4579 | + &root, |
| 4580 | + ctx, |
| 4581 | + walk::Options { |
| 4582 | + worktree_relative_worktree_dirs: Some(&BTreeSet::from(["hidden/subdir/worktree".into()])), |
| 4583 | + ..options_emit_all() |
| 4584 | + }, |
| 4585 | + keep, |
| 4586 | + ) |
| 4587 | + }); |
| 4588 | + assert_eq!( |
| 4589 | + out, |
| 4590 | + walk::Outcome { |
| 4591 | + read_dir_calls: 2, |
| 4592 | + returned_entries: entries.len(), |
| 4593 | + seen_entries: 4, |
| 4594 | + } |
| 4595 | + ); |
| 4596 | + assert_eq!( |
| 4597 | + entries, |
| 4598 | + &[ |
| 4599 | + entry_nokind(".git", Pruned).with_property(DotGit).with_match(Always), |
| 4600 | + entry(".gitignore", Untracked, File), |
| 4601 | + entry("dir/file", Tracked, File), |
| 4602 | + entry("hidden", Ignored(Expendable), Directory), |
| 4603 | + ], |
| 4604 | + "Currently, worktrees can't be found in ignored directories, even though hit should" |
| 4605 | + ); |
| 4606 | + Ok(()) |
| 4607 | +} |