GNU bug report logs - #79137
31.0.50; (vc-buffer-sync-fileset) cannot complete if unrelated no-longer-reachable TRAMP buffers exist

Previous Next

Package: emacs;

Reported by: Dima Kogan <dima <at> secretsauce.net>

Date: Thu, 31 Jul 2025 21:21:02 UTC

Severity: normal

Found in version 31.0.50

To reply to this bug, email your comments to 79137 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#79137; Package emacs. (Thu, 31 Jul 2025 21:21:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dima Kogan <dima <at> secretsauce.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 31 Jul 2025 21:21:02 GMT) Full text and rfc822 format available.

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

From: Dima Kogan <dima <at> secretsauce.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 31.0.50; (vc-buffer-sync-fileset) cannot complete if unrelated
 no-longer-reachable TRAMP buffers exist
Date: Thu, 31 Jul 2025 14:22:55 -0700
Hi. I'm using the bleeding-edge emacs from git: 99080d0c049. On Debian.
GTK.

I have an emacs session with lots of buffers. Some of these were remote
TRAMP /ssh: buffers, talking to a server that isn't accessible anymore.

I'm looking at a LOCAL file (not one of those unrelated TRAMP buffers).
I want a git-diff, so I hit C-x v D (vc-root-diff). Emacs then tries to
contact the no-longer-reachable server, which always fails, and I never
get my diff. The git repository in question is local. There's no reason
to even consider those other buffers. Probably what it should do is to
find the root of the repository, and reject all buffers that aren't
direct descendants of that path.

I tracked down the problem to this function:


  (defun vc-buffer-sync-fileset (fileset &optional not-essential missing-in-dirs)
    "Call `vc-buffer-sync' for most buffers visiting files in FILESET.
  NOT-ESSENTIAL means it is okay to continue if the user says not to save.

  For files named explicitly in FILESET, this function always syncs their
  buffers.  By contrast, for directories named in FILESET, its behavior
  depends on MISSING-IN-DIRS.  For each directory named in FILESET, it
  considers buffers visiting any file contained within that directory or
  its subdirectories.  If MISSING-IN-DIRS is nil, it syncs only those
  buffers whose files exist on disk.  Otherwise it syncs all of them."
    ;; This treatment of directories named in FILESET is wanted for, at
    ;; least, users with `vc-find-revision-no-save' set to non-nil: not
    ;; treating directories this way would imply calling `vc-buffer-sync'
    ;; on all buffers generated by \\`C-x v ~' during \\`C-x v D'.
    (let (dirs buffers)
      (dolist (name (cadr fileset))
        (if (file-directory-p name)
            (push name dirs)
          (when-let* ((buf (find-buffer-visiting name)))
            (push buf buffers))))
      (when dirs
        (setq buffers
              (cl-nunion buffers
                         (match-buffers
                          (lambda (buf)
                            (and-let*
                                ((file (buffer-local-value 'buffer-file-name buf))
                                 ((or missing-in-dirs (file-exists-p file)))
                                 ((cl-some (lambda (dir)
                                             (file-in-directory-p file dir))
                                           dirs)))))))))
      (dolist (buf buffers)
        (with-current-buffer buf
          (vc-buffer-sync not-essential)))))

The (file-exists-p file) call is the one that makes TRAMP look at ssh.
Probably a bit more logic is needed in that area. I can probably code
this up myself; let me know if yall want a patch.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79137; Package emacs. (Fri, 01 Aug 2025 12:52:02 GMT) Full text and rfc822 format available.

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

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Dima Kogan <dima <at> secretsauce.net>
Cc: 79137 <at> debbugs.gnu.org
Subject: Re: bug#79137: 31.0.50; (vc-buffer-sync-fileset) cannot complete if
 unrelated no-longer-reachable TRAMP buffers exist
Date: Fri, 01 Aug 2025 14:50:53 +0200
Dima Kogan <dima <at> secretsauce.net> writes:

Hi Dima,

>   (defun vc-buffer-sync-fileset (fileset &optional not-essential missing-in-dirs)
>     "Call `vc-buffer-sync' for most buffers visiting files in FILESET.
>   NOT-ESSENTIAL means it is okay to continue if the user says not to save.
>
>   For files named explicitly in FILESET, this function always syncs their
>   buffers.  By contrast, for directories named in FILESET, its behavior
>   depends on MISSING-IN-DIRS.  For each directory named in FILESET, it
>   considers buffers visiting any file contained within that directory or
>   its subdirectories.  If MISSING-IN-DIRS is nil, it syncs only those
>   buffers whose files exist on disk.  Otherwise it syncs all of them."
>     ;; This treatment of directories named in FILESET is wanted for, at
>     ;; least, users with `vc-find-revision-no-save' set to non-nil: not
>     ;; treating directories this way would imply calling `vc-buffer-sync'
>     ;; on all buffers generated by \\`C-x v ~' during \\`C-x v D'.
>     (let (dirs buffers)

Does it help to use here

(let ((non-essential t)
      dirs buffers)

> Thanks.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79137; Package emacs. (Fri, 01 Aug 2025 15:51:02 GMT) Full text and rfc822 format available.

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

From: Dima Kogan <dima <at> secretsauce.net>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: 79137 <at> debbugs.gnu.org
Subject: Re: bug#79137: 31.0.50; (vc-buffer-sync-fileset) cannot complete if
 unrelated no-longer-reachable TRAMP buffers exist
Date: Fri, 01 Aug 2025 08:53:05 -0700
Hi.


Michael Albinus <michael.albinus <at> gmx.de> writes:

> Does it help to use here
>
> (let ((non-essential t)
>       dirs buffers)

It does! I now get my diff. I should point out that this is very
confusing: later in this same function there's a reference to
'not-essential, which apparently is a different, unrelated thing to
'non-essential.

Let me know if any more tests would be useful.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79137; Package emacs. (Fri, 01 Aug 2025 16:45:01 GMT) Full text and rfc822 format available.

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

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Dima Kogan <dima <at> secretsauce.net>
Cc: 79137 <at> debbugs.gnu.org
Subject: Re: bug#79137: 31.0.50; (vc-buffer-sync-fileset) cannot complete if
 unrelated no-longer-reachable TRAMP buffers exist
Date: Fri, 01 Aug 2025 18:44:14 +0200
Dima Kogan <dima <at> secretsauce.net> writes:

> Hi.

Hi Dima,

>> Does it help to use here
>>
>> (let ((non-essential t)
>>       dirs buffers)
>
> It does! I now get my diff. I should point out that this is very
> confusing: later in this same function there's a reference to
> 'not-essential, which apparently is a different, unrelated thing to
> 'non-essential.
>
> Let me know if any more tests would be useful.

My proposal was just a guess. I don't know the code of VC.

Let the VC people chime in for further analysis.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79137; Package emacs. (Tue, 05 Aug 2025 10:44:02 GMT) Full text and rfc822 format available.

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

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Dima Kogan <dima <at> secretsauce.net>, Michael Albinus <michael.albinus <at> gmx.de>
Cc: 79137 <at> debbugs.gnu.org
Subject: Re: bug#79137: 31.0.50; (vc-buffer-sync-fileset) cannot complete if
 unrelated no-longer-reachable TRAMP buffers exist
Date: Tue, 05 Aug 2025 11:43:41 +0100
Hello,

On Fri 01 Aug 2025 at 08:53am -07, Dima Kogan wrote:

> Hi.
>
>
> Michael Albinus <michael.albinus <at> gmx.de> writes:
>
>> Does it help to use here
>>
>> (let ((non-essential t)
>>       dirs buffers)
>
> It does! I now get my diff. I should point out that this is very
> confusing: later in this same function there's a reference to
> 'not-essential, which apparently is a different, unrelated thing to
> 'non-essential.
>
> Let me know if any more tests would be useful.

I think that we should bind non-essential to the value of not-essential,
here.  I.e.

    (let ((non-essential not-essential)
          dirs buffers)

That would be saying: only if we are okay with the user saying no to
saving the buffers, we are okay with giving up on looking at them if
they are remote.

How about that?

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79137; Package emacs. (Tue, 05 Aug 2025 11:59:02 GMT) Full text and rfc822 format available.

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

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: 79137 <at> debbugs.gnu.org, Dima Kogan <dima <at> secretsauce.net>
Subject: Re: bug#79137: 31.0.50; (vc-buffer-sync-fileset) cannot complete if
 unrelated no-longer-reachable TRAMP buffers exist
Date: Tue, 05 Aug 2025 13:58:11 +0200
Sean Whitton <spwhitton <at> spwhitton.name> writes:

> Hello,

Hi Sean,

> I think that we should bind non-essential to the value of not-essential,
> here.  I.e.
>
>     (let ((non-essential not-essential)
>           dirs buffers)
>
> That would be saying: only if we are okay with the user saying no to
> saving the buffers, we are okay with giving up on looking at them if
> they are remote.
>
> How about that?

Sounds reasonable. However, I don't know VC internals, so I have no
informed opinion.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79137; Package emacs. (Wed, 06 Aug 2025 14:10:03 GMT) Full text and rfc822 format available.

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

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: 79137 <at> debbugs.gnu.org, Dima Kogan <dima <at> secretsauce.net>
Subject: Re: bug#79137: 31.0.50; (vc-buffer-sync-fileset) cannot complete if
 unrelated no-longer-reachable TRAMP buffers exist
Date: Wed, 06 Aug 2025 15:09:04 +0100
Hello,

On Tue 05 Aug 2025 at 01:58pm +02, Michael Albinus wrote:

> Sean Whitton <spwhitton <at> spwhitton.name> writes:
>
>> Hello,
>
> Hi Sean,
>
>> I think that we should bind non-essential to the value of not-essential,
>> here.  I.e.
>>
>>     (let ((non-essential not-essential)
>>           dirs buffers)
>>
>> That would be saying: only if we are okay with the user saying no to
>> saving the buffers, we are okay with giving up on looking at them if
>> they are remote.
>>
>> How about that?
>
> Sounds reasonable. However, I don't know VC internals, so I have no
> informed opinion.

Dima, does my suggestion fix the concrete problem you were seeing?

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79137; Package emacs. (Thu, 07 Aug 2025 18:01:01 GMT) Full text and rfc822 format available.

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

From: Dima Kogan <dima <at> secretsauce.net>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: 79137 <at> debbugs.gnu.org, Michael Albinus <michael.albinus <at> gmx.de>
Subject: Re: bug#79137: 31.0.50; (vc-buffer-sync-fileset) cannot complete if
 unrelated no-longer-reachable TRAMP buffers exist
Date: Thu, 07 Aug 2025 11:00:24 -0700
Sean Whitton <spwhitton <at> spwhitton.name> writes:

> Dima, does my suggestion fix the concrete problem you were seeing?


Hello. Yes; that fixes it. Thank you.

Relatedly, does it NEED to examine every single buffer? It takes 10s to
go through all the buffers in my current session, even though 99% of
them have nothing to do with this git repo. A git-diff operation
shouldn't take 10s. This is a different issue from this report, though.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79137; Package emacs. (Fri, 08 Aug 2025 10:23:01 GMT) Full text and rfc822 format available.

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

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Dima Kogan <dima <at> secretsauce.net>
Cc: Michael Albinus <michael.albinus <at> gmx.de>, 79137 <at> debbugs.gnu.org
Subject: Re: bug#79137: 31.0.50; (vc-buffer-sync-fileset) cannot complete if
 unrelated no-longer-reachable TRAMP buffers exist
Date: Fri, 08 Aug 2025 11:21:52 +0100
Hello,

On Thu 07 Aug 2025 at 11:00am -07, Dima Kogan wrote:

> Sean Whitton <spwhitton <at> spwhitton.name> writes:
>
>> Dima, does my suggestion fix the concrete problem you were seeing?
>
>
> Hello. Yes; that fixes it. Thank you.

Thanks for testing.  Installed that.

> Relatedly, does it NEED to examine every single buffer? It takes 10s to
> go through all the buffers in my current session, even though 99% of
> them have nothing to do with this git repo. A git-diff operation
> shouldn't take 10s. This is a different issue from this report, though.

Are you saying it takes 10s just to go through all your local buffers,
without any TRAMP slowdown?  That is definitely too slow.

-- 
Sean Whitton




This bug report was last modified 1 day ago.

Previous Next


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