Put branch name in text properties.

This commit is contained in:
Phil Jackson 2010-03-30 23:07:09 +01:00
parent b261669efe
commit 1ae36db891

View file

@ -3568,9 +3568,7 @@ Prefix arg means justify as well."
(defun magit--branch-name-from-line (line) (defun magit--branch-name-from-line (line)
"Extract the branch name from one line of 'git branch' output. "Extract the branch name from one line of 'git branch' output.
Will remove the 'remotes/' prefix if it exists." Will remove the 'remotes/' prefix if it exists."
(save-match-data (get-text-property 0 'branch-name line))
(if (string-match " \\([^ ]+\\)$" line)
(match-string 1 line))))
(defun magit--branch-name-at-point () (defun magit--branch-name-at-point ()
"Get the branch name in the line at point." "Get the branch name in the line at point."
@ -3648,7 +3646,7 @@ With prefix force the removal even it it hasn't been merged."
(interactive) (interactive)
(save-selected-window (save-selected-window
(unless (string= (buffer-name) magit-branches-buffer-name) (unless (string= (buffer-name) magit-branches-buffer-name)
(switch-to-buffer-other-window magit-branches-buffer-name)) (switch-to-buffer-other-window magit-branches-buffer-name))
(let ((inhibit-read-only t) (let ((inhibit-read-only t)
(branches (mapcar 'magit--branch-view-details (branches (mapcar 'magit--branch-view-details
(magit-git-lines "branch" "-va")))) (magit-git-lines "branch" "-va"))))
@ -3656,15 +3654,17 @@ With prefix force the removal even it it hasn't been merged."
(insert (insert
(mapconcat (mapconcat
(lambda (b) (lambda (b)
(concat (propertize
(cdr (assoc 'current b)) (concat
(propertize (or (cdr (assoc 'sha1 b)) (cdr (assoc 'current b))
" ") (propertize (or (cdr (assoc 'sha1 b))
'face 'magit-log-sha1) " ")
" " 'face 'magit-log-sha1)
(cdr (assoc 'branch b)) " "
(when (assoc 'other-ref b) (cdr (assoc 'branch b))
(concat " (" (cdr (assoc 'other-ref b)) ")")))) (when (assoc 'other-ref b)
(concat " (" (cdr (assoc 'other-ref b)) ")")))
'branch-name (cdr (assoc 'branch b))))
branches branches
"\n"))) "\n")))