Function: vc-git-state
vc-git-state is a byte-compiled function defined in vc-git.el.gz.
Signature
(vc-git-state FILE)
Documentation
Git-specific version of vc-state.
Source Code
;; Defined in /usr/src/emacs/lisp/vc/vc-git.el.gz
(defun vc-git-state (file)
"Git-specific version of `vc-state'."
;; It can't set `needs-update' or `needs-merge'. The rough
;; equivalent would be that upstream branch for current branch is in
;; fast-forward state i.e. current branch is direct ancestor of
;; corresponding upstream branch, and the file was modified
;; upstream. We'd need to check against the upstream tracking
;; branch for that (an extra process call or two).
(let* ((args
`("status" "--porcelain" "-z"
;; Just to be explicit, it's the default anyway.
"--untracked-files"
,@(when (version<= "1.7.6.3" (vc-git--program-version))
'("--ignored"))
"--"))
(status (apply #'vc-git--run-command-string file args)))
(if (null status)
;; If status is nil, there was an error calling git, likely because
;; the file is not in a git repo.
'unregistered
;; If this code is adapted to parse 'git status' for a directory,
;; note that a renamed file takes up two null values and needs to be
;; treated slightly more carefully.
(vc-git--git-status-to-vc-state
(mapcar (lambda (s)
(substring s 0 2))
(split-string status "\0" t))))))