Improve .gitignore and project-vc-ignores handling
* lisp/progmodes/project.el (project-ignores): Convert .gitignore entries more faithfully. (project--vc-list-files): Convert "our" ignore entries to "proper" globs, which is what Git pathspec requires.
This commit is contained in:
parent
e19c5d4348
commit
5f45fc7ee2
1 changed files with 41 additions and 10 deletions
|
@ -322,7 +322,7 @@ to find the list of ignores for each directory."
|
|||
:group 'project)
|
||||
|
||||
(defcustom project-vc-ignores nil
|
||||
"List of patterns to include in `project-ignores'."
|
||||
"List of patterns to add to `project-ignores'."
|
||||
:type '(repeat string)
|
||||
:safe #'listp)
|
||||
|
||||
|
@ -468,9 +468,26 @@ backend implementation of `project-external-roots'.")
|
|||
(cons "--"
|
||||
(mapcar
|
||||
(lambda (i)
|
||||
(if (string-match "\\./" i)
|
||||
(format ":!/:%s" (substring i 2))
|
||||
(format ":!:%s" i)))
|
||||
(format
|
||||
":(exclude,glob,top)%s"
|
||||
(if (string-match "\\*\\*" i)
|
||||
;; Looks like pathspec glob
|
||||
;; format already.
|
||||
i
|
||||
(if (string-match "\\./" i)
|
||||
;; ./abc -> abc
|
||||
(setq i (substring i 2))
|
||||
;; abc -> **/abc
|
||||
(setq i (concat "**/" i))
|
||||
;; FIXME: '**/abc' should also
|
||||
;; match a directory with that
|
||||
;; name, but doesn't (git 2.25.1).
|
||||
;; Maybe we should replace
|
||||
;; such entries with two.
|
||||
(if (string-match "/\\'" i)
|
||||
;; abc/ -> abc/**
|
||||
(setq i (concat i "**"))))
|
||||
i)))
|
||||
extra-ignores)))))
|
||||
(setq files
|
||||
(mapcar
|
||||
|
@ -535,12 +552,26 @@ backend implementation of `project-external-roots'.")
|
|||
(append
|
||||
(when (file-equal-p dir root)
|
||||
(setq backend (vc-responsible-backend root))
|
||||
(mapcar
|
||||
(lambda (entry)
|
||||
(if (string-match "\\`/" entry)
|
||||
(replace-match "./" t t entry)
|
||||
entry))
|
||||
(vc-call-backend backend 'ignore-completion-table root)))
|
||||
(delq
|
||||
nil
|
||||
(mapcar
|
||||
(lambda (entry)
|
||||
(cond
|
||||
((eq ?! (aref entry 0))
|
||||
;; No support for whitelisting (yet).
|
||||
nil)
|
||||
((string-match "\\(/\\)[^/]" entry)
|
||||
;; FIXME: This seems to be Git-specific.
|
||||
;; And / in the entry (start or even the middle) means
|
||||
;; the pattern is "rooted". Or actually it is then
|
||||
;; relative to its respective .gitignore (of which there
|
||||
;; could be several), but we only support .gitignore at
|
||||
;; the root.
|
||||
(if (= (match-beginning 0) 0)
|
||||
(replace-match "./" t t entry 1)
|
||||
(concat "./" entry)))
|
||||
(t entry)))
|
||||
(vc-call-backend backend 'ignore-completion-table root))))
|
||||
(project--value-in-dir 'project-vc-ignores root)
|
||||
(mapcar
|
||||
(lambda (dir)
|
||||
|
|
Loading…
Add table
Reference in a new issue