aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2025-12-14 02:25:45 +0200
committerDmitry Gutov2025-12-14 02:26:36 +0200
commit48a4444977555321d99fa00892fbebfe6752f84f (patch)
tree7adc89e14add7b4e7879fb38c98a04e8ee82004e
parent223dffabd8f601b70452998c1cf4c845c4ecbf15 (diff)
downloademacs-48a4444977555321d99fa00892fbebfe6752f84f.tar.gz
emacs-48a4444977555321d99fa00892fbebfe6752f84f.zip
Relax the condition on the values of DIRS in project-files
* lisp/progmodes/project.el (project-files): Use 'file-in-directory-p' to dispatch to 'project--vc-list-files' when listing subdirectory files too (bug#79809).
-rw-r--r--lisp/progmodes/project.el6
-rw-r--r--test/lisp/progmodes/project-tests.el14
2 files changed, 17 insertions, 3 deletions
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 8a128df0d16..d2bac95aaea 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -369,8 +369,8 @@ the user.")
369 369
370(cl-defgeneric project-files (project &optional dirs) 370(cl-defgeneric project-files (project &optional dirs)
371 "Return a list of files in directories DIRS in PROJECT. 371 "Return a list of files in directories DIRS in PROJECT.
372DIRS is a list of absolute directories; it should be some 372DIRS is a list of absolute directories; the values can be some of the
373subset of the project root and external roots. 373project roots or external roots or subdirectories of those.
374 374
375The default implementation uses `find-program'. PROJECT is used 375The default implementation uses `find-program'. PROJECT is used
376to find the list of ignores for each directory." 376to find the list of ignores for each directory."
@@ -679,7 +679,7 @@ See `project-vc-extra-root-markers' for the marker value format.")
679 (backend (cadr project))) 679 (backend (cadr project)))
680 (when backend 680 (when backend
681 (require (intern (concat "vc-" (downcase (symbol-name backend)))))) 681 (require (intern (concat "vc-" (downcase (symbol-name backend))))))
682 (if (and (file-equal-p dir (nth 2 project)) 682 (if (and (file-in-directory-p dir (nth 2 project))
683 (cond 683 (cond
684 ((eq backend 'Hg)) 684 ((eq backend 'Hg))
685 ((and (eq backend 'Git) 685 ((and (eq backend 'Git)
diff --git a/test/lisp/progmodes/project-tests.el b/test/lisp/progmodes/project-tests.el
index cbc0bd1e8b9..947ad94a385 100644
--- a/test/lisp/progmodes/project-tests.el
+++ b/test/lisp/progmodes/project-tests.el
@@ -157,6 +157,20 @@ When `project-ignores' includes a name matching project dir."
157 (should (equal '(".dir-locals.el" "foo") 157 (should (equal '(".dir-locals.el" "foo")
158 (mapcar #'file-name-nondirectory (project-files project)))))) 158 (mapcar #'file-name-nondirectory (project-files project))))))
159 159
160(ert-deftest project-vc-supports-files-in-subdirectory ()
161 "Check that it lists only files from subdirectory."
162 (skip-unless (eq (vc-responsible-backend default-directory) 'Git))
163 (let* ((dir (ert-resource-directory))
164 (_ (vc-file-clearprops dir))
165 (project-vc-extra-root-markers '("project-tests.el"))
166 (project (project-current nil dir)))
167 (should-not (null project))
168 (should (string-match-p "/test/lisp/progmodes/\\'" (project-root project)))
169 (should (equal '(".dir-locals.el" "etc" "foo")
170 (mapcar #'file-name-nondirectory
171 (project-files project
172 (list dir)))))))
173
160(ert-deftest project-vc-nonexistent-directory-no-error () 174(ert-deftest project-vc-nonexistent-directory-no-error ()
161 "Check that is doesn't error out when the current dir does not exist." 175 "Check that is doesn't error out when the current dir does not exist."
162 (skip-unless (eq (vc-responsible-backend default-directory) 'Git)) 176 (skip-unless (eq (vc-responsible-backend default-directory) 'Git))