GNU bug report logs - #51614
29.0.50; [PATCH] vc-switches ignore file or directory variables

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Aleksandr Vityazev <avityazev@HIDDEN>; Keywords: moreinfo; dated Fri, 5 Nov 2021 16:40:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Removed tag(s) patch. Request was from Lars Ingebrigtsen <larsi@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 51614 <at> debbugs.gnu.org:


Received: (at 51614) by debbugs.gnu.org; 10 Sep 2022 04:43:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Sep 10 00:43:51 2022
Received: from localhost ([127.0.0.1]:36104 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oWsLP-0001ap-8l
	for submit <at> debbugs.gnu.org; Sat, 10 Sep 2022 00:43:51 -0400
Received: from quimby.gnus.org ([95.216.78.240]:53750)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1oWsLJ-0001aX-Nc
 for 51614 <at> debbugs.gnu.org; Sat, 10 Sep 2022 00:43:49 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID
 :Date:References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-ID:
 Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
 :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=YnMXw/upbcnoJQC5Q9sbfAmgmde82TA0fWNGA0vtow0=; b=ARkrwaIMQtA3J2FQS5hhp0aSs+
 pEdTTHRyoz7Mz7u8xQ3RvGy/VD1lhLHqrLo4SshEHsrA5vtTtwg8Whdj1tSoz0BmqQHKem7tM/Ltn
 SIXLHITV7b6ePm0MNTtKHB1/YF0aTcXdlRJyCEVGDSpOqek1ixkD+02KyAC/hHMH6PRo=;
Received: from [84.212.220.105] (helo=joga)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1oWsLB-0006Kv-5T; Sat, 10 Sep 2022 06:43:39 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Aleksandr Vityazev <avityazev@HIDDEN>
Subject: Re: bug#51614: 29.0.50; [PATCH] vc-switches ignore file or
 directory variables
In-Reply-To: <875yt68skq.fsf@HIDDEN> (Aleksandr Vityazev's message of
 "Fri, 05 Nov 2021 16:39:49 +0000")
References: <875yt68skq.fsf@HIDDEN>
X-Now-Playing: Peter Gabriel's _Peter Gabriel 3_: "I Don't Remember"
Date: Sat, 10 Sep 2022 06:43:36 +0200
Message-ID: <87mtb7rg93.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 
 Content preview:  Aleksandr Vityazev <avityazev@HIDDEN> writes: > The current
    implementation of the vc-switches function from > lisp/vc/vc.el ignores the
    values ​​of vc-BACKEND-diff-switches, > vc-diff-switches set as local
    directory or file variables. 
 
 Content analysis details:   (-2.9 points, 5.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
                             [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 51614
Cc: 51614 <at> debbugs.gnu.org, Dmitry Gutov <dgutov@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Aleksandr Vityazev <avityazev@HIDDEN> writes:

> The current implementation of the vc-switches function from
> lisp/vc/vc.el ignores the values =E2=80=8B=E2=80=8Bof vc-BACKEND-diff-swi=
tches,
> vc-diff-switches set as local directory or file variables.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

> Perhaps the attached patch can solve the problem.

[...]

> +  (let* ((buffer (other-buffer (current-buffer) t))
> +         (switches
> +	  (or (when backend
> +	        (let ((sym (vc-make-backend-sym
> +			    backend (intern (concat (symbol-name op)
> +						    "-switches")))))
> +		  (when (boundp sym) (buffer-local-value sym buffer))))
> +	      (let ((sym (intern (format "vc-%s-switches" (symbol-name op)))))
> +	        (when (boundp sym) (buffer-local-value sym buffer)))
> +	      (cond
> +	       ((eq op 'diff) diff-switches)))))

I don't think using `other-buffer' here is a reliable way of getting the
buffer we're interested in here, so I think this would have to be fixed
in a different way.

I'm adding Dmitry to the CCs; perhaps he has some comments here.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#51614; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 5 Nov 2021 16:39:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 05 12:39:54 2021
Received: from localhost ([127.0.0.1]:46986 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mj2Ft-0005Bp-LJ
	for submit <at> debbugs.gnu.org; Fri, 05 Nov 2021 12:39:53 -0400
Received: from lists.gnu.org ([209.51.188.17]:57186)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <avityazev@HIDDEN>) id 1mj2Fo-0005Bd-RU
 for submit <at> debbugs.gnu.org; Fri, 05 Nov 2021 12:39:52 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:36606)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <avityazev@HIDDEN>)
 id 1mj2Fo-0004Tp-1d
 for bug-gnu-emacs@HIDDEN; Fri, 05 Nov 2021 12:39:48 -0400
Received: from mout02.posteo.de ([185.67.36.66]:49499)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <avityazev@HIDDEN>)
 id 1mj2Fk-000402-Ao
 for bug-gnu-emacs@HIDDEN; Fri, 05 Nov 2021 12:39:47 -0400
Received: from submission (posteo.de [89.146.220.130]) 
 by mout02.posteo.de (Postfix) with ESMTPS id 18B5A240101
 for <bug-gnu-emacs@HIDDEN>; Fri,  5 Nov 2021 17:39:37 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.org; s=2017;
 t=1636130378; bh=vq13Kot2f0rDdJTsSlECxTp1KSIy9sU0JFyjaZ4YfWU=;
 h=From:To:Subject:Date:From;
 b=Hcm5zQgzgp7L8lW1vlDfnJX2ak06cPBmpUxa7MoLpWUVziIecCtgO8HMwQ548u5bN
 UHXIGoqIBDm+P6jLBYP9igGzC6H9tZr09rx/mz7KXAJSKTpWUV7xr8fxQZA50uFZOM
 0m2pmOdzvlTYUfNknvtcVc58L6nhii8DXnQqVAR6npH9evFpoX18HXnHuwFozKLe/p
 +1kE6yHZ+/nZmAZLP/AWTlmIDDpWCrZTNxtUUSqLRS9FM5hVvQuakajAwQRj6wFdYE
 NOQdVa8IHUYgMJYFw1ZVAw1fKgLkO9F2dtSiR7pjqwcHZ07i0ArOgFDRMCRrNlfIAb
 toFFBZtjSR3hQ==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4Hm5nh55Qrz9rxB
 for <bug-gnu-emacs@HIDDEN>; Fri,  5 Nov 2021 17:39:36 +0100 (CET)
From: Aleksandr Vityazev <avityazev@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 29.0.50; [PATCH] vc-switches ignore file or directory variables
Date: Fri, 05 Nov 2021 16:39:49 +0000
Message-ID: <875yt68skq.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=185.67.36.66; envelope-from=avityazev@HIDDEN;
 helo=mout02.posteo.de
X-Spam_score_int: -43
X-Spam_score: -4.4
X-Spam_bar: ----
X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable


Hello,

The current implementation of the vc-switches function from
lisp/vc/vc.el ignores the values =E2=80=8B=E2=80=8Bof vc-BACKEND-diff-switc=
hes,
vc-diff-switches set as local directory or file variables.

Here's a reproduction:

1. Run "emacs -Q"
2. "C-x C-f" to open file /tmp/test-project/.dir-locals.el
3. Type this into the buffer:
((nil ((vc-git-diff-switches . ("--binary" "--textconv")))))
4. "C-x C-s" to save the buffer
5. "C-x C-f" to open the file /tmp/test-project/test.gpg.
Without --binary and --textconv, diff will not be displayed
for a file with a .gpg extension.
6. Type something in the buffer for example: "Just a test"
7. "C-x C-s" to save the file
8. "C-x v v" to choose VCS backend: in this case, Git
and register the file under VCS
9. "C-x v v" to commit changes
10. Type commit message and "C-c C-c"
11. Type something in the buffer with file /tmp/test-project/test.gpg
12. "C-x C-s" to save the buffer
13. "C-x v =3D" to show the diff
14. Bug occurs: diff is not displayed.


Perhaps the attached patch can solve the problem.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0001-lisp-vc-vc.el-vc-switches-Handle-dir-local-variables.patch
Content-Description: lisp/vc/vc.el

From 9b031423294224a6fe142abf6bd469b5cfa99c83 Mon Sep 17 00:00:00 2001
From: Alexandr Vityazev <avityazev@HIDDEN>
Date: Thu, 28 Oct 2021 22:43:28 +0300
Subject: [PATCH] * lisp/vc/vc.el (vc-switches): Handle dir local variables.

* lisp/vc/vc.el (vc-switches): Handle vc-BACKEND-diff-switches,
vc-diff-switches set as local directory or file variables.
---
 lisp/vc/vc.el | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 927a241a60..a858cbc451 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -1700,16 +1700,17 @@ diff only, `diff-switches'.
 If the chosen value is not a string or a list, return nil.
 This is so that you may set, e.g. `vc-svn-diff-switches' to t in order
 to override the value of `vc-diff-switches' and `diff-switches'."
-  (let ((switches
-	 (or (when backend
-	       (let ((sym (vc-make-backend-sym
-			   backend (intern (concat (symbol-name op)
-						   "-switches")))))
-		   (when (boundp sym) (symbol-value sym))))
-	     (let ((sym (intern (format "vc-%s-switches" (symbol-name op)))))
-	       (when (boundp sym) (symbol-value sym)))
-	     (cond
-	      ((eq op 'diff) diff-switches)))))
+  (let* ((buffer (other-buffer (current-buffer) t))
+         (switches
+	  (or (when backend
+	        (let ((sym (vc-make-backend-sym
+			    backend (intern (concat (symbol-name op)
+						    "-switches")))))
+		  (when (boundp sym) (buffer-local-value sym buffer))))
+	      (let ((sym (intern (format "vc-%s-switches" (symbol-name op)))))
+	        (when (boundp sym) (buffer-local-value sym buffer)))
+	      (cond
+	       ((eq op 'diff) diff-switches)))))
     (if (stringp switches) (list switches)
       ;; If not a list, return nil.
       ;; This is so we can set vc-diff-switches to t to override
-- 
2.33.1


--=-=-=
Content-Type: text/plain


-- 
Best regards,
Aleksandr Vityazev

--=-=-=--




Acknowledgement sent to Aleksandr Vityazev <avityazev@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#51614; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 10 Sep 2022 04:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.