Subject: Re: bug#52507: [PATCH] Option for vc-delete-file to keep file on disk

From: Ashwin Kafle <[email-masked]>
Date: Wed, 15 Dec 2021 18:26:14 +0000

Juri Linkov <[email-masked]> writes:

> Then another question: why backup is needed at all?
> When the file is not going to be deleted, then
> there is no need to make a backup copy?

There could be deletion or not depending on the value of keep-file.
Maybe the check for that can be made earlier and backup can be skipped
conditionally.  

> The comment before calling `vc-resynch-buffer' says it's to
> make sure the buffer is deleted.  But it seems the buffer
> is already deleted at that point?

No, the buffer is not deleted at that point. I should've changed that
comment too.  vc-resynch-buffer would've deleted that buffer if the
second arg was nil.

>
> Also it looks that your another change is dangerous:
>
>  (defun vc-git-delete-file (file)
> -  (vc-git-command nil 0 (vc-git--literal-pathspec file) "rm" "-f" "--"))
> +  (vc-git-command nil 0 (vc-git--literal-pathspec file) "rm" "-f" "--cached" "--")))
>
> because it deletes the file in the staging area
> that is not used by vc-git, so there is no way
> to commit the deletion using vc commands.

I think this check in vc-delete-file takes care of that

(when (eq state 'edited)
        (error "Please commit or undo your changes before deleting %s" file))

-- 
I'd rather just believe that it's done by little elves running around.