unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#37215: [PATCH] vc-cvs-ignore writes absolute filenames and duplicate strings
@ 2019-08-28 22:32 Wolfgang Scherer
  2019-09-15 13:12 ` Lars Ingebrigtsen
  2020-02-28 16:07 ` Mattias Engdegård
  0 siblings, 2 replies; 26+ messages in thread
From: Wolfgang Scherer @ 2019-08-28 22:32 UTC (permalink / raw)
  To: 37215

[-- Attachment #1: Type: text/plain, Size: 237 bytes --]

When called with an absolute filename (which is the default
case), `vc-cvs-ignore' writes the entire path into the .cvsignore
file.

`vc-cvs-ignore' also writes duplicate strings into .cvsignore.

The attached patch fixes these errors.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Do-not-write-absolute-filenames-and-duplicate-string.patch --]
[-- Type: text/x-patch; name="0001-Do-not-write-absolute-filenames-and-duplicate-string.patch", Size: 2257 bytes --]

From 2b7b90b94a426754a99c965bf708bf5854008b76 Mon Sep 17 00:00:00 2001
From: Wolfgang Scherer <wolfgang.scherer@gmx.de>
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


^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2020-02-28 16:24 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-28 22:32 bug#37215: [PATCH] vc-cvs-ignore writes absolute filenames and duplicate strings Wolfgang Scherer
2019-09-15 13:12 ` Lars Ingebrigtsen
2020-01-05  3:59   ` Wolfgang Scherer
2020-01-22 12:43     ` Lars Ingebrigtsen
2020-01-30 19:44       ` Wolfgang Scherer
2020-02-13 19:36         ` Eli Zaretskii
2020-02-14  1:24           ` Wolfgang Scherer
2020-02-14  8:33             ` Eli Zaretskii
2020-02-15  1:42               ` Wolfgang Scherer
2020-02-15  7:44                 ` Eli Zaretskii
2020-02-15 12:55                   ` Dmitry Gutov
2020-02-19 23:02                     ` Wolfgang Scherer
2020-02-16  0:20                   ` Wolfgang Scherer
2020-02-19 23:06                   ` Wolfgang Scherer
2020-02-21  9:31                     ` Eli Zaretskii
2020-02-21 10:16                       ` Dmitry Gutov
2020-02-21 20:44                         ` Wolfgang Scherer
2020-02-21 21:30                           ` Dmitry Gutov
2020-02-21 22:23                             ` Wolfgang Scherer
2020-02-21 20:32                       ` Wolfgang Scherer
2020-02-22  8:59                         ` Eli Zaretskii
2020-02-14  2:50           ` Wolfgang Scherer
2020-02-14  8:39             ` Eli Zaretskii
2020-02-14  9:24               ` Eli Zaretskii
2020-02-28 16:07 ` Mattias Engdegård
2020-02-28 16:24   ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).