branch: elpa/projectile
commit 6f637948596bc7aff9fb0ac1cc88d910512bb488
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>
Don't execute empty string as shell command for non-git sub-projects
projectile-get-sub-projects-command returned "" for non-git VCSes,
which passed the stringp guard in projectile-files-via-ext-command
and spawned a useless shell process. Return nil instead, and also
make the guard defensive against empty strings to match the
docstring's contract.
---
projectile.el | 4 ++--
test/projectile-test.el | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/projectile.el b/projectile.el
index cc99ea4225..6c833af4b7 100644
--- a/projectile.el
+++ b/projectile.el
@@ -1617,7 +1617,7 @@ Currently that's supported just for Git (sub-projects
being Git
sub-modules there)."
(pcase vcs
('git projectile-git-submodule-command)
- (_ "")))
+ (_ nil)))
(defun projectile-get-ext-ignored-command (vcs)
"Determine which external command to invoke based on the project's VCS."
@@ -1703,7 +1703,7 @@ If `command' is nil or an empty string, return nil.
This allows commands to be disabled.
Only text sent to standard output is taken into account."
- (when (stringp command)
+ (when (and (stringp command) (not (string-empty-p command)))
(let ((default-directory root))
(with-temp-buffer
(shell-command command t "*projectile-files-errors*")
diff --git a/test/projectile-test.el b/test/projectile-test.el
index e26ed6644e..39f577de08 100644
--- a/test/projectile-test.el
+++ b/test/projectile-test.el
@@ -638,8 +638,8 @@ Just delegates OPERATION and ARGS for all operations except
for`shell-command`'.
(describe "projectile-get-sub-projects-command"
(it "gets sub projects command for git"
(expect (string-prefix-p "git" (projectile-get-sub-projects-command 'git))
:to-be-truthy))
- (it "returns empty when vcs is not supported"
- (expect (string-empty-p (projectile-get-sub-projects-command 'none))
:to-be-truthy)))
+ (it "returns nil when vcs is not supported"
+ (expect (projectile-get-sub-projects-command 'none) :to-be nil)))
(describe "projectile-files-via-ext-command"
(it "returns nil when command is nil or empty or fails"