summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorWolfgang Scherer <wolfgang.scherer@gmx.de>2019-09-15 15:03:33 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2019-09-15 15:03:33 +0200
commitf144c87f92bb9930c9fdafc39bbcdfbb7c7bb983 (patch)
tree9616264cc41f28cc58d951e2647d708f7b165403 /lisp
parentc99c9ec28c440d42a66b737651b1095151d85957 (diff)
downloademacs-f144c87f92bb9930c9fdafc39bbcdfbb7c7bb983.tar.gz
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).
Diffstat (limited to 'lisp')
-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."
(defun vc-default-ignore (backend file &optional directory remove)
"Ignore FILE under the VCS of DIRECTORY (default is `default-directory').
-FILE is a file wildcard, relative to the root directory of DIRECTORY.
+FILE is a wildcard specification, either relative to
+DIRECTORY or absolute.
When called from Lisp code, if DIRECTORY is non-nil, the
repository to use will be deduced by DIRECTORY; if REMOVE is
non-nil, remove FILE from ignored files.
Argument BACKEND is the backend you are using."
(let ((ignore
(vc-call-backend backend 'find-ignore-file (or directory default-directory)))
- (pattern (file-relative-name
- (expand-file-name file) (file-name-directory file))))
+ file-path root-dir pattern)
+ (setq file-path (expand-file-name file directory))
+ (setq root-dir (file-name-directory ignore))
+ (when (not (string= (substring file-path 0 (length root-dir)) root-dir))
+ (error "Ignore spec %s is not below project root %s" file-path root-dir))
+ (setq pattern (substring file-path (length root-dir)))
(if remove
- (vc--remove-regexp pattern ignore)
+ (vc--remove-regexp (concat "^" (regexp-quote pattern ) "\\(\n\\|$\\)") ignore)
(vc--add-line pattern ignore))))
(defun vc-default-ignore-completion-table (backend file)