Commit 5e999590 authored by Jonas Bernoulli's avatar Jonas Bernoulli

refs: Hide the remote prefix from branches in remote-specific lists

This is done to preserve some space.  While alignment occasionally
breaks for local branches, it usually broke for many remote branches.

The new option `magit-refs-show-remote-prefix' can be used to revert
this change.
parent 3e4a4575
...@@ -232,6 +232,11 @@ Changes since v2.11.0 ...@@ -232,6 +232,11 @@ Changes since v2.11.0
intendation). Use the new option `magit-diff-adjust-tab-width' to intendation). Use the new option `magit-diff-adjust-tab-width' to
control if and when the tab widths should be adjusted. #2929 control if and when the tab widths should be adjusted. #2929
* In the references buffer the remote part of the branch names are now
hidden in the remote specific lists of branches by default, which is
done to preserves space. The option `magit-refs-show-remote-prefix'
can be used to revert this change.
Fixes since v2.11.0 Fixes since v2.11.0
------------------- -------------------
......
...@@ -73,6 +73,15 @@ To change the value in an existing buffer use the command ...@@ -73,6 +73,15 @@ To change the value in an existing buffer use the command
(put 'magit-refs-show-commit-count 'safe-local-variable 'symbolp) (put 'magit-refs-show-commit-count 'safe-local-variable 'symbolp)
(put 'magit-refs-show-commit-count 'permanent-local t) (put 'magit-refs-show-commit-count 'permanent-local t)
(defcustom magit-refs-show-remote-prefix nil
"Whether to show the remote prefix in lists of remote branches.
This is redundant because the name of the remote is already shown
in the heading preceeding the list of its branches."
:package-version '(magit . "2.12.0")
:group 'magit-refs
:type 'boolean)
(defcustom magit-refs-margin (defcustom magit-refs-margin
(list nil (list nil
(nth 1 magit-log-margin) (nth 1 magit-log-margin)
...@@ -469,12 +478,14 @@ line is inserted at all." ...@@ -469,12 +478,14 @@ line is inserted at all."
(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 branch magit-refs-remote-branch-format nil
'magit-branch-remote hash message)))) 'magit-branch-remote hash message nil nil nil
(and (not magit-refs-show-remote-prefix)
(1+ (length remote)))))))
(insert ?\n) (insert ?\n)
(magit-make-margin-overlay nil t)))) (magit-make-margin-overlay nil t))))
(defun magit-insert-branch (branch format &optional current face hash (defun magit-insert-branch (branch format &optional current face hash
message upstream uref utrack) message upstream uref utrack substring)
"For internal use, don't add to a hook." "For internal use, don't add to a hook."
(unless magit-refs-show-commit-count (unless magit-refs-show-commit-count
(setq format (replace-regexp-in-string "%[0-9]\\([cC]\\)" "%1\\1" format t))) (setq format (replace-regexp-in-string "%[0-9]\\([cC]\\)" "%1\\1" format t)))
...@@ -482,15 +493,15 @@ line is inserted at all." ...@@ -482,15 +493,15 @@ line is inserted at all."
(magit-insert-section it (branch branch t) (magit-insert-section it (branch branch t)
(magit-insert-branch-1 it branch format (magit-insert-branch-1 it branch format
current face hash message current face hash message
upstream uref utrack)) upstream uref utrack substring))
(magit-insert-section it (commit (magit-rev-parse "HEAD") t) (magit-insert-section it (commit (magit-rev-parse "HEAD") t)
(magit-insert-branch-1 it nil format (magit-insert-branch-1 it nil format
current face hash message current face hash message
upstream uref utrack)))) upstream uref utrack substring))))
(defun magit-insert-branch-1 (defun magit-insert-branch-1
(section branch format current face (section branch format current face
&optional hash message upstream uref utrack) &optional hash message upstream uref utrack substring)
"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"))
...@@ -506,6 +517,8 @@ line is inserted at all." ...@@ -506,6 +517,8 @@ line is inserted at all."
(if (string-prefix-p "refs/heads/" uref) (if (string-prefix-p "refs/heads/" uref)
'magit-branch-local 'magit-branch-local
'magit-branch-remote)))) 'magit-branch-remote))))
(when (and substring branch)
(setq branch (substring branch substring)))
(magit-insert-heading (magit-insert-heading
(format-spec (format-spec
format format
......
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