Subject: Re: bug#42966: 28.0.50; vc-dir: wrong backend

From: Dmitry Gutov <[email-masked]>
Date: Sat, 17 Oct 2020 23:01:09 +0300

On 17.10.2020 09:06, Lars Ingebrigtsen wrote:
> Dmitry Gutov <[email-masked]> writes:
> 
>> On 16.10.2020 18:35, Glenn Morris wrote:
>>> See eghttps://debbugs.gnu.org/3807#21  from 11 years ago.
>>
>> Stefan's suggestion is pretty sensible.
>>
>> Though it'll require a rework of the corresponding VC backend
>> actions. Not sure if it's possible to do in a backward-compatible
>> fashion.
> 
> (The suggestion is to recurse upwards and ask each backend "are you
> responsible for this directory, then?")

Or, more low-level, if we find that every backend follows the pattern of 
aliasing vc-xyz-responsible-p to vc-xyz-root, and calling vc-find-root 
in the latter's implementation, we could opt for creating a backend 
action that returns the "witness" file name (e.g. ".git"), and then 
construct a regexp from all witness file names, and pass it to 
'directory-files' as MATCH. Depending on the cost of certain things, 
this could end up being much faster, both locally and remotely.

> That makes sense, but it's just a performance hack, isn't it?  The
> result should be the same as the less invasive "loop over all the
> backends and collect the most specific one".

Pretty much. Except it should naturally limit the traversal up the 
directory tree, so it feels like a good architecture, not just a "hack".

The backward compatibility headache might not be worth it, though.