GNU bug report logs -
#79999
31.0.50; vc-dir-clean-files fails to unlist deleted files
Previous Next
Reported by: "Paul D. Nelson" <ultrono <at> gmail.com>
Date: Sat, 13 Dec 2025 13:22:02 UTC
Severity: normal
Found in version 31.0.50
Fixed in version 31.1
Done: Sean Whitton <spwhitton <at> spwhitton.name>
To reply to this bug, email your comments to 79999 AT debbugs.gnu.org.
There is no need to reopen the bug first.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79999; Package
emacs.
(Sat, 13 Dec 2025 13:22:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
"Paul D. Nelson" <ultrono <at> gmail.com>:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org.
(Sat, 13 Dec 2025 13:22:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
To reproduce:
- Create an untracked file in a git repo (e.g., test.txt in Emacs/src).
- C-x p v (vc-dir), navigate to the file, hit d (vc-dir-clean-files).
Expect the file to disappear from the listing. Observe that it does not
(and pressing x, or doing revert-buffer, still doesn't hide it).
The issue seems to be that vc-git-dir-status-goto-stage calls "git add
--refresh" on files that may be untracked, in which case it returns an
error status 128. That error was previously ignored, but is now fatal
due to the (vc-run-delayed-success 1 ...) wrapper introduced in
0391b3f94ecf57536c068611c12ae776d7382962. As a result,
vc-dir-refresh-files never reaches the ewoc-filter that drops the files
from the listing.
I experimented with filtering to tracked files, like so:
--8<---------------cut here---------------start------------->8---
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index ad70202724e..e79c85b527d 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -716,6 +716,12 @@ vc-git-after-dir-status-stage
;; Follows vc-exec-after.
(declare-function vc-set-async-update "vc-dispatcher" (process-buffer))
+(defun vc-git--tracked-files (files)
+ "Return the subset of FILES that Git currently tracks."
+ (with-temp-buffer
+ (when (zerop (apply #'vc-git--call nil t "ls-files" "-z" "--" files))
+ (split-string (buffer-string) "\0" t))))
+
(defun vc-git-dir-status-goto-stage (git-state)
;; TODO: Look into reimplementing this using `git status --porcelain=v2'.
(let ((files (vc-git-dir-status-state->files git-state)))
@@ -723,7 +729,9 @@ vc-git-dir-status-goto-stage
(pcase (vc-git-dir-status-state->stage git-state)
('update-index
(if files
- (vc-git-command (current-buffer) 'async files "add" "--refresh" "--")
+ (when-let* ((tracked (vc-git--tracked-files files)))
+ (vc-git-command (current-buffer) 'async tracked
+ "add" "--refresh" "--"))
(vc-git-command (current-buffer) 'async nil
"update-index" "--refresh")))
('ls-files-added
--8<---------------cut here---------------end--------------->8---
This sidesteps the issue, but violates the asynchronous contract of
'vc-dir-status-files' and does not propagate errors.
Using a recent master (fcbb9066bea0f1fb3a2185b8257e54083e6e39c9) and Git
version 2.50.1.
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79999; Package
emacs.
(Sat, 13 Dec 2025 14:15:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 79999 <at> debbugs.gnu.org (full text, mbox):
Hello,
On Sat 13 Dec 2025 at 02:20pm +01, Paul D. Nelson wrote:
> To reproduce:
>
> - Create an untracked file in a git repo (e.g., test.txt in Emacs/src).
> - C-x p v (vc-dir), navigate to the file, hit d (vc-dir-clean-files).
>
> Expect the file to disappear from the listing. Observe that it does not
> (and pressing x, or doing revert-buffer, still doesn't hide it).
>
> The issue seems to be that vc-git-dir-status-goto-stage calls "git add
> --refresh" on files that may be untracked, in which case it returns an
> error status 128. That error was previously ignored, but is now fatal
> due to the (vc-run-delayed-success 1 ...) wrapper introduced in
> 0391b3f94ecf57536c068611c12ae776d7382962. As a result,
> vc-dir-refresh-files never reaches the ewoc-filter that drops the files
> from the listing.
I have been seeing a similar problem but didn't have a reproducer; thank
you for tracking it down.
I think the fix is just to accept exit 128 from that particular command
(though I'm not sure why we run git-add at all, instead of passing FILES
to git-update-index).
I've implemented that; let me know if you can still see the problem.
--
Sean Whitton
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79999; Package
emacs.
(Sat, 13 Dec 2025 15:09:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 79999 <at> debbugs.gnu.org (full text, mbox):
> I think the fix is just to accept exit 128 from that particular command
> (though I'm not sure why we run git-add at all, instead of passing FILES
> to git-update-index).
Thanks, this indeed addresses the problem. The one thing I worried
about with that approach is that if 'git add --refresh' is called with
some mixture of untracked and tracked files, then it will error on the
untracked ones and fail to refresh the index stats for the tracked ones.
I don't have a clear enough global picture of vc-dir to see exactly what
this might spoil, and as you say, perhaps git-update-index would work
better here anyway.
Reply sent
to
Sean Whitton <spwhitton <at> spwhitton.name>:
You have taken responsibility.
(Sun, 14 Dec 2025 10:44:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
"Paul D. Nelson" <ultrono <at> gmail.com>:
bug acknowledged by developer.
(Sun, 14 Dec 2025 10:44:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 79999-done <at> debbugs.gnu.org (full text, mbox):
Version: 31.1
Hello,
On Sat 13 Dec 2025 at 04:08pm +01, Paul D. Nelson wrote:
>> I think the fix is just to accept exit 128 from that particular command
>> (though I'm not sure why we run git-add at all, instead of passing FILES
>> to git-update-index).
>
> Thanks, this indeed addresses the problem. The one thing I worried
> about with that approach is that if 'git add --refresh' is called with
> some mixture of untracked and tracked files, then it will error on the
> untracked ones and fail to refresh the index stats for the tracked ones.
> I don't have a clear enough global picture of vc-dir to see exactly what
> this might spoil, and as you say, perhaps git-update-index would work
> better here anyway.
Well, we have been ignoring the exit status for eons and people haven't
noticed any inconsistencies, so overall I'm not too worried.
There is an option --ignore-errors we could consider passing to git-add.
--
Sean Whitton
This bug report was last modified 3 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.