GNU bug report logs - #78987
30.1; Unable to create new Git repository in Dired mode

Previous Next

Package: emacs;

Reported by: "Zipei Lu" <zipeilu <at> qq.com>

Date: Wed, 9 Jul 2025 21:57:09 UTC

Severity: normal

Found in version 30.1

Done: Sean Whitton <spwhitton <at> spwhitton.name>

Bug is archived. No further changes may be made.

Full log


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

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: zipeilu <at> qq.com, 78987 <at> debbugs.gnu.org,
 Sean Whitton <spwhitton <at> spwhitton.name>
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Fri, 11 Jul 2025 13:49:47 +0200
[Message part 1 (text/plain, inline)]
On Fri, 11 Jul 2025 14:12:38 +0300 Eli Zaretskii <eliz <at> gnu.org> wrote:

>> Cc: zipeilu <at> qq.com, Stephen Berman <stephen.berman <at> gmx.net>
>> From: Sean Whitton <spwhitton <at> spwhitton.name>
>> Date: Fri, 11 Jul 2025 09:36:14 +0100
>> 
>> Hello,
>> 
>> On Thu 10 Jul 2025 at 02:29am +02, Stephen Berman via "Bug reports for GNU
>> Emacs, the Swiss army knife of text editors" wrote:
>> 
>> > On Thu, 10 Jul 2025 03:37:40 +0800 "Zipei Lu" via "Bug reports for GNU
>> > Emacs, the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>> > wrote:
>> >
>> >> Here are the steps to reproduce the bug:
>> >> 1. 'C-x d' to arbitrary directory without any version control repository.
>> >> 2. Mark arbitrary number of files with 'm'.
>> >> 3. Type 'C-x v v'.
>> >>
>> >> Then the mini buffer will display:
>> >>
>> >> No VC backend is responsible for c:/my/directory/
>> >>
>> >> According to GNU Emacs manual 30.1.3.1, 'C-x v v' is expected to create
>> >> a new repository in the directory. However, 'C-x v v' can still be able
>> >> to create
>> >> new repository in the buffer of  a file(Not in the buffer of directory).
>> >
>> > This patch seems to DTRT, at least on initial testing with -Q:
>> >
>> > diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
>> > index e5b08af2a30..d8b195d9a12 100644
>> > --- a/lisp/dired-aux.el
>> > +++ b/lisp/dired-aux.el
>> > @@ -4022,8 +4022,9 @@ dired-vc-next-action
>> >  ;;;###autoload
>> >  (defun dired-vc-deduce-fileset
>> >      (&optional state-model-only-files not-state-changing)
>> > -  (let ((backend (vc-responsible-backend default-directory))
>> > -        (files (dired-get-marked-files nil nil nil nil t)))
>> > +  (let* ((files (dired-get-marked-files nil nil nil nil t))
>> > +         (backend (or (vc-responsible-backend default-directory t)
>> > +                      (vc-backend-for-registration (car files)))))
>> >      (when (and (not not-state-changing)
>> >                 (cl-some #'file-directory-p files))
>> >        (user-error "\
>> 
>> I think this is okay, please install.
>
> Please don't ignore my comment in
>
>   https://lists.gnu.org/archive/html/help-gnu-emacs/2025-07/msg00090.html

I wanted to reply to that so I'll do it here; here's the context:

> From: Eli Zaretskii <eliz <at> gnu.org>
> Subject: Re: Unable to create new Git repo with VC utilities
> To: Stephen Berman <stephen.berman <at> gmx.net>
> Cc: rpluim <at> gmail.com, lzpzipei <at> gmail.com, help-gnu-emacs <at> gnu.org
> Date: Thu, 10 Jul 2025 07:52:07 +0300 (1 day, 6 hours, 38 minutes ago)
>
>> From: Stephen Berman <stephen.berman <at> gmx.net>
>> Cc: rpluim <at> gmail.com,  lzpzipei <at> gmail.com,  help-gnu-emacs <at> gnu.org
>> Date: Wed, 09 Jul 2025 19:55:54 +0200
[...]
>> >> This patch seems to DTRT, at least on initial testing:
[...]
>> > Thanks, but vc-backend-for-registration is not autoloaded, so I think
>> > something is still missing.
>> 
>> But vc-responsible-backend is called first and it is autoloaded.
>
> It is not a good idea to rely on that.  It's fragile: one simple
> change to the source, and the command will signal an error.

I'm not sure what you mean by "one simple change to the source".  But I
did see this warning after rebuilding emacs:

  ⛔ Warning (native-compiler): dired-aux.el:4027:24: Warning: the
  function ‘vc-backend-for-registration’ is not known to be defined.

With the following patch, there is no longer such a warning; does it
also allay your reservations?

[Message part 2 (text/x-patch, inline)]
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index e5b08af2a30..3c6ef080f5f 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -4022,8 +4022,10 @@ dired-vc-next-action
 ;;;###autoload
 (defun dired-vc-deduce-fileset
     (&optional state-model-only-files not-state-changing)
-  (let ((backend (vc-responsible-backend default-directory))
-        (files (dired-get-marked-files nil nil nil nil t)))
+  (eval-when-compile (require 'vc))
+  (let* ((files (dired-get-marked-files nil nil nil nil t))
+         (backend (or (vc-responsible-backend default-directory t)
+                      (vc-backend-for-registration (car files)))))
     (when (and (not not-state-changing)
                (cl-some #'file-directory-p files))
       (user-error "\
[Message part 3 (text/plain, inline)]
Steve Berman

This bug report was last modified 31 days ago.

Previous Next


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