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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 78987 in the body.
You can then email your comments to 78987 AT debbugs.gnu.org in the normal way.

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#78987; Package emacs. (Wed, 09 Jul 2025 21:57:09 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Zipei Lu" <zipeilu <at> qq.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 09 Jul 2025 21:57:10 GMT) Full text and rfc822 format available.

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

From: "Zipei Lu" <zipeilu <at> qq.com>
To: "bug-gnu-emacs" <bug-gnu-emacs <at> gnu.org>
Subject: 30.1; Unable to create new Git repository in Dired mode
Date: Thu, 10 Jul 2025 03:37:40 +0800
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).

	
Zipei Lu
zipeilu <at> qq.com

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Thu, 10 Jul 2025 00:30:05 GMT) Full text and rfc822 format available.

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

From: Stephen Berman <stephen.berman <at> gmx.net>
To: "Zipei Lu" via "Bug reports for GNU Emacs, the Swiss army knife of text
 editors" <bug-gnu-emacs <at> gnu.org>
Cc: Zipei Lu <zipeilu <at> qq.com>, 78987 <at> debbugs.gnu.org
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Thu, 10 Jul 2025 02:29:34 +0200
[Message part 1 (text/plain, inline)]
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:

[Message part 2 (text/x-patch, inline)]
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 "\
[Message part 3 (text/plain, inline)]
Steve Berman

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Thu, 10 Jul 2025 00:31:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Fri, 11 Jul 2025 08:37:02 GMT) Full text and rfc822 format available.

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

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: 78987 <at> debbugs.gnu.org
Cc: zipeilu <at> qq.com, Stephen Berman <stephen.berman <at> gmx.net>
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
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.

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Fri, 11 Jul 2025 09:06:02 GMT) Full text and rfc822 format available.

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

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: 78987 <at> debbugs.gnu.org
Cc: zipeilu <at> qq.com, Stephen Berman <stephen.berman <at> gmx.net>
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Fri, 11 Jul 2025 10:05:00 +0100
Hello,

On Fri 11 Jul 2025 at 09:36am +01, Sean Whitton wrote:

>> 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.

No, wait.  I think that we need to pass down the allow-unregistered
argument from vc-deduce-fileset to dired-vc-deduce-fileset, and only
if that's non-nil can we call vc-backend-for-registration.

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Fri, 11 Jul 2025 09:35:02 GMT) Full text and rfc822 format available.

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

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: zipeilu <at> qq.com, 78987 <at> debbugs.gnu.org
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Fri, 11 Jul 2025 11:33:51 +0200
On Fri, 11 Jul 2025 10:05:00 +0100 Sean Whitton <spwhitton <at> spwhitton.name> wrote:

> Hello,
>
> On Fri 11 Jul 2025 at 09:36am +01, Sean Whitton wrote:
>
>>> 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.
>
> No, wait.  I think that we need to pass down the allow-unregistered
> argument from vc-deduce-fileset to dired-vc-deduce-fileset, and only
> if that's non-nil can we call vc-backend-for-registration.

When I test with -Q, a Git repository is created and either the file at
point or the marked files in Dired are added to it, although
`vc-deduce-fileset' calls `(dired-vc-deduce-fileset
state-model-only-files not-state-changing)', i.e., without passing
`allow-unregistered'; so why do you think it must be passed (and
non-nil)?

Steve Berman




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Fri, 11 Jul 2025 11:13:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: zipeilu <at> qq.com, 78987 <at> debbugs.gnu.org, stephen.berman <at> gmx.net
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Fri, 11 Jul 2025 14:12:38 +0300
> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Fri, 11 Jul 2025 11:50:02 GMT) Full text and rfc822 format available.

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

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Fri, 11 Jul 2025 18:15:01 GMT) Full text and rfc822 format available.

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

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: zipeilu <at> qq.com, 78987 <at> debbugs.gnu.org
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Fri, 11 Jul 2025 19:13:59 +0100
Hello,

On Fri 11 Jul 2025 at 11:33am +02, Stephen Berman via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote:

> When I test with -Q, a Git repository is created and either the file at
> point or the marked files in Dired are added to it, although
> `vc-deduce-fileset' calls `(dired-vc-deduce-fileset
> state-model-only-files not-state-changing)', i.e., without passing
> `allow-unregistered'; so why do you think it must be passed (and
> non-nil)?

It should be passed because the corresponding code path for vc-dir
passes allow-unregistered down.  dired-vc-deduce-fileset is meant to be
just a dired version of the vc-dir code path in vc-deduce-fileset.

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Sat, 12 Jul 2025 09:08:03 GMT) Full text and rfc822 format available.

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

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: zipeilu <at> qq.com, 78987 <at> debbugs.gnu.org
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Sat, 12 Jul 2025 11:07:28 +0200
On Fri, 11 Jul 2025 19:13:59 +0100 Sean Whitton <spwhitton <at> spwhitton.name> wrote:

> Hello,
>
> On Fri 11 Jul 2025 at 11:33am +02, Stephen Berman via "Bug reports for GNU
> Emacs, the Swiss army knife of text editors" wrote:
>
>> When I test with -Q, a Git repository is created and either the file at
>> point or the marked files in Dired are added to it, although
>> `vc-deduce-fileset' calls `(dired-vc-deduce-fileset
>> state-model-only-files not-state-changing)', i.e., without passing
>> `allow-unregistered'; so why do you think it must be passed (and
>> non-nil)?
>
> It should be passed because the corresponding code path for vc-dir
> passes allow-unregistered down.  dired-vc-deduce-fileset is meant to be
> just a dired version of the vc-dir code path in vc-deduce-fileset.

I admit that I find the VC code hard to follow, but I don't see where
`vc-dir' uses ALLOW-UNREGISTERED.  The docstring of `vc-deduce-fileset'
says:

  If the current buffer is in `vc-dir' or Dired mode, FILESET is the
  list of marked files, or the file under point if no files are
  marked.
  [...]
  Otherwise, if ALLOW-UNREGISTERED is non-nil and the visited file
  is unregistered, FILESET is a single-file list containing the
  name of the visited file.

This seems to say that the code path using ALLOW-UNREGISTERED bypasses
the code path using Dired.  Anyway, I'm sure you understand the VC
better than I do, so you should make the change you think is required.

Steve Berman




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Sat, 12 Jul 2025 09:13:02 GMT) Full text and rfc822 format available.

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

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: zipeilu <at> qq.com, 78987 <at> debbugs.gnu.org
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Sat, 12 Jul 2025 11:12:35 +0200
On Sat, 12 Jul 2025 11:07:28 +0200 Stephen Berman <stephen.berman <at> gmx.net> wrote:

> On Fri, 11 Jul 2025 19:13:59 +0100 Sean Whitton <spwhitton <at> spwhitton.name> wrote:
>
>> Hello,
>>
>> On Fri 11 Jul 2025 at 11:33am +02, Stephen Berman via "Bug reports for GNU
>> Emacs, the Swiss army knife of text editors" wrote:
>>
>>> When I test with -Q, a Git repository is created and either the file at
>>> point or the marked files in Dired are added to it, although
>>> `vc-deduce-fileset' calls `(dired-vc-deduce-fileset
>>> state-model-only-files not-state-changing)', i.e., without passing
>>> `allow-unregistered'; so why do you think it must be passed (and
>>> non-nil)?
>>
>> It should be passed because the corresponding code path for vc-dir
>> passes allow-unregistered down.  dired-vc-deduce-fileset is meant to be
>> just a dired version of the vc-dir code path in vc-deduce-fileset.
>
> I admit that I find the VC code hard to follow, but I don't see where
> `vc-dir' uses ALLOW-UNREGISTERED.  The docstring of `vc-deduce-fileset'
> says:
>
>   If the current buffer is in `vc-dir' or Dired mode, FILESET is the
>   list of marked files, or the file under point if no files are
>   marked.
>   [...]
>   Otherwise, if ALLOW-UNREGISTERED is non-nil and the visited file
>   is unregistered, FILESET is a single-file list containing the
>   name of the visited file.
>
> This seems to say that the code path using ALLOW-UNREGISTERED bypasses
> the code path using Dired.  Anyway, I'm sure you understand the VC

                     ^ either vc-dir or 

> better than I do, so you should make the change you think is required.
>
> Steve Berman




Reply sent to Sean Whitton <spwhitton <at> spwhitton.name>:
You have taken responsibility. (Sat, 12 Jul 2025 10:36:02 GMT) Full text and rfc822 format available.

Notification sent to "Zipei Lu" <zipeilu <at> qq.com>:
bug acknowledged by developer. (Sat, 12 Jul 2025 10:36:02 GMT) Full text and rfc822 format available.

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

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: zipeilu <at> qq.com, 78987-done <at> debbugs.gnu.org
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Sat, 12 Jul 2025 11:35:05 +0100
Hello,

On Sat 12 Jul 2025 at 11:07am +02, Stephen Berman via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote:

> This seems to say that the code path using ALLOW-UNREGISTERED bypasses
> the code path using Dired.  Anyway, I'm sure you understand the VC
> better than I do, so you should make the change you think is required.

I had another look, and I think you're right.  ALLOW-UNREGISTERED is not
relevant here.  I've installed your patch -- thanks!

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Sat, 12 Jul 2025 10:52:02 GMT) Full text and rfc822 format available.

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

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: zipeilu <at> qq.com, 78987-done <at> debbugs.gnu.org
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Sat, 12 Jul 2025 12:51:15 +0200
On Sat, 12 Jul 2025 11:35:05 +0100 Sean Whitton <spwhitton <at> spwhitton.name> wrote:

> Hello,
>
> On Sat 12 Jul 2025 at 11:07am +02, Stephen Berman via "Bug reports for GNU
> Emacs, the Swiss army knife of text editors" wrote:
>
>> This seems to say that the code path using ALLOW-UNREGISTERED bypasses
>> the code path using Dired.  Anyway, I'm sure you understand the VC
>> better than I do, so you should make the change you think is required.
>
> I had another look, and I think you're right.  ALLOW-UNREGISTERED is not
> relevant here.  I've installed your patch -- thanks!

Thank you!

Steve Berman




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Sat, 12 Jul 2025 11:07:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Sean Whitton <spwhitton <at> spwhitton.name>,
 Stephen Berman <stephen.berman <at> gmx.net>
Cc: zipeilu <at> qq.com, 78987 <at> debbugs.gnu.org
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Sat, 12 Jul 2025 14:05:52 +0300
> Resent-To: bug-gnu-emacs <at> gnu.org
> Cc: zipeilu <at> qq.com, 78987-done <at> debbugs.gnu.org
> From: Sean Whitton <spwhitton <at> spwhitton.name>
> Date: Sat, 12 Jul 2025 11:35:05 +0100
> 
> Hello,
> 
> On Sat 12 Jul 2025 at 11:07am +02, Stephen Berman via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote:
> 
> > This seems to say that the code path using ALLOW-UNREGISTERED bypasses
> > the code path using Dired.  Anyway, I'm sure you understand the VC
> > better than I do, so you should make the change you think is required.
> 
> I had another look, and I think you're right.  ALLOW-UNREGISTERED is not
> relevant here.  I've installed your patch -- thanks!

Thanks, but I don't understand why you both made
vc-backend-for-registration autoloaded _and_ added an autoload form
for it in dired-aux.el.  Isn't just one of them enough?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Sat, 12 Jul 2025 11:16:02 GMT) Full text and rfc822 format available.

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

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: zipeilu <at> qq.com, Stephen Berman <stephen.berman <at> gmx.net>,
 78987 <at> debbugs.gnu.org
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Sat, 12 Jul 2025 12:15:04 +0100
Hello,

On Sat 12 Jul 2025 at 02:05pm +03, Eli Zaretskii wrote:

>> Resent-To: bug-gnu-emacs <at> gnu.org
>> Cc: zipeilu <at> qq.com, 78987-done <at> debbugs.gnu.org
>> From: Sean Whitton <spwhitton <at> spwhitton.name>
>> Date: Sat, 12 Jul 2025 11:35:05 +0100
>>
>> Hello,
>>
>> On Sat 12 Jul 2025 at 11:07am +02, Stephen Berman via "Bug reports for GNU
>> Emacs, the Swiss army knife of text editors" wrote:
>>
>> > This seems to say that the code path using ALLOW-UNREGISTERED bypasses
>> > the code path using Dired.  Anyway, I'm sure you understand the VC
>> > better than I do, so you should make the change you think is required.
>>
>> I had another look, and I think you're right.  ALLOW-UNREGISTERED is not
>> relevant here.  I've installed your patch -- thanks!
>
> Thanks, but I don't understand why you both made
> vc-backend-for-registration autoloaded _and_ added an autoload form
> for it in dired-aux.el.  Isn't just one of them enough?

The autoload form in dired-aux.el was just to satisfy the bytecompiler.
Should it be declare-function?  Or should I drop the autoload cookie?
Which do you think would be more appropriate?

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Sat, 12 Jul 2025 11:45:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: zipeilu <at> qq.com, stephen.berman <at> gmx.net, 78987 <at> debbugs.gnu.org
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Sat, 12 Jul 2025 14:44:45 +0300
> From: Sean Whitton <spwhitton <at> spwhitton.name>
> Cc: Stephen Berman <stephen.berman <at> gmx.net>,  78987 <at> debbugs.gnu.org,
>   zipeilu <at> qq.com
> Date: Sat, 12 Jul 2025 12:15:04 +0100
> 
> On Sat 12 Jul 2025 at 02:05pm +03, Eli Zaretskii wrote:
> 
> >> Resent-To: bug-gnu-emacs <at> gnu.org
> >> Cc: zipeilu <at> qq.com, 78987-done <at> debbugs.gnu.org
> >> From: Sean Whitton <spwhitton <at> spwhitton.name>
> >> Date: Sat, 12 Jul 2025 11:35:05 +0100
> >>
> >> Hello,
> >>
> >> On Sat 12 Jul 2025 at 11:07am +02, Stephen Berman via "Bug reports for GNU
> >> Emacs, the Swiss army knife of text editors" wrote:
> >>
> >> > This seems to say that the code path using ALLOW-UNREGISTERED bypasses
> >> > the code path using Dired.  Anyway, I'm sure you understand the VC
> >> > better than I do, so you should make the change you think is required.
> >>
> >> I had another look, and I think you're right.  ALLOW-UNREGISTERED is not
> >> relevant here.  I've installed your patch -- thanks!
> >
> > Thanks, but I don't understand why you both made
> > vc-backend-for-registration autoloaded _and_ added an autoload form
> > for it in dired-aux.el.  Isn't just one of them enough?
> 
> The autoload form in dired-aux.el was just to satisfy the bytecompiler.
> Should it be declare-function?  Or should I drop the autoload cookie?
> Which do you think would be more appropriate?

I'd like to avoid the autoload cookie, yes, if that's feasible.  A
single client doesn't justify the autoload, IMO.

Why doesn't the autoload form in dired-aux enough to satisfy both the
byte compiler and run-time?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Sat, 12 Jul 2025 13:09:02 GMT) Full text and rfc822 format available.

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

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: zipeilu <at> qq.com, 78987 <at> debbugs.gnu.org, stephen.berman <at> gmx.net
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Sat, 12 Jul 2025 14:08:21 +0100
Hello,

On Sat 12 Jul 2025 at 02:44pm +03, Eli Zaretskii wrote:

> I'd like to avoid the autoload cookie, yes, if that's feasible.  A
> single client doesn't justify the autoload, IMO.

Yup, now done.

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Sat, 12 Jul 2025 13:55:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: zipeilu <at> qq.com, 78987 <at> debbugs.gnu.org, stephen.berman <at> gmx.net
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Sat, 12 Jul 2025 16:54:06 +0300
> From: Sean Whitton <spwhitton <at> spwhitton.name>
> Cc: zipeilu <at> qq.com,  stephen.berman <at> gmx.net,  78987 <at> debbugs.gnu.org
> Date: Sat, 12 Jul 2025 14:08:21 +0100
> 
> Hello,
> 
> On Sat 12 Jul 2025 at 02:44pm +03, Eli Zaretskii wrote:
> 
> > I'd like to avoid the autoload cookie, yes, if that's feasible.  A
> > single client doesn't justify the autoload, IMO.
> 
> Yup, now done.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Sun, 13 Jul 2025 07:18:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: 78987 <at> debbugs.gnu.org
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Sun, 13 Jul 2025 09:58:59 +0300
>  (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)))))

The original recipe still fails with the same error.
Shouldn't 'vc-responsible-backend' be wrapped with
'ignore-errors' in 'dired-vc-deduce-fileset'?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Sun, 13 Jul 2025 07:55:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: stephen.berman <at> gmx.net, 78987 <at> debbugs.gnu.org
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Sun, 13 Jul 2025 10:54:35 +0300
> Cc: 78987 <at> debbugs.gnu.org
> From: Juri Linkov <juri <at> linkov.net>
> Date: Sun, 13 Jul 2025 09:58:59 +0300
> 
> >  (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)))))
> 
> The original recipe still fails with the same error.
> Shouldn't 'vc-responsible-backend' be wrapped with
> 'ignore-errors' in 'dired-vc-deduce-fileset'?

There's no need for ignore-errors; instead, vc-responsible-backend
should be called with the second argument NO-ERROR non-nil.

The original patch did precisely that, so it looks like some snafu
when applying the patch; now fixed.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Sun, 13 Jul 2025 11:13:02 GMT) Full text and rfc822 format available.

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

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: stephen.berman <at> gmx.net, 78987 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Sun, 13 Jul 2025 12:12:20 +0100
Hello,

On Sun 13 Jul 2025 at 10:54am +03, Eli Zaretskii wrote:

>> Cc: 78987 <at> debbugs.gnu.org
>> From: Juri Linkov <juri <at> linkov.net>
>> Date: Sun, 13 Jul 2025 09:58:59 +0300
>>
>> >  (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)))))
>>
>> The original recipe still fails with the same error.
>> Shouldn't 'vc-responsible-backend' be wrapped with
>> 'ignore-errors' in 'dired-vc-deduce-fileset'?
>
> There's no need for ignore-errors; instead, vc-responsible-backend
> should be called with the second argument NO-ERROR non-nil.
>
> The original patch did precisely that, so it looks like some snafu
> when applying the patch; now fixed.

Oh, my fault.  Thank you for the fix.

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Sun, 13 Jul 2025 16:54:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: Eli Zaretskii <eliz <at> gnu.org>, stephen.berman <at> gmx.net, 78987 <at> debbugs.gnu.org
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Sun, 13 Jul 2025 19:51:25 +0300
The first 'C-x v v' works now.  Then I tried the second 'C-x v v'
on the new file, but it fails because I customized
'log-edit-hook' and added 'log-edit-maybe-show-diff' to it:

Debugger entered--Lisp error: (error "Failed (status 128): git --no-pager diff-index --exit-code -p HEAD  -- file")
  signal(error ("Failed (status 128): git --no-pager diff-index --exit-code -p HEAD  -- file"))
  error("Failed (%s): %s" "status 128" "git --no-pager diff-index --exit-code -p HEAD  -- file")
  vc-do-command("*vc-diff*" 1 "git" ("/tmp/dir/file") "--no-pager" "diff-index" "--exit-code" "-p" "HEAD" nil "--")
  vc-git-command("*vc-diff*" 1 ("/tmp/dir/file") "diff-index" "--exit-code" "-p" "HEAD" nil "--")
  vc-git-diff(("/tmp/dir/file") nil nil "*vc-diff*" nil)
  vc-call-backend(Git diff ("/tmp/dir/file") nil nil "*vc-diff*" nil)
  vc-diff-internal(nil (Git ("/tmp/dir/file")) nil nil nil)
  vc-diff(nil not-essential (Git ("/tmp/dir/file")))
  log-edit-diff-fileset()
  log-edit-maybe-show-diff()
  log-edit(vc-finish-logentry t ...
  vc-log-edit(("/tmp/dir/file") ...
  vc-start-logentry(("/tmp/dir/file") nil nil ...
  vc-checkin(("/tmp/dir/file") Git nil nil nil nil nil)
  vc-next-action(nil)
  dired-vc-next-action(nil)
  funcall-interactively(dired-vc-next-action nil)
  command-execute(dired-vc-next-action)

Do you have an idea how to handle an empty repository on the first commit?
Or this needs a separate bug report?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Tue, 15 Jul 2025 09:30:02 GMT) Full text and rfc822 format available.

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

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, stephen.berman <at> gmx.net, 78987 <at> debbugs.gnu.org
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Tue, 15 Jul 2025 10:29:40 +0100
Hello,

On Sun 13 Jul 2025 at 07:51pm +03, Juri Linkov wrote:

> The first 'C-x v v' works now.  Then I tried the second 'C-x v v'
> on the new file, but it fails because I customized
> 'log-edit-hook' and added 'log-edit-maybe-show-diff' to it:
>
> Debugger entered--Lisp error: (error "Failed (status 128): git --no-pager
> diff-index --exit-code -p HEAD -- file")
>   signal(error ("Failed (status 128): git --no-pager diff-index --exit-code -p
> HEAD -- file"))
>   error("Failed (%s): %s" "status 128" "git --no-pager diff-index --exit-code
> -p HEAD -- file")
>   vc-do-command("*vc-diff*" 1 "git" ("/tmp/dir/file") "--no-pager"
> "diff-index" "--exit-code" "-p" "HEAD" nil "--")
>   vc-git-command("*vc-diff*" 1 ("/tmp/dir/file") "diff-index" "--exit-code"
> "-p" "HEAD" nil "--")
>   vc-git-diff(("/tmp/dir/file") nil nil "*vc-diff*" nil)
>   vc-call-backend(Git diff ("/tmp/dir/file") nil nil "*vc-diff*" nil)
>   vc-diff-internal(nil (Git ("/tmp/dir/file")) nil nil nil)
>   vc-diff(nil not-essential (Git ("/tmp/dir/file")))
>   log-edit-diff-fileset()
>   log-edit-maybe-show-diff()
>   log-edit(vc-finish-logentry t ...
>   vc-log-edit(("/tmp/dir/file") ...
>   vc-start-logentry(("/tmp/dir/file") nil nil ...
>   vc-checkin(("/tmp/dir/file") Git nil nil nil nil nil)
>   vc-next-action(nil)
>   dired-vc-next-action(nil)
>   funcall-interactively(dired-vc-next-action nil)
>   command-execute(dired-vc-next-action)
>
> Do you have an idea how to handle an empty repository on the first commit?
> Or this needs a separate bug report?

I think this is a bug in vc-git-diff.  Does this fix it:

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 13696a7a929..afcea8bdda6 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1818,7 +1818,10 @@ vc-git-diff
         ;; Diffing against the empty tree.
         (unless rev1 (setq rev1 "4b825dc642cb6eb9a060e54bf8d69288fbee4904"))
       (setq command "diff-index")
-      (unless rev1 (setq rev1 "HEAD")))
+      (unless rev1
+        (setq rev1 (if (vc-git--empty-db-p)
+                       "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
+                     "HEAD"))))
     (if vc-git-diff-switches
         (apply #'vc-git-command (or buffer "*vc-diff*")
                (if async 'async 1)
--8<---------------cut here---------------end--------------->8---

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Tue, 15 Jul 2025 12:30:04 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: stephen.berman <at> gmx.net, 78987 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Tue, 15 Jul 2025 15:29:10 +0300
> From: Sean Whitton <spwhitton <at> spwhitton.name>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  stephen.berman <at> gmx.net,
>   78987 <at> debbugs.gnu.org
> Date: Tue, 15 Jul 2025 10:29:40 +0100
> 
> > Debugger entered--Lisp error: (error "Failed (status 128): git --no-pager
> > diff-index --exit-code -p HEAD -- file")
> >   signal(error ("Failed (status 128): git --no-pager diff-index --exit-code -p
> > HEAD -- file"))
> >   error("Failed (%s): %s" "status 128" "git --no-pager diff-index --exit-code
> > -p HEAD -- file")
> >   vc-do-command("*vc-diff*" 1 "git" ("/tmp/dir/file") "--no-pager"
> > "diff-index" "--exit-code" "-p" "HEAD" nil "--")
> >   vc-git-command("*vc-diff*" 1 ("/tmp/dir/file") "diff-index" "--exit-code"
> > "-p" "HEAD" nil "--")
> >   vc-git-diff(("/tmp/dir/file") nil nil "*vc-diff*" nil)
> >   vc-call-backend(Git diff ("/tmp/dir/file") nil nil "*vc-diff*" nil)
> >   vc-diff-internal(nil (Git ("/tmp/dir/file")) nil nil nil)
> >   vc-diff(nil not-essential (Git ("/tmp/dir/file")))
> >   log-edit-diff-fileset()
> >   log-edit-maybe-show-diff()
> >   log-edit(vc-finish-logentry t ...
> >   vc-log-edit(("/tmp/dir/file") ...
> >   vc-start-logentry(("/tmp/dir/file") nil nil ...
> >   vc-checkin(("/tmp/dir/file") Git nil nil nil nil nil)
> >   vc-next-action(nil)
> >   dired-vc-next-action(nil)
> >   funcall-interactively(dired-vc-next-action nil)
> >   command-execute(dired-vc-next-action)
> >
> > Do you have an idea how to handle an empty repository on the first commit?
> > Or this needs a separate bug report?
> 
> I think this is a bug in vc-git-diff.  Does this fix it:
> 
> --8<---------------cut here---------------start------------->8---
> diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
> index 13696a7a929..afcea8bdda6 100644
> --- a/lisp/vc/vc-git.el
> +++ b/lisp/vc/vc-git.el
> @@ -1818,7 +1818,10 @@ vc-git-diff
>          ;; Diffing against the empty tree.
>          (unless rev1 (setq rev1 "4b825dc642cb6eb9a060e54bf8d69288fbee4904"))
>        (setq command "diff-index")
> -      (unless rev1 (setq rev1 "HEAD")))
> +      (unless rev1
> +        (setq rev1 (if (vc-git--empty-db-p)
> +                       "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
> +                     "HEAD"))))
>      (if vc-git-diff-switches
>          (apply #'vc-git-command (or buffer "*vc-diff*")
>                 (if async 'async 1)
> --8<---------------cut here---------------end--------------->8---

Can we please have a comment there explaining the rationale for using
this literal SHA1?

And please make it a defconst instead of hard-coding it twice.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Tue, 15 Jul 2025 12:56:02 GMT) Full text and rfc822 format available.

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

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: stephen.berman <at> gmx.net, 78987 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Tue, 15 Jul 2025 13:55:18 +0100
Hello,

On Tue 15 Jul 2025 at 03:29pm +03, Eli Zaretskii wrote:

> Can we please have a comment there explaining the rationale for using
> this literal SHA1?
>
> And please make it a defconst instead of hard-coding it twice.

Yes, both done locally, just wanted to get Juri to test the functional
change.

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Wed, 16 Jul 2025 06:25:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: Eli Zaretskii <eliz <at> gnu.org>, stephen.berman <at> gmx.net, 78987 <at> debbugs.gnu.org
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Wed, 16 Jul 2025 09:20:01 +0300
>> Do you have an idea how to handle an empty repository on the first commit?
>> Or this needs a separate bug report?
>
> I think this is a bug in vc-git-diff.  Does this fix it:
>
> @@ -1818,7 +1818,10 @@ vc-git-diff
> -      (unless rev1 (setq rev1 "HEAD")))
> +      (unless rev1
> +        (setq rev1 (if (vc-git--empty-db-p)
> +                       "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
> +                     "HEAD"))))

Thanks, I confirm it's fixed not only for the reported case,
but generally for all uses of vc-diff in an empty repository.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78987; Package emacs. (Wed, 16 Jul 2025 08:57:01 GMT) Full text and rfc822 format available.

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

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, stephen.berman <at> gmx.net, 78987 <at> debbugs.gnu.org
Subject: Re: bug#78987: 30.1; Unable to create new Git repository in Dired mode
Date: Wed, 16 Jul 2025 09:56:29 +0100
Hello,

Thank you for testing.  Installed the fix.

-- 
Sean Whitton




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 13 Aug 2025 11:24:10 GMT) Full text and rfc822 format available.

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.