Skip to content

Commit ac37c2c

Browse files
committed
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
1 parent 3c287cd commit ac37c2c

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Bugs fixed
1010

1111
* [#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).
12+
* [#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`.
1213

1314
### Changes
1415

projectile.el

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,11 @@ Only text sent to standard output is taken into account."
16611661
(with-temp-buffer
16621662
(shell-command command t "*projectile-files-errors*")
16631663
(let ((shell-output (buffer-substring (point-min) (point-max))))
1664-
(split-string (string-trim shell-output) "\0" t))))))
1664+
(mapcar (lambda (f)
1665+
(if (string-prefix-p "./" f)
1666+
(substring f 2)
1667+
f))
1668+
(split-string (string-trim shell-output) "\0" t)))))))
16651669

16661670
(defun projectile-adjust-files (project vcs files)
16671671
"First remove ignored files from FILES, then add back unignored files."

test/projectile-test.el

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,11 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
546546
(expect (projectile-files-via-ext-command "" "echo filename") :to-equal '("filename")))
547547

548548
(it "supports magic file handlers"
549-
(expect (projectile-files-via-ext-command "#magic#" "echo filename") :to-equal '("magic"))))
549+
(expect (projectile-files-via-ext-command "#magic#" "echo filename") :to-equal '("magic")))
550+
551+
(it "strips ./ prefix from results"
552+
(expect (projectile-files-via-ext-command "" "printf './foo\\0./bar/baz\\0quux'")
553+
:to-equal '("foo" "bar/baz" "quux"))))
550554

551555
(describe "projectile-mode"
552556
(before-each

0 commit comments

Comments
 (0)