From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Wolfgang Scherer Newsgroups: gmane.emacs.bugs Subject: bug#37217: [PATCH] vc-default-ignore implementation is incorrect Date: Thu, 29 Aug 2019 02:53:20 +0200 Message-ID: <4b41d328-04ef-8fc3-9b89-6362e83c37a6@gmx.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------04F003101082A9DDA0F0355C" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="177411"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 To: 37217@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 29 02:54:45 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i38i1-000jfK-Mt for geb-bug-gnu-emacs@m.gmane.org; Thu, 29 Aug 2019 02:54:42 +0200 Original-Received: from localhost ([::1]:44090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i38hz-0008US-R0 for geb-bug-gnu-emacs@m.gmane.org; Wed, 28 Aug 2019 20:54:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40464) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i38hQ-0008U8-1S for bug-gnu-emacs@gnu.org; Wed, 28 Aug 2019 20:54:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i38hO-0006t6-TO for bug-gnu-emacs@gnu.org; Wed, 28 Aug 2019 20:54:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42603) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i38hO-0006t0-Px for bug-gnu-emacs@gnu.org; Wed, 28 Aug 2019 20:54:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i38hO-0002Io-Ms for bug-gnu-emacs@gnu.org; Wed, 28 Aug 2019 20:54:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Wolfgang Scherer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 29 Aug 2019 00:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 37217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: Emacs Bugs Original-Received: via spool by submit@debbugs.gnu.org id=B.15670400118803 (code B ref -1); Thu, 29 Aug 2019 00:54:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Aug 2019 00:53:31 +0000 Original-Received: from localhost ([127.0.0.1]:51424 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i38gt-0002Hs-5m for submit@debbugs.gnu.org; Wed, 28 Aug 2019 20:53:31 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:41992) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i38gr-0002Hl-EE for submit@debbugs.gnu.org; Wed, 28 Aug 2019 20:53:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40378) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i38gq-0008R7-AD for bug-gnu-emacs@gnu.org; Wed, 28 Aug 2019 20:53:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i38gp-0006kH-79 for bug-gnu-emacs@gnu.org; Wed, 28 Aug 2019 20:53:28 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:50995) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i38go-0006k3-Sk for bug-gnu-emacs@gnu.org; Wed, 28 Aug 2019 20:53:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1567040002; bh=aMeA05dneAoJKVwyEF80DAfci9RaDhKChLXctsYoFeo=; h=X-UI-Sender-Class:To:From:Subject:Date; b=ZQl8uVqrTFVPTVz+7ohFBikIpRVhfHziRQjKMfbd+DeoTl5mYDVwio8lzlca2jbb+ XoyOcSIiUsXbfXXB2MGMsdShifGNMfLo02snRqZEENZs8SMuUbjkUwGbv0JDHZ0xVs 1RjvyzpoUmWLG28oVvEAHoUbgT5cjfoJ7qzRnR/Q= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from sheckley.simul.de ([87.144.41.174]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0LaaVn-1iTvbR1N9j-00mHz2 for ; Thu, 29 Aug 2019 02:53:22 +0200 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 CAABD1942B0A for ; Thu, 29 Aug 2019 02:53:20 +0200 (CEST) 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 Content-Language: de-DE X-Provags-ID: V03:K1:GmIALAq9f8mwaAy6DglCLzEHMqrASeWD1LpcLxWeTikwpSfGzCK PuhWFkQQTBcMvmVzcpJAlGOaVBQz4s/2TADv4cfdBrsAoHlx8YDvZsovxImCyYRmKj+qO3e 3rXV99qxtRYo+smFmtHdyuLwlVKDThJulKKAprlRpPkkKjHXUqtPrUDxb/v0AE7ByoypnCZ 3LBR3enWRdWokSbUm4pJA== X-UI-Out-Filterresults: notjunk:1;V03:K0:eC2NCKojhk4=:CLBHhjEuEYDB6loi3xMV6v 053a0XzAimVBAabQaCdajh4J/HPULNAZwBE40AKOJHvwF6bRvpPUILHWRMBz0+lUe0KyBvYUR v3BVBYtULiUTRfMIglrskfClcbWx4/588ijylgjpGf7SPU/DSAOLPhyqS+l6uc0hsPFFn7ZTN m7do3jP/QcV9WfEHWRZbsD/aFn20TaOrArw9KWc/c1S1039aufa/cvZBJxgrPiYZm7ihfcBjs bmtP1kNY0qS1beOW/SHU42trgY6s+uR/x7UjDfYQyl0Sd/Hd7ASzTqrqy4SIJNoYPg0joQI8F Y6L4c3QYhu2OiXy4C2LvWhP/60bQonrA9CM488owWfPP4hoALV2e2RfzaHBktCUelriAW4r1e q92QUz+GpF09dfsUMrTB/HcPVTSVGFoD23NF6B1x6MqEWgntEQgxn4Jd789yFHhIcKmAA0iUL N0sHGZzFZlH9RPWEDXash+F74XZUcq/nm7830P1of6UITFW30OIJVDj7ee8D4y+lndJnrzo++ zcU6oOvV52W2t9KjlQjWg9Idwq5eI7KWQfe9d9zS068sVADM8xxjwoPYi0XryMLglY35QwV83 ZvJ5RG1lap9q1bbfCQqH3NDIn841Jwi3x8IX+ZtUjEmW4WxsgnbcZFtJxZI3G1rcRhkskiW6W kpYADURakdljaU1SPf/4Az4TtZ+66WBVVh0CtTVzcmn6gsbNA8X0jkH2YHmK8nwv694pKTkqG VbrIRCNnJDYLvBl9vdogrH/HJl+iJ1AvKfRJYxTx6LRve0kF1HoAstVIfAQ90DkHsYL2r02h X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:166032 Archived-At: This is a multi-part message in MIME format. --------------04F003101082A9DDA0F0355C Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Only the basename of FILE is written to the ignore file. This is wrong for all filenames relative to project root with one ore more parent directories. The remove option is also implemented incorrectly. The attached patch fixes these errors. --------------04F003101082A9DDA0F0355C Content-Type: text/x-patch; name="0001-Fixes-vc-default-ignore.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Fixes-vc-default-ignore.patch" =46rom 7ca81822189035db9a117b66ed8365b4eb2ab88b Mon Sep 17 00:00:00 2001 From: Wolfgang Scherer Date: Thu, 29 Aug 2019 02:51:03 +0200 Subject: [PATCH] Fixes 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. =2D-- lisp/vc/vc.el | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 4cac153..2b1f163 100644 =2D-- 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-direct= ory))) - (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=3D (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) =2D- 2.7.4 --------------04F003101082A9DDA0F0355C--