GNU bug report logs - #60897
29.0.60; vc-revert fails to revert buffer

Previous Next

Package: emacs;

Reported by: Eric Gillespie <epg <at> pretzelnet.org>

Date: Wed, 18 Jan 2023 01:11:01 UTC

Severity: normal

Fixed in version 29.0.60

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


Message #35 received at 60897 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 60897 <at> debbugs.gnu.org, epg <at> pretzelnet.org
Subject: Re: bug#60897: 29.0.60; vc-revert fails to revert buffer
Date: Tue, 24 Jan 2023 20:18:32 +0200
>>  (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?

I tried to avoid expand-file-name, but maybe it's unavoidable.
In this case I can't find a solution simpler than this:

diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el
index e1a3eff448d..fd5f655a0f6 100644
--- a/lisp/vc/vc-dispatcher.el
+++ b/lisp/vc/vc-dispatcher.el
@@ -608,7 +608,10 @@ 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= buffer-file-name
+                (if (file-name-absolute-p file)
+                    file
+                  (expand-file-name file (vc-root-dir))))
        (if keep
 	   (when (file-exists-p file)
 	     (when reset-vc-info
@@ -643,7 +646,10 @@ 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= buffer-file-name
+               (if (file-name-absolute-p file)
+                   file
+                 (expand-file-name file (vc-root-dir))))
       (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)




This bug report was last modified 2 years and 119 days ago.

Previous Next


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