aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.dev>2026-02-13 14:21:04 +0200
committerBozhidar Batsov <bozhidar@batsov.dev>2026-02-13 14:21:04 +0200
commit4dbcda27d6870990421e217c8379b14037d9239f (patch)
treec9b767b3d7d5c2f2ea4c7969f77507dd0af17ae7 /test
parent5560f083b69d40eb1a0e359fdd4ba9712f8a1bd8 (diff)
Filter deleted-but-unstaged files from git ls-files output (#1897)
When fd is unavailable or disabled, `git ls-files -zco --exclude-standard` returns files still tracked in the index even if deleted from disk. This causes projectile-dir-files-alien to list ghost files. Fix by running `git ls-files -zd` and removing those entries from the result.
Diffstat (limited to 'test')
-rw-r--r--test/projectile-test.el24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/projectile-test.el b/test/projectile-test.el
index c658dcd..25c96f1 100644
--- a/test/projectile-test.el
+++ b/test/projectile-test.el
@@ -532,6 +532,30 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
(let ((projectile-indexing-method 'hybrid))
(expect (projectile-dir-files "/my/root/") :to-equal '("a/b/c" "a/d/e")))))
+(describe "projectile-dir-files-alien"
+ (it "excludes deleted-but-unstaged files when not using fd"
+ (projectile-test-with-sandbox
+ (projectile-test-with-files
+ ("project/"
+ "project/.git/"
+ "project/existing.txt")
+ (let ((default-directory (file-truename (expand-file-name "project/")))
+ (projectile-git-use-fd nil)
+ (projectile-fd-executable nil)
+ (projectile-indexing-method 'alien))
+ ;; Initialize a real git repo, commit a file, then delete it without staging
+ (call-process "git" nil nil nil "init")
+ (call-process "git" nil nil nil "config" "user.email" "test@test.com")
+ (call-process "git" nil nil nil "config" "user.name" "Test")
+ (call-process "git" nil nil nil "add" "existing.txt")
+ (write-region "content" nil "deleted.txt")
+ (call-process "git" nil nil nil "add" "deleted.txt")
+ (call-process "git" nil nil nil "commit" "-m" "init")
+ (delete-file "deleted.txt")
+ (let ((files (projectile-dir-files-alien default-directory)))
+ (expect files :to-contain "existing.txt")
+ (expect files :not :to-contain "deleted.txt")))))))
+
(describe "projectile-index-directory"
(it "skips unreadable directories"
(unless (eq system-type 'windows-nt)