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.") (cl-defgeneric project-files (project &optional dirs) "Return a list of files in directories DIRS in PROJECT. -DIRS is a list of absolute directories; it should be some -subset of the project root and external roots. +DIRS is a list of absolute directories; the values can be some of the +project roots or external roots or subdirectories of those. The default implementation uses `find-program'. PROJECT is used to find the list of ignores for each directory." @@ -679,7 +679,7 @@ See `project-vc-extra-root-markers' for the marker value format.") (backend (cadr project))) (when backend (require (intern (concat "vc-" (downcase (symbol-name backend)))))) - (if (and (file-equal-p dir (nth 2 project)) + (if (and (file-in-directory-p dir (nth 2 project)) (cond ((eq backend 'Hg)) ((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." (should (equal '(".dir-locals.el" "foo") (mapcar #'file-name-nondirectory (project-files project)))))) +(ert-deftest project-vc-supports-files-in-subdirectory () + "Check that it lists only files from subdirectory." + (skip-unless (eq (vc-responsible-backend default-directory) 'Git)) + (let* ((dir (ert-resource-directory)) + (_ (vc-file-clearprops dir)) + (project-vc-extra-root-markers '("project-tests.el")) + (project (project-current nil dir))) + (should-not (null project)) + (should (string-match-p "/test/lisp/progmodes/\\'" (project-root project))) + (should (equal '(".dir-locals.el" "etc" "foo") + (mapcar #'file-name-nondirectory + (project-files project + (list dir))))))) + (ert-deftest project-vc-nonexistent-directory-no-error () "Check that is doesn't error out when the current dir does not exist." (skip-unless (eq (vc-responsible-backend default-directory) 'Git))