Skip to content

Commit d03350e

Browse files
ByronLuaKT
authored andcommitted
Add a test to see what happens if worktrees are hidden in ignored directories (GitoxideLabs#1469)
1 parent 143a6cd commit d03350e

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

gix-dir/tests/fixtures/many.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,4 +443,11 @@ git clone dir-with-tracked-file in-repo-worktree
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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4550,3 +4550,58 @@ fn in_repo_worktree() -> crate::Result {
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+
}

0 commit comments

Comments
 (0)