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

From: Lars Ingebrigtsen <[email-masked]>
Date: Fri, 16 Oct 2020 10:55:54 +0200

Sam Steingold <[email-masked]> writes:

> My home directory is under `git` and `~/.gitignore` contains `/src` so
> that directories under `~/src` can be handled separately, under
> different repos.
>
> `~/src/cl/clocc` is a managed by mercurial and files there are identified
> by Emacs as such, as indicated in the mode line as `Hg:1234567`.
>
> However, when I do `C-x v d` in a buffer visiting
> `~/src/cl/clocc/src/port/proc.lisp`, I get a prompt
>
> VC status for directory: ~/src/cl/clocc/
>
> (note the _correct_ default mercurial root directory!) and hit RET, I
> get the `*vc-dr*` buffer with
>
> VC backend : Git
> Working dir: ~/src/cl/clocc/
> Branch     : master
> Remote     : [email-masked]:sam-s/home.git
> Stash      : Nothing stashed

I don't think the .gitignore helps much here -- Emacs doesn't look that
hard at the various backend's ignore capabilities.

But:

      (catch 'found
	;; First try: find a responsible backend.  If this is for registration,
	;; it must be a backend under which FILE is not yet registered.
	(dolist (backend vc-handled-backends)
	  (and (vc-call-backend backend 'responsible-p file)
	       (throw 'found backend))))

This just goes through the backends and the first one that happens to be
able to say "yes" wins.  Shouldn't this instead go through all the
backends, and if more than one says "yes", then choose the one with the
most specific path?

Looking at the code, that shouldn't be too hard to implement, because it
seems like responsible-p returns the root path? 

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no