From 2b7b90b94a426754a99c965bf708bf5854008b76 Mon Sep 17 00:00:00 2001 From: Wolfgang Scherer Date: Thu, 29 Aug 2019 00:29:31 +0200 Subject: [PATCH] Do not write absolute filenames and duplicate strings into .cvsignore * lisp/vc/vc-cvs.el: (vc-cvs-ignore) Expand filename correctly and pass on basename only. (vc-cvs-append-to-ignore) Do not write duplicate strings to .cvsignore. --- lisp/vc/vc-cvs.el | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el index d84700f..1d0387b 100644 --- a/lisp/vc/vc-cvs.el +++ b/lisp/vc/vc-cvs.el @@ -1220,9 +1220,11 @@ is non-nil." "Return the administrative directory of FILE." (vc-find-root file "CVS")) -(defun vc-cvs-ignore (file &optional _directory _remove) - "Ignore FILE under CVS." - (vc-cvs-append-to-ignore (file-name-directory file) file)) +(defun vc-cvs-ignore (file &optional directory _remove) + "Ignore FILE under CVS. +FILE is either absolute or relative to DIRECTORY." + (setq file (directory-file-name (expand-file-name file directory))) + (vc-cvs-append-to-ignore (file-name-directory file) (file-name-nondirectory file))) (defun vc-cvs-append-to-ignore (dir str &optional old-dir) "In DIR, add STR to the .cvsignore file. @@ -1236,13 +1238,16 @@ to hear about anymore." (not (vc-editable-p buffer-file-name)))) ;; CVSREAD=on special case (vc-checkout buffer-file-name t)) - (goto-char (point-max)) - (unless (bolp) (insert "\n")) - (insert str (if old-dir "/\n" "\n")) - ;; FIXME this is a pcvs variable. - (if (bound-and-true-p cvs-sort-ignore-file) - (sort-lines nil (point-min) (point-max))) - (save-buffer))) + (goto-char (point-min)) + (save-match-data + (unless (re-search-forward (concat "^" (regexp-quote str) "$") nil t) + (goto-char (point-max)) + (unless (bolp) (insert "\n")) + (insert str (if old-dir "/\n" "\n")) + ;; FIXME this is a pcvs variable. + (if (bound-and-true-p cvs-sort-ignore-file) + (sort-lines nil (point-min) (point-max))) + (save-buffer))))) (provide 'vc-cvs) -- 2.7.4