History

Add a test to see what happens if worktrees are hidden in ignored directories (#1469)

Sebastian Thiel committed 2 years ago

Commit 2bacc451 parent 8b09cf22 files · +63 −1Browse files

Unified · Split

2 files
  1. gix-dir/tests/fixtures/many.sh +8 −1
  2. gix-dir/tests/walk/mod.rs +55 −0
gix-dir/tests/fixtures/many.sh+8−1
@@ -443,4 +443,11 @@ git clone dir-with-tracked-file in-repo-worktree · 442 unmodified lines
443443 (cd in-repo-worktree
444444 git worktree add worktree
445445 git worktree add -b other-worktree dir/worktree
446−)
446+)
447+
448+git clone dir-with-tracked-file in-repo-hidden-worktree
449+(cd in-repo-hidden-worktree
450+ echo '/hidden/' > .gitignore
451+ mkdir -p hidden/sbudir
452+ git worktree add -b worktree-branch hidden/subdir/worktree
453+)
gix-dir/tests/walk/mod.rs+55−0
@@ -4550,3 +4550,58 @@ fn in_repo_worktree() -> crate::Result { · 4549 unmodified lines
45504550 );
45514551 Ok(())
45524552 }
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+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t