From: Alexandre Julliard Date: Sun, 17 Feb 2008 18:30:34 GMT Subject: Re: [PATCH 01/03] Add helper function for branch tag and commitish to git.el Message-ID: <87wsp34er9.fsf@wine.dyndns.org> In-Reply-To: <87ejbcu2gb.dlv_-_@maison.homelinux.org> Rémi Vanicat 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 julliard@winehq.org