From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Wolfgang Scherer Newsgroups: gmane.emacs.bugs Subject: bug#37215: [PATCH] vc-cvs-ignore writes absolute filenames and duplicate strings Date: Thu, 20 Feb 2020 00:06:11 +0100 Message-ID: <6aaa5f28-13da-e998-a2b5-3a52a97b9dde@gmx.de> References: <87imptwvoa.fsf@gnus.org> <87k15jy84c.fsf@gnus.org> <543853fe-6cc2-9d1e-093e-e90e0886eed2@gmx.de> <831rqyqnya.fsf@gnu.org> <83pnehpnyr.fsf@gnu.org> <31d20c7f-aec2-8b93-0643-f0fa611eb816@gmx.de> <83imk8nvl4.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------F124554BCE15942068D249C9" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="50261"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 Cc: 37215@debbugs.gnu.org, larsi@gnus.org, dgutov@yandex.ru To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 20 00:07:36 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j4YRK-000Cth-Pf for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 20 Feb 2020 00:07:34 +0100 Original-Received: from localhost ([::1]:33682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4YRJ-0007dX-Ku for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 Feb 2020 18:07:33 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42505) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4YQp-0007dJ-N7 for bug-gnu-emacs@gnu.org; Wed, 19 Feb 2020 18:07:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4YQo-00057M-DJ for bug-gnu-emacs@gnu.org; Wed, 19 Feb 2020 18:07:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37610) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j4YQn-00056b-Ps for bug-gnu-emacs@gnu.org; Wed, 19 Feb 2020 18:07:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j4YQn-0000Xo-MB for bug-gnu-emacs@gnu.org; Wed, 19 Feb 2020 18:07:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Wolfgang Scherer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 19 Feb 2020 23:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37215 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 37215-submit@debbugs.gnu.org id=B37215.15821535802041 (code B ref 37215); Wed, 19 Feb 2020 23:07:01 +0000 Original-Received: (at 37215) by debbugs.gnu.org; 19 Feb 2020 23:06:20 +0000 Original-Received: from localhost ([127.0.0.1]:43583 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j4YQ8-0000Wr-AK for submit@debbugs.gnu.org; Wed, 19 Feb 2020 18:06:20 -0500 Original-Received: from mout.gmx.net ([212.227.15.15]:53879) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j4YQ6-0000We-6J for 37215@debbugs.gnu.org; Wed, 19 Feb 2020 18:06:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1582153572; bh=i3FwbI3liPXQntJKEHLzRY3XQl8wKl78hX4wFK0rICY=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=WcOjaBsum0Hfh8PEunQzbKksj50/PY2RilYUWZnt2/9JgT+5Nxh2tBw/BQP4k6gV3 VQURL9tFzs/dr0MYrogrobPq1HtSaofWIaPQj1xiaXO7dEcZp7qa7EHCqrPfuLQuXX d5Yz3G4J2ABxa/MvGoC9MyhH4/Y9JCzDC0l4o2jg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from sheckley.simul.de ([87.160.210.52]) by mail.gmx.com (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MtOGa-1jJJsr3fLi-00upR9; Thu, 20 Feb 2020 00:06:11 +0100 Original-Received: from [127.0.0.1] (sheckley.simul.de [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by sheckley.simul.de (Postfix) with ESMTPSA id 3543A19431E6; Thu, 20 Feb 2020 00:06:11 +0100 (CET) Openpgp: preference=signencrypt Autocrypt: addr=Wolfgang.Scherer@gmx.de; prefer-encrypt=mutual; keydata= xsDiBEb46IgRBACMHOAb1KNo1Ylk+ebri+4R+bG4tyKlqBlrpv8D9/ZwRdXSGt+0DyCHoaAd 7KW7noHapLe87DunABOjKG4nqTGv+dRiWuUBlp3I4aYRFDVa3Da+XnIYkMHKqhK59VEHQCdp Km42nuLS7TS+n99at9YwzTG6VBdOlBKTlRFngOjVLwCg1RGXJ6X3EjS1FKCQeXziURVpWlkD /2zY6Ayhxi62TS84VjikXrrmjXykAAaAmMVEyKKYb9L5pGlqiZz9g/K9xw1EUoZTYuaufquD v4rAGR58K/3V4CYfJLEeshMWiaXHvMmlxMznlG16/um4MvmR8B3r+cx0nOPK1JBdD2qrkNnF Mw8FB+zouLFB4Gt2IUC5IlOmZ8OQA/4qdU53CItzWsCr9Nux4L0qUlRweSmCnV8xGQ2wP5XI MawIQxxREvSrsYDG8cNnYETMg4iQFfIktwAoxCJvuFAwIB6ZxHGF4FcEZm64CXc2u7CmFLqt rVhXhIfMz9oEYC+HhGczGamn9ofbGTFd2hJEtPcQgWNR4f7+aKknmi2+OM0fV29sZmdhbmcg U2NoZXJlciA8d3NAc3ctYW10LndzPsJhBBMRAgAhBQJYmz3YAhsjBQsJCAcCBhUICQoLAgQW AgMBAh4BAheAAAoJEIUCr3Gr112VZZoAoLTBSTp1qGuNhLdXY04iaWCMYmHCAJ4kHPtQ6nTw kEq9qCHgVgXDaY7wjs7ATQRG+OiIEAQAhi0wjcxvA4tychg2NQuwBIf9LX/46l+74+QbewCn a4a+mw/9s5KY In-Reply-To: <83imk8nvl4.fsf@gnu.org> Content-Language: de-DE X-Provags-ID: V03:K1:UNho++Azyg2vbmmeTgpi5gN9pWIrrB3mIoBAjI0emD1DLplRF/t KIwNIyk1IGqXsuSDYwTmpyIi/BLCQIezlYgU6w5VzdY3iO77qh6OFdisgWvi63LHkzeBtGZ T/rFtUlLwbY/Ye7spz4eDsjaEfHEYDJ6IvNelxLJLftE2WemRluMU/bwOK3O1PynwCR0nhF C+Rb3eU6AhlgfTgTSY3Pg== X-UI-Out-Filterresults: notjunk:1;V03:K0:iwQmGFFqX4s=:T9AG/W7YMer4+ZQKVn3byA TVffhXFSNi6Wn94PY+9wf4sgkj0dX2tw4HV86Iccdp3/NvVH46EwGoAXUz+KfQJfKQVieQPmb Dd74Md52QM7dMod6f/Ng5juj/e2mq2l9SJTW7lKBxg7jSkPGR/jt8Mz9n10OCLgplCQ4yZ7aP 1ERotEwq4bkwHXO2atui/KYHfGw5YGugn0dhNoSk2A2KvjeAhu/KHZMSA7B+3tnmvijoHE44D jUBXeDGIDskN8sr1nv5YR75tqc1CR6nQidIgr3pgLi+tvQSp6R7IdjwiszlRaa2c8vHUAmaDN aV6Dh+sMGfO7lh91zodlfpvvHkhg8LL8htbZEPE5ErTHETAt/5BirL/hZdViyhGY4zTCN+wl4 TJcd/7gxCl6z/ADa8BCK1zaicrApUPsfE1+9J2VVKWdyX+TUnMBYLV3GroGRaNlFZB3+vPsAk yUIe7dlf+4HG7GBahVkLlir55eWd1z/CXqrBJqxTotZtjJ5FwxHYW/Ro/jVFun3NRz+7i5hOZ RHyKFGY+29K0qHXZyAtxtGKLchBTf1QFeuAM9D3aFHJuUQUpFr+CqnbCmBQheNQwAjvZIQ+37 +ZBpfJBeWtTIO2ML+80430cGKCyc0IbhmbNFleirlBwIJwyXyi0BcjxRUvi62htpn/E2+Qz6z eqh9t8u5F8VbgQ3oJbFUi6AobkhIvePAS8csQk9XxnNeTXLbEGKy2NmGEz2tCapGJh0tQe9ou v7NWCmUwIrqMChkCAVhNDZIr4x9Mixe3lWyE+AKiZLJuw4/jGptO5ouvei6zWGu0Sq/cq5eH X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:176265 Archived-At: This is a multi-part message in MIME format. --------------F124554BCE15942068D249C9 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Am 15.02.20 um 08:44 schrieb Eli Zaretskii: > > I'd like to install your patch, and I'd like to do it soon, so it > makes it into Emacs 27. Can you please propose a modified patch which > adds some minimal information about what's going on to the doc string > and/or the comments around the code? Here is the revised patch. I have cleared the FIXME issue mentioned by Lars and added commentary to what is going on. --------------F124554BCE15942068D249C9 Content-Type: text/x-patch; name="0001-Do-not-write-absolute-filenames-and-duplicate-string.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename*0="0001-Do-not-write-absolute-filenames-and-duplicate-string.pa"; filename*1="tch" =46rom 375bdad57a2b56c63722e1d93c1e1de13566e8a2 Mon Sep 17 00:00:00 2001 From: Wolfgang Scherer Date: Wed, 19 Feb 2020 23:53:10 +0100 Subject: [PATCH] Do not write absolute filenames and duplicate strings int= o .cvsignore MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * 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. Addtional optional parameter SORT. (lisp/vc/pcvs.el) Call =E2=80=98vc-cvs-append-to-ignore=E2=80=99 with SORT= argument. =2D-- lisp/vc/pcvs.el | 4 ++-- lisp/vc/vc-cvs.el | 40 +++++++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/lisp/vc/pcvs.el b/lisp/vc/pcvs.el index dcba504..cb0494e 100644 =2D-- a/lisp/vc/pcvs.el +++ b/lisp/vc/pcvs.el @@ -106,7 +106,6 @@ ;; right now, it's killed without further ado. ;; - make `cvs-mode-ignore' allow manually entering a pattern. ;; to which dir should it apply ? -;; - cvs-mode-ignore should try to remove duplicate entries. ;; - maybe poll/check CVS/Entries files to react to external `cvs' comman= ds ? ;; - some kind of `cvs annotate' support ? ;; but vc-annotate can be used instead. @@ -1972,7 +1971,8 @@ This command ignores files that are not flagged as `= Unknown'." (interactive) (dolist (fi (cvs-mode-marked 'ignore)) (vc-cvs-append-to-ignore (cvs-fileinfo->dir fi) (cvs-fileinfo->file f= i) - (eq (cvs-fileinfo->subtype fi) 'NEW-DIR)) + (eq (cvs-fileinfo->subtype fi) 'NEW-DIR) + cvs-sort-ignore-file) (setf (cvs-fileinfo->type fi) 'DEAD)) (cvs-cleanup-collection cvs-cookies nil nil nil)) diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el index 16566a8..00459e8 100644 =2D-- a/lisp/vc/vc-cvs.el +++ b/lisp/vc/vc-cvs.el @@ -1220,14 +1220,27 @@ 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-append-to-ignore (dir str &optional old-dir) +(defun vc-cvs-ignore (file &optional directory _remove) + "Ignore FILE under CVS. +FILE is either absolute or relative to DIRECTORY. + +There is a CVS ignore file in each subdirectory. Patterns only +match files in the same directory. Since FILE can be a relative +filename with leading diretories, FILE is expanded against +DIRECTORY to determine the correct absolute filename. This path +is then used to determine the directory and the pattern for the +ignore file. + +Patterns follow glob(7) syntax. Special characters \"?*[\\\" are +escaped with a backslash." + (setq file (directory-file-name (expand-file-name file directory))) + (vc-cvs-append-to-ignore (file-name-directory file) (file-name-nondirec= tory file))) + +(defun vc-cvs-append-to-ignore (dir str &optional old-dir sort) "In DIR, add STR to the .cvsignore file. If OLD-DIR is non-nil, then this is a directory that we don't want -to hear about anymore." +to hear about anymore. If SORT is non-nil, sort the ines of the +ignore file." (with-current-buffer (find-file-noselect (expand-file-name ".cvsignore" dir)) (when (ignore-errors @@ -1236,13 +1249,14 @@ to hear about anymore." (not (vc-editable-p buffer-file-name)))) ;; CVSREAD=3Don 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")) + (if sort (sort-lines nil (point-min) (point-max))) + (save-buffer))))) (provide 'vc-cvs) =2D- 2.7.4 --------------F124554BCE15942068D249C9--