Subject: Re: bug#39452: [PATCH] vc-git-state fails for filenames with wildcards

From: Dmitry Gutov <[email-masked]>
Date: Fri, 27 Aug 2021 15:51:51 +0300

On 27.08.2021 09:05, Juri Linkov wrote:
>>> If we've seen one piece of code break here already, then perhaps
>>> reverting and moving to the other (safer, but more invasive) approach is
>>> the right way to go.
>>
>> Fair enough.
>>
>> Pushed the other patch with a couple of small tweaks.
> 
> This broke vc-rename-file that now fails with
> 
>    (error Failed (status 128): git --no-pager mv -f -- :(literal)/tmp/gitrepo/subdir/file1 :(literal)/tmp/gitrepo/subdir/file2)
>    fatal: bad source, source=subdir/:(literal)/tmp/gitrepo/subdir/file1, destination=subdir/:(literal)/tmp/gitrepo/subdir/file2

It was probably broken by the original change, no?

Just not fixed by any of the subsequent repairs.

> Can be fixed with
> 
> diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
> index 02ca022ad4..88e015fc9d 100644
> --- a/lisp/vc/vc-git.el
> +++ b/lisp/vc/vc-git.el
> @@ -1559,7 +1559,7 @@ vc-git-delete-file
>     (vc-git-command nil 0 (vc-git--literal-pathspecs file) "rm" "-f" "--"))
>   
>   (defun vc-git-rename-file (old new)
> -  (vc-git-command nil 0 (vc-git--literal-pathspecs (list old new)) "mv" "-f" "--"))
> +  (vc-git-command nil 0 (list old new) "mv" "-f" "--"))
>   
>   (defun vc-git-mark-resolved (files)
>     (vc-git-command nil 0 (vc-git--literal-pathspecs files) "add"))

Looks like the proper fix, thanks. Feel free to push it right away, if 
you like.

Would be great to add some test, though. vc-tests.el currently doesn't 
exercise vc-rename-file at all.