In an Emacs Lisp function, I want to know the VC root of an arbitrary folder (if under source control), the same as something like vc-print-root-log does it. I'm trying to do it from outside the VC file/folder (though creating a temporary buffer to do this would be fine). I currently have a git-only solution through magit - (magit-get-top-dir dir-name)
.
I tried using (vc-deduce-backend)
and the 'root command, but the variables that vc-deduce-backend checks seems to only be set in existing vc mode (e.g. log-view-mode) buffers.
Is there a simple way to get this out of VC?
Looking at your own example of vc-print-root-log
, the following seems to be what you're after:
(require 'vc)
(let ((path "~/.emacs.d/el-get/"))
(vc-call-backend (vc-responsible-backend path) 'root path))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With