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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rémi Vanicat <vanicat@xxxxxxxxxx> 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@xxxxxxxxxx
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux