Function: projectile-dashboard--git-status
projectile-dashboard--git-status is a byte-compiled function defined
in projectile.el.
Signature
(projectile-dashboard--git-status ROOT)
Documentation
Return the git branch and working tree counts for ROOT as a plist.
The branch comes from a single git rev-parse and the counts from a
single git status --porcelain, which rides git's index stat cache and
reports an untracked directory as one entry instead of recursing into
it - that's what keeps this cheap enough to run on a project switch.
The status is scoped to ROOT, since a project can sit below the git root
(see projectile-project-vcs) and the whole repository's counts would
be meaningless for it.
The plist's :vcs-state is ok when both answered, partial when only
the branch could be determined and unavailable when git couldn't
answer at all (not installed, no commits yet, a broken repository).
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
;;;; Dashboard data collection
(defun projectile-dashboard--git-status (root)
"Return the git branch and working tree counts for ROOT as a plist.
The branch comes from a single `git rev-parse' and the counts from a
single `git status --porcelain', which rides git's index stat cache and
reports an untracked directory as one entry instead of recursing into
it - that's what keeps this cheap enough to run on a project switch.
The status is scoped to ROOT, since a project can sit below the git root
\(see `projectile-project-vcs') and the whole repository's counts would
be meaningless for it.
The plist's `:vcs-state' is `ok' when both answered, `partial' when only
the branch could be determined and `unavailable' when git couldn't
answer at all (not installed, no commits yet, a broken repository)."
(if-let* ((branch (projectile--git
root "rev-parse" "--abbrev-ref" "HEAD")))
(let ((status (projectile--git
root "status" "--porcelain" "--untracked-files=normal"
"--" "."))
(modified 0)
(untracked 0))
(dolist (line (and status (split-string status "\n" t)))
(if (string-prefix-p "??" line)
(setq untracked (1+ untracked))
(setq modified (1+ modified))))
(list :vcs-state (if status 'ok 'partial)
;; `--abbrev-ref' prints "HEAD" itself when the head is
;; detached, which would read as a branch named HEAD.
:branch (let ((branch (string-trim branch)))
(if (equal branch "HEAD") "detached HEAD" branch))
:modified modified
:untracked untracked))
(list :vcs-state 'unavailable)))