Function: vc-git-branches

vc-git-branches is a byte-compiled function defined in vc-git.el.gz.

Signature

(vc-git-branches)

Documentation

Return the existing branches, as a list of strings.

The car of the list is the current branch.

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc-git.el.gz
(defun vc-git-branches ()
  "Return the existing branches, as a list of strings.
The car of the list is the current branch."
  (with-temp-buffer
    ;; 'git branch' is a porcelain command whose output could change in
    ;; the future.
    (vc-git--call nil t "for-each-ref"
                  "--format=%(HEAD) %(refname:short)" "refs/heads/")
    (goto-char (point-min))
    (let (current-branch branches)
      (while (not (eobp))
	(when (looking-at "^\\([ *]\\) \\(.+\\)$")
	  (if (string-equal (match-string 1) "*")
	      (setq current-branch (match-string 2))
	    (push (match-string 2) branches)))
	(forward-line 1))
      (cons current-branch (nreverse branches)))))