From 896248dea3725d3d3c63613816728930d8b48659 Mon Sep 17 00:00:00 2001 From: Paul Nameless Date: Sun, 13 Apr 2025 17:51:55 +0200 Subject: [PATCH] Add test for gitignore with .git/info/exclude --- crates/worktree/src/worktree_tests.rs | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/crates/worktree/src/worktree_tests.rs b/crates/worktree/src/worktree_tests.rs index 45ffc22892..a7eaa4ec43 100644 --- a/crates/worktree/src/worktree_tests.rs +++ b/crates/worktree/src/worktree_tests.rs @@ -1984,6 +1984,58 @@ fn test_unrelativize() { ); } +#[gpui::test] +async fn test_gitignore_with_git_info_exclude(cx: &mut TestAppContext) { + init_test(cx); + + // Test that .git/info/exclude entries are properly recognized + let fs = FakeFs::new(cx.background_executor.clone()); + fs.insert_tree( + "/root", + json!({ + ".git": { + "info": { + "exclude": "excluded_file.txt\n", + }, + }, + ".gitignore": "local_ignored.txt\n", + "normal_file.txt": "normal file content", + "local_ignored.txt": "locally ignored content", + "excluded_file.txt": "excluded content", + }), + ) + .await; + + let tree = Worktree::local( + Path::new("/root"), + true, + fs.clone(), + Default::default(), + &mut cx.to_async(), + ) + .await + .unwrap(); + + cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete()) + .await; + + tree.read_with(cx, |tree, _| { + check_worktree_entries( + tree, + &[], + &[ + "local_ignored.txt", // Ignored by .gitignore + "excluded_file.txt", // Ignored by .git/info/exclude + ], + &[ + "normal_file.txt", // Not ignored + ".gitignore", // Not ignored + ], + &[], + ) + }); +} + #[track_caller] fn check_worktree_entries( tree: &Worktree,