Commit 74362bf1 authored by Jonas Bernoulli's avatar Jonas Bernoulli

magit-insert-branch-1: replace BRANCHES argument with UREF

Instead of checking whether UPSTREAM is one of the local branches,
listed in BRANCHES, check whether UREF begins with "refs/heads/".

The value of UREF can be determined using the call to "git branch",
while providing the value of BRANCHES made additional calls to git
necessary.
parent f9e052f8
...@@ -419,18 +419,17 @@ line is inserted at all." ...@@ -419,18 +419,17 @@ line is inserted at all."
"Insert sections showing all local branches." "Insert sections showing all local branches."
(magit-insert-section (local nil) (magit-insert-section (local nil)
(magit-insert-heading "Branches:") (magit-insert-heading "Branches:")
(let ((branches (magit-list-local-branch-names))) (dolist (line (magit-git-lines "branch" "--format=\
(dolist (line (magit-git-lines "branch" "--format=\
%(HEAD)%00%(refname:short)%00%(objectname:short)%00%(subject)%00\ %(HEAD)%00%(refname:short)%00%(objectname:short)%00%(subject)%00\
%(upstream:short)%00%(upstream:track,nobracket)" %(upstream:short)%00%(upstream)%00%(upstream:track,nobracket)"
(cadr magit-refresh-args))) (cadr magit-refresh-args)))
(pcase-let ((`(,head ,branch ,hash ,message (pcase-let ((`(,head ,branch ,hash ,message
,upstream ,utrack) ,upstream ,uref ,utrack)
(-replace "" nil (split-string line "\0")))) (-replace "" nil (split-string line "\0"))))
(magit-insert-branch (magit-insert-branch
(and (not (string-prefix-p "(HEAD detached" branch)) branch) (and (not (string-prefix-p "(HEAD detached" branch)) branch)
magit-refs-local-branch-format (and (equal head "*") branch) branches magit-refs-local-branch-format (and (equal head "*") branch)
'magit-branch-local hash message upstream utrack)))) 'magit-branch-local hash message upstream uref utrack)))
(insert ?\n) (insert ?\n)
(magit-make-margin-overlay nil t))) (magit-make-margin-overlay nil t)))
...@@ -443,18 +442,17 @@ line is inserted at all." ...@@ -443,18 +442,17 @@ line is inserted at all."
(push (magit-get "remote" remote "pushurl"))) (push (magit-get "remote" remote "pushurl")))
(format "%s (%s):" (capitalize remote) (format "%s (%s):" (capitalize remote)
(concat pull (and pull push ", ") push)))) (concat pull (and pull push ", ") push))))
(let ((branches (magit-list-local-branch-names))) (dolist (line (magit-git-lines "branch" "-r" "--format=\
(dolist (line (magit-git-lines "branch" "-r" "--format=\
%(symref:short)%00%(refname:short)%00%(objectname:short)%00%(subject)" %(symref:short)%00%(refname:short)%00%(objectname:short)%00%(subject)"
"--list" (concat remote "/*") "--list" (concat remote "/*")
(cadr magit-refresh-args))) (cadr magit-refresh-args)))
(pcase-let ((`(,symref ,branch ,hash ,message) (pcase-let ((`(,symref ,branch ,hash ,message)
(-replace "" nil (split-string line "\0")))) (-replace "" nil (split-string line "\0"))))
(if symref (if symref
(magit-insert-symref branch symref 'magit-branch-remote) (magit-insert-symref branch symref 'magit-branch-remote)
(magit-insert-branch (magit-insert-branch
branch magit-refs-remote-branch-format nil branches branch magit-refs-remote-branch-format nil
'magit-branch-remote hash message))))) 'magit-branch-remote hash message))))
(insert ?\n) (insert ?\n)
(magit-make-margin-overlay nil t)))) (magit-make-margin-overlay nil t))))
...@@ -469,8 +467,8 @@ line is inserted at all." ...@@ -469,8 +467,8 @@ line is inserted at all."
(apply #'magit-insert-branch-1 it nil format args)))) (apply #'magit-insert-branch-1 it nil format args))))
(defun magit-insert-branch-1 (defun magit-insert-branch-1
(section branch format current branches face (section branch format current face &optional hash message
&optional hash message upstream utrack) upstream uref utrack)
"For internal use, don't add to a hook." "For internal use, don't add to a hook."
(let* ((focus (car magit-refresh-args)) (let* ((focus (car magit-refresh-args))
(head (or focus "HEAD")) (head (or focus "HEAD"))
...@@ -483,7 +481,7 @@ line is inserted at all." ...@@ -483,7 +481,7 @@ line is inserted at all."
(propertize "#" 'face 'magit-tag))))) (propertize "#" 'face 'magit-tag)))))
(when upstream (when upstream
(setq upstream (propertize upstream 'face (setq upstream (propertize upstream 'face
(if (member upstream branches) (if (string-prefix-p "refs/heads/" uref)
'magit-branch-local 'magit-branch-local
'magit-branch-remote)))) 'magit-branch-remote))))
(magit-insert-heading (magit-insert-heading
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment