aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.dev>2026-02-13 12:33:33 +0200
committerBozhidar Batsov <bozhidar@batsov.dev>2026-02-13 12:33:33 +0200
commitac37c2c96b1296b147aed021273efdd20e3b4938 (patch)
tree2a26805e25ec4d103e48e2e294589178746b7111
parent3c287cd1b4a5289e6342361471c11685e3f168ab (diff)
Strip "./" prefix from fd output in projectile-files-via-ext-command
Newer fd versions (8.3.0+) prepend "./" to output. The --strip-cwd-prefix flag was already added to projectile-generic-command and projectile-git-fd-args, but this flag doesn't exist in older fd versions, causing errors. Add post-processing in projectile-files-via-ext-command to strip the "./" prefix from results as a defensive fallback, matching the existing pattern in projectile-files-from-cmd. Fixes #1749
-rw-r--r--CHANGELOG.md1
-rw-r--r--projectile.el6
-rw-r--r--test/projectile-test.el6
3 files changed, 11 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9f0ac7a..2af852c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@
### Bugs fixed
* [#1961](https://github.com/bbatsov/projectile/issues/1961): Prevent directories from matching file-type project root markers (e.g., a `workspace` directory no longer matches the `WORKSPACE` Bazel marker on case-insensitive filesystems).
+* [#1749](https://github.com/bbatsov/projectile/issues/1749): Strip `./` prefix from `fd` output in `projectile-files-via-ext-command`, fixing compatibility with older `fd` versions that don't support `--strip-cwd-prefix`.
### Changes
diff --git a/projectile.el b/projectile.el
index 7f0c581..90e2d48 100644
--- a/projectile.el
+++ b/projectile.el
@@ -1661,7 +1661,11 @@ Only text sent to standard output is taken into account."
(with-temp-buffer
(shell-command command t "*projectile-files-errors*")
(let ((shell-output (buffer-substring (point-min) (point-max))))
- (split-string (string-trim shell-output) "\0" t))))))
+ (mapcar (lambda (f)
+ (if (string-prefix-p "./" f)
+ (substring f 2)
+ f))
+ (split-string (string-trim shell-output) "\0" t)))))))
(defun projectile-adjust-files (project vcs files)
"First remove ignored files from FILES, then add back unignored files."
diff --git a/test/projectile-test.el b/test/projectile-test.el
index 33c50e4..0880d6d 100644
--- a/test/projectile-test.el
+++ b/test/projectile-test.el
@@ -546,7 +546,11 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
(expect (projectile-files-via-ext-command "" "echo filename") :to-equal '("filename")))
(it "supports magic file handlers"
- (expect (projectile-files-via-ext-command "#magic#" "echo filename") :to-equal '("magic"))))
+ (expect (projectile-files-via-ext-command "#magic#" "echo filename") :to-equal '("magic")))
+
+ (it "strips ./ prefix from results"
+ (expect (projectile-files-via-ext-command "" "printf './foo\\0./bar/baz\\0quux'")
+ :to-equal '("foo" "bar/baz" "quux"))))
(describe "projectile-mode"
(before-each