aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWolfgang Scherer2019-09-15 15:03:33 +0200
committerLars Ingebrigtsen2019-09-15 15:03:33 +0200
commitf144c87f92bb9930c9fdafc39bbcdfbb7c7bb983 (patch)
tree9616264cc41f28cc58d951e2647d708f7b165403
parentc99c9ec28c440d42a66b737651b1095151d85957 (diff)
downloademacs-f144c87f92bb9930c9fdafc39bbcdfbb7c7bb983.tar.gz
emacs-f144c87f92bb9930c9fdafc39bbcdfbb7c7bb983.zip
Fix vc-default-ignore
* lisp/vc/vc.el: (vc-default-ignore) Treat FILE parameter as relative to DIRECTORY parameter. Construct a file-path relative to directory of ignore file. When removing, use properly anchored regexp. Remove entire line, not just the match (bug#37217).
-rw-r--r--lisp/vc/vc.el13
1 files changed, 9 insertions, 4 deletions
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 4cac1539289..c982b0220e3 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -1417,17 +1417,22 @@ remove from the list of ignored files."
1417 1417
1418(defun vc-default-ignore (backend file &optional directory remove) 1418(defun vc-default-ignore (backend file &optional directory remove)
1419 "Ignore FILE under the VCS of DIRECTORY (default is `default-directory'). 1419 "Ignore FILE under the VCS of DIRECTORY (default is `default-directory').
1420FILE is a file wildcard, relative to the root directory of DIRECTORY. 1420FILE is a wildcard specification, either relative to
1421DIRECTORY or absolute.
1421When called from Lisp code, if DIRECTORY is non-nil, the 1422When called from Lisp code, if DIRECTORY is non-nil, the
1422repository to use will be deduced by DIRECTORY; if REMOVE is 1423repository to use will be deduced by DIRECTORY; if REMOVE is
1423non-nil, remove FILE from ignored files. 1424non-nil, remove FILE from ignored files.
1424Argument BACKEND is the backend you are using." 1425Argument BACKEND is the backend you are using."
1425 (let ((ignore 1426 (let ((ignore
1426 (vc-call-backend backend 'find-ignore-file (or directory default-directory))) 1427 (vc-call-backend backend 'find-ignore-file (or directory default-directory)))
1427 (pattern (file-relative-name 1428 file-path root-dir pattern)
1428 (expand-file-name file) (file-name-directory file)))) 1429 (setq file-path (expand-file-name file directory))
1430 (setq root-dir (file-name-directory ignore))
1431 (when (not (string= (substring file-path 0 (length root-dir)) root-dir))
1432 (error "Ignore spec %s is not below project root %s" file-path root-dir))
1433 (setq pattern (substring file-path (length root-dir)))
1429 (if remove 1434 (if remove
1430 (vc--remove-regexp pattern ignore) 1435 (vc--remove-regexp (concat "^" (regexp-quote pattern ) "\\(\n\\|$\\)") ignore)
1431 (vc--add-line pattern ignore)))) 1436 (vc--add-line pattern ignore))))
1432 1437
1433(defun vc-default-ignore-completion-table (backend file) 1438(defun vc-default-ignore-completion-table (backend file)