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

From: Aleksandr Vityazev <[email-masked]>
Date: Wed, 17 Jan 2024 13:56:08 +0300

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.

>  (defun diff--filter-substring (str)
>    (when diff-font-lock-prettify
>
>
> (Eli, would this be suitable for emacs-29?)
>

-- 
Best regards,
Aleksandr Vityazev