Merge branch 'fancy-log-output'.
This commit is contained in:
commit
bf42bf872a
1 changed files with 122 additions and 47 deletions
165
magit.el
165
magit.el
|
@ -175,6 +175,27 @@ Many Magit faces inherit from this one by default."
|
||||||
"Face for lines in a diff that have been deleted."
|
"Face for lines in a diff that have been deleted."
|
||||||
:group 'magit)
|
:group 'magit)
|
||||||
|
|
||||||
|
(defface magit-log-graph
|
||||||
|
'((((class color) (background light))
|
||||||
|
:foreground "grey11")
|
||||||
|
(((class color) (background dark))
|
||||||
|
:foreground "grey30"))
|
||||||
|
"Face for the graph element of the log output."
|
||||||
|
:group 'magit)
|
||||||
|
|
||||||
|
(defface magit-log-sha1
|
||||||
|
'((((class color) (background light))
|
||||||
|
:foreground "firebrick")
|
||||||
|
(((class color) (background dark))
|
||||||
|
:foreground "tomato"))
|
||||||
|
"Face for the sha1 element of the log output."
|
||||||
|
:group 'magit)
|
||||||
|
|
||||||
|
(defface magit-log-message
|
||||||
|
'((t))
|
||||||
|
"Face for the message element of the log output."
|
||||||
|
:group 'magit)
|
||||||
|
|
||||||
(defface magit-item-highlight
|
(defface magit-item-highlight
|
||||||
'((((class color) (background light))
|
'((((class color) (background light))
|
||||||
:background "gray95")
|
:background "gray95")
|
||||||
|
@ -199,12 +220,28 @@ Many Magit faces inherit from this one by default."
|
||||||
"Face for git tag labels shown in log buffer."
|
"Face for git tag labels shown in log buffer."
|
||||||
:group 'magit)
|
:group 'magit)
|
||||||
|
|
||||||
(defface magit-log-head-label
|
(defface magit-log-head-label-remote
|
||||||
'((((class color) (background light))
|
'((((class color) (background light))
|
||||||
:background "spring green")
|
:box t
|
||||||
|
:background "Grey85"
|
||||||
|
:foreground "OliveDrab4")
|
||||||
(((class color) (background dark))
|
(((class color) (background dark))
|
||||||
:background "DarkGreen"))
|
:box t
|
||||||
"Face for branch head labels shown in log buffer."
|
:background "Grey11"
|
||||||
|
:foreground "DarkSeaGreen2"))
|
||||||
|
"Face for remote branch head labels shown in log buffer."
|
||||||
|
:group 'magit)
|
||||||
|
|
||||||
|
(defface magit-log-head-label-tags
|
||||||
|
'((((class color) (background light))
|
||||||
|
:box t
|
||||||
|
:background "Grey85"
|
||||||
|
:foreground "VioletRed1")
|
||||||
|
(((class color) (background dark))
|
||||||
|
:box t
|
||||||
|
:background "Grey13"
|
||||||
|
:foreground "khaki1"))
|
||||||
|
"Face for tag labels shown in log buffer."
|
||||||
:group 'magit)
|
:group 'magit)
|
||||||
|
|
||||||
(defvar magit-completing-read 'completing-read
|
(defvar magit-completing-read 'completing-read
|
||||||
|
@ -214,6 +251,18 @@ Many Magit faces inherit from this one by default."
|
||||||
"When non-nil magit will only list an untracked directory, not
|
"When non-nil magit will only list an untracked directory, not
|
||||||
its contents.")
|
its contents.")
|
||||||
|
|
||||||
|
(defface magit-log-head-label-local
|
||||||
|
'((((class color) (background light))
|
||||||
|
:box t
|
||||||
|
:background "Grey85"
|
||||||
|
:foreground "LightSkyBlue4")
|
||||||
|
(((class color) (background dark))
|
||||||
|
:box t
|
||||||
|
:background "Grey13"
|
||||||
|
:foreground "LightSkyBlue1"))
|
||||||
|
"Face for local branch head labels shown in log buffer."
|
||||||
|
:group 'magit)
|
||||||
|
|
||||||
;;; Macros
|
;;; Macros
|
||||||
|
|
||||||
(defmacro magit-with-refresh (&rest body)
|
(defmacro magit-with-refresh (&rest body)
|
||||||
|
@ -1842,50 +1891,77 @@ Please see the manual for a complete description of Magit.
|
||||||
|
|
||||||
;;; Logs and Commits
|
;;; Logs and Commits
|
||||||
|
|
||||||
(defun magit-parse-log-ref (refname)
|
(defvar magit-log-oneline-re
|
||||||
"Return shortened and propertized version of full REFNAME, like
|
(concat
|
||||||
\"refs/remotes/origin/master\"."
|
"^\\([_\\*|/ ]+\\)" ; graph (1)
|
||||||
(let ((face 'magit-log-head-label))
|
"\\(?:"
|
||||||
(cond ((string-match "^\\(tag: +\\)?refs/tags/\\(.+\\)" refname)
|
"\\([0-9a-fA-F]\\{40\\}\\) " ; sha1 (2)
|
||||||
(setq refname (match-string 2 refname)
|
"\\(?:\\((.+?)\\) \\)?" ; refs (3)
|
||||||
face 'magit-log-tag-label))
|
"\\(.*\\)" ; msg (4)
|
||||||
((string-match "^refs/remotes/\\(.+\\)" refname)
|
"\\)?$")
|
||||||
(setq refname (match-string 1 refname)))
|
"Regexp used to extract elements of git log output with
|
||||||
((string-match "[^/]+$" refname)
|
--pretty=oneline.")
|
||||||
(setq refname (match-string 0 refname))))
|
|
||||||
(propertize refname 'face face)))
|
|
||||||
|
|
||||||
(defun magit-parse-log-refs (refstring)
|
(defvar magit-present-log-line-function 'magit-present-log-line
|
||||||
"Parse REFSTRING annotation from `git log --decorate'
|
"The function to use when generating a log line. It takes four
|
||||||
output (for example: \"refs/remotes/origin/master,
|
args: CHART, SHA1, REFS and MESSAGE. The function must return a
|
||||||
refs/heads/master\") and return prettified string for displaying
|
string which will represent the log line.")
|
||||||
in log buffer."
|
|
||||||
(mapconcat 'identity
|
(defun magit-present-log-line (graph sha1 refs message)
|
||||||
(mapcar 'magit-parse-log-ref
|
"The default log line generator."
|
||||||
(remove-if (lambda (refname)
|
(let* ((ref-re "\\(?:tag: \\)?refs/\\(tags\\|remotes\\|heads\\)/\\(.+\\)")
|
||||||
(string-match "/HEAD$" refname))
|
(string-refs
|
||||||
(reverse (split-string refstring ", *" t))))
|
(when refs
|
||||||
" - "))
|
(concat (mapconcat
|
||||||
|
(lambda (r)
|
||||||
|
(propertize
|
||||||
|
(if (string-match ref-re r)
|
||||||
|
(match-string 2 r)
|
||||||
|
r)
|
||||||
|
'face (cond
|
||||||
|
((string= (match-string 1 r) "remotes")
|
||||||
|
'magit-log-head-label-remote)
|
||||||
|
((string= (match-string 1 r) "tags")
|
||||||
|
'magit-log-head-label-tags)
|
||||||
|
((string= (match-string 1 r) "heads")
|
||||||
|
'magit-log-head-label-local))))
|
||||||
|
refs
|
||||||
|
" ")
|
||||||
|
" "))))
|
||||||
|
(concat
|
||||||
|
(if sha1
|
||||||
|
(propertize (substring sha1 0 8) 'face 'magit-log-sha1)
|
||||||
|
(insert-char ? 8))
|
||||||
|
" "
|
||||||
|
(propertize graph 'face 'magit-log-graph)
|
||||||
|
string-refs
|
||||||
|
(when message
|
||||||
|
(propertize message 'face 'magit-log-message)))))
|
||||||
|
|
||||||
(defun magit-wash-log-line ()
|
(defun magit-wash-log-line ()
|
||||||
(if (and (search-forward-regexp "[0-9a-fA-F]\\{40\\}" (line-end-position) t)
|
(beginning-of-line)
|
||||||
(goto-char (match-beginning 0))
|
(let ((line-re magit-log-oneline-re))
|
||||||
(not (looking-back "commit ")))
|
(cond
|
||||||
(let ((commit (match-string-no-properties 0)))
|
((looking-at magit-log-oneline-re)
|
||||||
(delete-region (match-beginning 0) (match-end 0))
|
(let ((chart (match-string 1))
|
||||||
(fixup-whitespace)
|
(sha1 (match-string 2))
|
||||||
(goto-char (line-beginning-position))
|
(msg (match-string 4))
|
||||||
(when (search-forward-regexp "^[|*\\/ ]+\\((\\(tag:.+?\\|refs/.+?\\))\\)"
|
(refs (when (match-string 3)
|
||||||
(line-end-position) t)
|
(remove-if (lambda (s)
|
||||||
(let ((refstring (match-string-no-properties 2)))
|
(or (string= s "tag:")
|
||||||
(delete-region (match-beginning 1) (match-end 1))
|
(string= s "HEAD"))) ; as of 1.6.6
|
||||||
(insert (magit-parse-log-refs refstring)))
|
(split-string (match-string 3) "[(), ]" t)))))
|
||||||
(goto-char (line-beginning-position)))
|
(delete-region (point-at-bol) (point-at-eol))
|
||||||
(magit-with-section commit 'commit
|
(insert (funcall magit-present-log-line-function chart sha1 refs msg))
|
||||||
(magit-set-section-info commit)
|
(goto-char (point-at-bol))
|
||||||
(forward-line)))
|
(if sha1
|
||||||
|
(magit-with-section sha1 'commit
|
||||||
|
(magit-set-section-info sha1)
|
||||||
(forward-line))
|
(forward-line))
|
||||||
t)
|
(forward-line))))
|
||||||
|
(t
|
||||||
|
(forward-line)))
|
||||||
|
t))
|
||||||
|
|
||||||
(defun magit-wash-log ()
|
(defun magit-wash-log ()
|
||||||
(let ((magit-old-top-section nil))
|
(let ((magit-old-top-section nil))
|
||||||
|
@ -3362,5 +3438,4 @@ Prefix arg means justify as well."
|
||||||
((diff)
|
((diff)
|
||||||
(magit-interactive-resolve (cadr info)))))
|
(magit-interactive-resolve (cadr info)))))
|
||||||
|
|
||||||
|
|
||||||
(provide 'magit)
|
(provide 'magit)
|
Loading…
Add table
Reference in a new issue