(marker-re
(mapconcat
(lambda (m) (format "\\(%s\\)" (wildcard-to-regexp m)))
- (append backend-markers project-vc-extra-root-markers)
+ (append backend-markers
+ (project--value-in-dir 'project-vc-extra-root-markers dir))
"\\|"))
(locate-dominating-stop-dir-regexp
(or vc-ignore-dir-regexp locate-dominating-stop-dir-regexp))
project)
(when (and
(eq backend 'Git)
- project-vc-merge-submodules
+ (project--vc-merge-submodules-p root)
(project--submodule-p root))
(let* ((parent (file-name-directory (directory-file-name root))))
(setq root (vc-call-backend 'Git 'root parent))))
(cl-defmethod project-files ((project (head vc)) &optional dirs)
(mapcan
(lambda (dir)
- (let ((ignores project-vc-ignores)
+ (let ((ignores (project--value-in-dir 'project-vc-ignores (nth 2 project)))
(backend (cadr project)))
(when backend
(require (intern (concat "vc-" (downcase (symbol-name backend))))))
(split-string
(apply #'vc-git--run-command-string nil "ls-files" args)
"\0" t)))
- (when project-vc-merge-submodules
+ (when (project--vc-merge-submodules-p default-directory)
;; Unfortunately, 'ls-files --recurse-submodules' conflicts with '-o'.
(let* ((submodules (project--git-submodules))
(sub-files
(lambda (s) (concat default-directory s))
(split-string (buffer-string) "\0" t)))))))
+(defun project--vc-merge-submodules-p (dir)
+ (project--value-in-dir
+ 'project-vc-merge-submodules
+ dir))
+
(defun project--git-submodules ()
;; 'git submodule foreach' is much slower.
(condition-case nil
(condition-case nil
(vc-call-backend backend 'ignore-completion-table root)
(vc-not-supported () nil)))))
- project-vc-ignores
+ (project--value-in-dir 'project-vc-ignores root)
(mapcar
(lambda (dir)
(concat dir "/"))
;; Sidestep the issue of expanded/abbreviated file names here.
(cl-set-difference files dirs :test #'file-in-directory-p))
+(defun project--value-in-dir (var dir)
+ (with-temp-buffer
+ (setq default-directory dir)
+ (let ((enable-local-variables :all))
+ (hack-dir-local-variables-non-file-buffer))
+ (symbol-value var)))
+
(cl-defmethod project-buffers ((project (head vc)))
(let* ((root (expand-file-name (file-name-as-directory (project-root project))))
- (modules (unless (or project-vc-merge-submodules
+ (modules (unless (or (project--vc-merge-submodules-p root)
(project--submodule-p root))
(mapcar
(lambda (m) (format "%s%s/" root m))
(should-not (null project))
(should (string-match-p "/test/lisp/\\'" (project-root project)))))
+(ert-deftest project-vc-supports-project-in-different-dir ()
+ "Check that it picks up dir-locals settings from somewhere else."
+ (skip-unless (eq (vc-responsible-backend default-directory) 'Git))
+ (let* ((dir (ert-resource-directory))
+ (_ (vc-file-clearprops dir))
+ (project-vc-extra-root-markers '(".dir-locals.el"))
+ (project (project-current nil dir)))
+ (should-not (null project))
+ (should (string-match-p "/test/lisp/progmodes/project-resources/\\'" (project-root project)))
+ (should (member "etc" (project-ignores project dir)))
+ (should (equal '(".dir-locals.el" "foo")
+ (mapcar #'file-name-nondirectory (project-files project))))))
+
;;; project-tests.el ends here