:type '(repeat string)
:safe 'listp)
-(defcustom project-vc-project-files-backends '(Bzr Git Hg SVN)
+(defcustom project-vc-project-files-backends '(Git Hg)
"List of vc backends which should be used by `project-files'.
For projects using a backend in this list, `project-files' will
(let ((backend (ignore-errors (vc-responsible-backend dir))))
(if (and backend
(memq backend project-vc-project-files-backends))
- (vc-call-backend backend 'list-files dir)
+ (vc-call-backend backend 'list-files
+ dir t project-vc-ignores)
(cl-call-next-method))))
(or dirs (project-roots project))))
(declare-function cl-remove-if "cl-seq")
-(defun vc-git-list-files (&optional dir)
- (let ((default-directory (or dir default-directory)))
+(defun vc-git-list-files (&optional dir
+ include-unregistered
+ extra-ignores)
+ (let ((default-directory (or dir default-directory))
+ (args '("-z")))
+ (when include-unregistered
+ (setq args (append args '("-c" "-o" "--exclude-standard"))))
+ (when extra-ignores
+ (setq args (append args
+ (cons "--"
+ (mapcar
+ (lambda (i)
+ (format ":!:%s" i))
+ extra-ignores)))))
(mapcar
#'expand-file-name
- (cl-remove-if #'string-empty-p
- (split-string
- (vc-git--run-command-string nil "ls-files" "-z")
- "\0")))))
+ (cl-remove-if
+ #'string-empty-p
+ (split-string
+ (apply #'vc-git--run-command-string nil "ls-files" args)
+ "\0")))))
(provide 'vc-git)
(defun vc-hg-root (file)
(vc-find-root file ".hg"))
-(defun vc-hg-list-files (&optional dir)
- (let ((default-directory (or dir default-directory)))
- (mapcar
- #'expand-file-name
- (cl-remove-if #'string-empty-p
- (split-string
- (with-output-to-string
- (with-current-buffer standard-output
- (vc-hg-command t 0 "."
- "files" "--print0")))
- "\0")))))
+(defun vc-hg-list-files (&optional dir
+ include-unregistered
+ extra-ignores)
+ (let ((default-directory (or dir default-directory))
+ args
+ files)
+ (when include-unregistered
+ (setq args (nconc args '("--all"))))
+ (when extra-ignores
+ (setq args (nconc args
+ (mapcan
+ (lambda (i)
+ (list "--exclude" i))
+ (copy-list extra-ignores)))))
+ (with-temp-buffer
+ (apply #'vc-hg-command t 0 "."
+ "status" args)
+ (goto-char (point-min))
+ (while (re-search-forward "^[?C]\s+\\(.*\\)$" nil t)
+ (setq files (cons (expand-file-name (match-string 1))
+ files))))
+ (nreverse files)))
(provide 'vc-hg)
\f
-(defun vc-default-list-files (_backend &optional dir)
+(defun vc--glob-pattern-to-regex (glob)
+ (replace-regexp-in-string
+ "\\?" "."
+ (replace-regexp-in-string
+ "\\*" ".*"
+ (replace-regexp-in-string "\\." "\\\\." glob))))
+
+(defun vc--any-string-match-p (str regexes)
+ (catch 'match
+ (dolist (regex regexes)
+ (when (string-match-p regex str)
+ (throw 'match t)))))
+
+(defun vc-default-list-files (_backend &optional dir
+ _include-unregistered
+ extra-ignores)
+ ;; FIXME: We collect only tracked files and ignore
+ ;; include-unregistered.
(let* ((default-directory (or dir default-directory))
(inhibit-message t)
files)
- (vc-file-tree-walk default-directory
- (lambda (f)
- (setq files (cons f files))))
+ (vc-file-tree-walk
+ default-directory
+ (lambda (f)
+ (unless (vc--any-string-match-p f extra-ignores)
+ (setq files (cons f files)))))
files))
(provide 'vc)