Subject: Re: bug#57777: 28.2; `vc-dir' picks incorrect backend.

From: Mike Woolley <[email-masked]>
Date: Thu, 15 Sep 2022 16:39:54 +0100

I should also mention that I tested changing the code to the following and it fixed the problem:

     (when-let ((dir (expand-file-name
			    (vc-call-backend
                               backend 'responsible-p file))))

Thanks,
Mike

> On 15 Sep 2022, at 15:53, Mike Woolley <[email-masked]> wrote:
> 
> Thanks for looking at this Lars.
> 
> The steps you tried also work correctly for me, so clearly the problem is a bit more specific than I initially thought!
> 
> I stepped through `vc-responsible-backend’ in the debugger when executing `vc-dir’ on one of the directories where I have this problem (my home directory in the following example).
> This bit of code:
> 
>  (vc-call-backend backend 'responsible-p file)
> 
> returns "~/“ for the Git backend, but "/Users/mike/“ for the CVS backend.
> 
> Further down, this next bit of code looks for the longest directory string in an attempt to find the deepest subdirectory:
> 
>   ;; Several roots; we seem to have one vc inside another's
>   ;; directory.  Choose the most specific.
>   (caar (sort dirs (lambda (d1 d2)
>                      (< (length (cdr d2)) (length (cdr d1))))))))
> 
> Which explains why it picks the CVS backend, because "/Users/mike/“ is longer than "~/“ 😊
> 
> So in other words, the missing step from my instructions is the directory has to be under the user’s home directory.
> 
> I would have thought the fix would be either to make `responsible-p’ return the same string or expand the “~” before executing the length comparison above.
> 
> Thanks,
> Mike
> 
>> On 14 Sep 2022, at 15:43, Lars Ingebrigtsen <[email-masked] <mailto:[email-masked]>> wrote:
>> 
>> Lars Ingebrigtsen <[email-masked] <mailto:[email-masked]>> writes:
>> 
>>>> I'm unable to reproduce this problem with Emacs 28.2 (or the current
>>>> trunk).
>>> 
>>> Sorry; I was testing in the wrong checkout -- I'm now rebuilding the
>>> real emacs-28.2 release and will re-test.
>> 
>> I've now redone the tests, but I'm still not able to reproduce the
>> problem.
>