Subject: bug#13866: [VC] ‘vc-git-root’ is too lax

From: Stefan Monnier <[email-masked]>
Date: Mon, 04 Mar 2013 09:58:33 -0500

> A better definition would be something like this:
> (defun vc-git-root (file)
>   (lexical-let ((root (vc-find-root file ".git")))
>     (and (file-in-directory-p root "objects")
>          root)))

Beside the fact that ~/.git is not the config directory, the above code
has some problems:

vc-git.el uses lexical-binding, so using lexical-let in it is a bad idea.
file-in-directory-p sounds completely wrong here.  You want to use
(file-directory-p (expand-file-name "objects" root)) instead.

And of course you could have used simply (vc-find-root file ".git/objects").

        Stefan