Subject: bug#68443: 30.0.50; Cannot commit from *vc-diff* if there is a deleted file.

From: Dmitry Gutov <[email-masked]>
Date: Wed, 17 Jan 2024 13:36:53 +0200

On 17/01/2024 12:56, Aleksandr Vityazev wrote:
> On 2024-01-17 06:25, Dmitry Gutov wrote:
> 
>> Hi! Thanks for the report.
>>
>> On 13/01/2024 15:56, Aleksandr Vityazev via Bug reports for GNU Emacs,
>> the Swiss army knife of text editors wrote:
>>> Hi,
>>> Steps to reproduce with emacs -q:
>>> 1. Enter git repository;
>>> 2. vc-delete-file some file;
>>> 3. vc-root-diff;
>>> 4. From *vc-diff* buffer vc-next-action;
>>> 5. In *vc-log* write summary and invoke vc-next-action;
>>> 6. get error (wrong-type-argument stringp nil)
>>> Full backtrace:
>>> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>>>     file-directory-p(nil)
>>>     #f(compiled-function (files comment) #<bytecode
>>> 0x1e31e0a127714b22>)((#(".gitignore" 0 10 (fontified t face
>>> (diff-file-header diff-header))) #("buffer.c" 0 8 (fontified t face
>>> (diff-file-header diff-header))) nil) #("Summary: Delete file.\n" 0
>>> 8 (jit-lock-defer-multiline t face log-edit-header fontified t field
>>> header) 8 9 (jit-lock-defer-multiline t fontified t field header) 9
>>> 21 (jit-lock-defer-multiline t face log-edit-summary fontified t
>>> field header) 21 22 (fontified t)))
>>>     vc-finish-logentry()
>>>     funcall-interactively(vc-finish-logentry)
>>>     log-edit-done()
>>>     funcall-interactively(log-edit-done)
>>>     command-execute(log-edit-done)
>>
>> Try the patch below, seems to work here:
>>
>> diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
>> index 03efe0fdb31..83d580d98dd 100644
>> --- a/lisp/vc/diff-mode.el
>> +++ b/lisp/vc/diff-mode.el
>> @@ -3014,7 +3014,7 @@ diff-vc-deduce-fileset
>>         (goto-char (point-min))
>>         (while (progn (diff-file-next) (not (eobp)))
>>           (push (diff-find-file-name nil t) files)))
>> -    (list backend (nreverse files) nil nil 'patch)))
>> +    (list backend (delete nil (nreverse files)) nil nil 'patch)))
> 
> Yes with this patch the error is no longer present, but the deleted file
> is not displayed in the *log-edit-files* buffer, unlike if you run
> vc-next-action from *vc-dir*. Although this is another bug report.

Right, that's still a remaining problem. diff-find-file-name doesn't 
really want to "find" files that don't exist on disk, so it might need a 
replacement for such cases.

Splitting reports should not be necessary, but we can install the first 
fix separately.