Subject: Re: [PATCH 01/03] Add helper function for branch tag and commitish to git.el

From: Alexandre Julliard <[email-masked]>
Date: Sun, 17 Feb 2008 19:30:34 +0100

Rémi Vanicat <[email-masked]> writes:

> +(defun git-list-branches (&optional all)
> +  "Return an alist of available branches
> +if all is non-nil, return all branch, otherwise only local one
> +cdr of assoc is non-nil for the current branch
> +nil otherwise"
> +  (let ((branches ()))
> +    (with-temp-buffer
> +      (if all
> +	  (git-run-command-buffer (current-buffer) "branch" "-a")
> +	  (git-run-command-buffer (current-buffer) "branch"))
> +      (goto-char (point-min))
> +      (while (re-search-forward "^\\([ *]\\) \\([^\n]*\\)$" () t)
> +	(push (cons (match-string 2)
> +		    (string= (match-string 1) "*"))
> +	      branches)))
> +    (nreverse branches)))

git-run-command-buffer isn't really what you want to use here, look at
how other functions that use a temp-buffer do it. Also that alist thing
is ugly, there are better ways of finding the current branch if we need
it. Besides, you probably want to use git-for-each-ref instead of
git-branch, git-branch is a bit too porcelainish IMO.

-- 
Alexandre Julliard
[email-masked]