Subject: bug#78987: 30.1; Unable to create new Git repository in Dired mode

From: Stephen Berman <[email-masked]>
Date: Thu, 10 Jul 2025 02:29:34 +0200

On Thu, 10 Jul 2025 03:37:40 +0800 "Zipei Lu" via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email-masked]> 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 "\

Steve Berman