Function: vc-backend

vc-backend is a byte-compiled function defined in vc-hooks.el.gz.

Signature

(vc-backend FILE-OR-LIST)

Documentation

Return the version control type of FILE-OR-LIST, nil if it's not registered.

If the argument is a list, the files must all have the same back end.

This function returns cached information. To query the VCS regarding whether FILE-OR-LIST is registered or unregistered, use vc-registered.

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc-hooks.el.gz
(defun vc-backend (file-or-list)
  "Return the version control type of FILE-OR-LIST, nil if it's not registered.
If the argument is a list, the files must all have the same back end.

This function returns cached information.  To query the VCS regarding
whether FILE-OR-LIST is registered or unregistered, use `vc-registered'."
  ;; `file' can be nil in several places (typically due to the use of
  ;; code like (vc-backend buffer-file-name)).
  (cond ((stringp file-or-list)
         ;; Subprocesses (and with them, VC backends) can't run from
         ;; /contents or /actions, which are fictions maintained by
         ;; Emacs that do not exist in the filesystem.
         (if (and (eq system-type 'android)
                  (string-match-p "/\\(content\\|assets\\)[/$]"
                                  (expand-file-name file-or-list)))
             nil
	   (let ((property (vc-file-getprop file-or-list 'vc-backend)))
	     ;; Note that internally, Emacs remembers unregistered
	     ;; files by setting the property to `none'.
	     (cond ((eq property 'none) nil)
		   (property)
		   ;; vc-registered sets the vc-backend property
		   (t (if (vc-registered file-or-list)
			  (vc-file-getprop file-or-list 'vc-backend)
                        nil))))))
	((and file-or-list (listp file-or-list))
	 (vc-backend (car file-or-list)))
	(t
	 nil)))