From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#60897: 29.0.60; vc-revert fails to revert buffer Date: Tue, 24 Jan 2023 20:06:17 +0200 Message-ID: <83ilgvhko6.fsf@gnu.org> References: <29401.1674004194@hassadar.pretzelnet.org> <86edrr4zcz.fsf@mail.linkov.net> <868rhu5w0u.fsf@mail.linkov.net> <83cz76jqm5.fsf@gnu.org> <86v8kx3czh.fsf@mail.linkov.net> <83v8kxidu2.fsf@gnu.org> <864jsfygsw.fsf@mail.linkov.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15743"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 60897@debbugs.gnu.org, epg@pretzelnet.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 24 19:10:36 2023 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 1pKNki-0003pb-Jo for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 24 Jan 2023 19:10:36 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKNhf-0005hV-Pn; Tue, 24 Jan 2023 13:07:27 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKNhI-0004z7-3q for bug-gnu-emacs@gnu.org; Tue, 24 Jan 2023 13:07:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pKNhH-00075U-2c for bug-gnu-emacs@gnu.org; Tue, 24 Jan 2023 13:07:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pKNhG-0003an-In for bug-gnu-emacs@gnu.org; Tue, 24 Jan 2023 13:07:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 24 Jan 2023 18:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60897 X-GNU-PR-Package: emacs Original-Received: via spool by 60897-submit@debbugs.gnu.org id=B60897.167458358713768 (code B ref 60897); Tue, 24 Jan 2023 18:07:02 +0000 Original-Received: (at 60897) by debbugs.gnu.org; 24 Jan 2023 18:06:27 +0000 Original-Received: from localhost ([127.0.0.1]:57524 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pKNgh-0003Zz-4b for submit@debbugs.gnu.org; Tue, 24 Jan 2023 13:06:27 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33352) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pKNgf-0003Zm-5A for 60897@debbugs.gnu.org; Tue, 24 Jan 2023 13:06:26 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKNgZ-00070P-0Z; Tue, 24 Jan 2023 13:06:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=yk9xPMhFZUAkaPYZzwPHKORYnF7gCFl2+S8gqsPlkB8=; b=BvAfvn+6vQ6Z WrcAWShixa4aSHLVS8Uv2tEVEf2wMXTiKR8WkMNYERucRkwl+atsXi/6OKBITkg0rVwO0VMUQk0Bd XBHooSB69MZfCT+UYtOGCXBOqJVCxJuvKcmZhOOli1yeaE9bqQYYqRciF+ERjjGbxTFQVImxRdPrV wwKGIS76WvJOH08TBy/PAksxXY3kczSLzldaKRXsI7smPaU51aCVJ0f1QkNAxEHyHJ0h69q/dUn4z 80BWDXK7VCubrXk3RZx7pifo0zD4Fc01qG0KmBKBWMuoqUsGiAYUOkZWWRcggKp5SZB0BasNdO76o pu8XhB5HLFlsi0BQZz4t1g==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKNgM-0007ec-Nt; Tue, 24 Jan 2023 13:06:18 -0500 In-Reply-To: <864jsfygsw.fsf@mail.linkov.net> (message from Juri Linkov on Tue, 24 Jan 2023 19:46:51 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:254062 Archived-At: > From: Juri Linkov > Cc: epg@pretzelnet.org, 60897@debbugs.gnu.org > Date: Tue, 24 Jan 2023 19:46:51 +0200 > > > How about replacing string= in these two cases with something smarter, > > which would expand-file-name? Comparing file names as simple strings > > is wrought with trouble anyway. > > This works as well: > > diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el > index e1a3eff448d..8a0cdef4726 100644 > --- a/lisp/vc/vc-dispatcher.el > +++ b/lisp/vc/vc-dispatcher.el > @@ -608,7 +608,7 @@ vc-resynch-window > difference between the buffer and the file is due to > modifications by the dispatcher client code, rather than user > editing!" > - (and (string= buffer-file-name file) > + (and (string-prefix-p file buffer-file-name) > (if keep > (when (file-exists-p file) > (when reset-vc-info > @@ -643,7 +643,7 @@ vc-resynch-buffers-in-directory > > (defun vc-resynch-buffer (file &optional keep noquery reset-vc-info) > "If FILE is currently visited, resynch its buffer." > - (if (string= buffer-file-name file) > + (if (string-prefix-p file buffer-file-name) > (vc-resynch-window file keep noquery reset-vc-info) > (if (file-directory-p file) > (vc-resynch-buffers-in-directory file keep noquery reset-vc-info) I'm confused: I though the problem was that FILE was some relative form of buffer-file-name, which is why you wanted to run it through expand-file-name, to make it absolute. But if this is the case, i.e. you have file = "foo" and buffer-file-name = /path/to/foo, then string-prefix-p will not do the job, right? And even if it did, you could have false positives. Maybe I just don't understand what this if clause is trying to test?