Commit 5580e034 authored by Jonas Bernoulli's avatar Jonas Bernoulli

magit-blame--format-string-1: Improve uncommitted lines fallback

parent 6afd12e4
......@@ -632,38 +632,40 @@ modes is toggled, then this mode also gets toggled automatically.
string))
(defun magit-blame--format-string-1 (rev revinfo format face)
(if (equal rev "0000000000000000000000000000000000000000")
(propertize (concat "Not Yet Committed"
(if (string-suffix-p "\n" format) "\n" ""))
'face face)
(let ((str (magit--format-spec
(propertize format 'face face)
(cl-flet* ((p0 (s f)
(propertize s 'face (if face
(if (listp face)
face
(list f face))
f)))
(p1 (k f)
(p0 (cdr (assoc k revinfo)) f))
(p2 (k1 k2 f)
(p0 (magit-blame--format-time-string
(cdr (assoc k1 revinfo))
(cdr (assoc k2 revinfo)))
f)))
`((?H . ,(p0 rev 'magit-blame-hash))
(?s . ,(p1 "summary" 'magit-blame-summary))
(?a . ,(p1 "author" 'magit-blame-name))
(?c . ,(p1 "committer" 'magit-blame-name))
(?A . ,(p2 "author-time" "author-tz" 'magit-blame-date))
(?C . ,(p2 "committer-time" "committer-tz" 'magit-blame-date))
(?f . ""))))))
(-if-let (width (and (string-suffix-p "%f" format)
(magit-blame--style-get 'margin-width)))
(concat str
(propertize (make-string (max 0 (- width (length str))) ?\s)
'face face))
str))))
(let ((str
(if (equal rev "0000000000000000000000000000000000000000")
(propertize (concat (if (string-prefix-p "\s" format) "\s" "")
"Not Yet Committed"
(if (string-suffix-p "\n" format) "\n" ""))
'face face)
(magit--format-spec
(propertize format 'face face)
(cl-flet* ((p0 (s f)
(propertize s 'face (if face
(if (listp face)
face
(list f face))
f)))
(p1 (k f)
(p0 (cdr (assoc k revinfo)) f))
(p2 (k1 k2 f)
(p0 (magit-blame--format-time-string
(cdr (assoc k1 revinfo))
(cdr (assoc k2 revinfo)))
f)))
`((?H . ,(p0 rev 'magit-blame-hash))
(?s . ,(p1 "summary" 'magit-blame-summary))
(?a . ,(p1 "author" 'magit-blame-name))
(?c . ,(p1 "committer" 'magit-blame-name))
(?A . ,(p2 "author-time" "author-tz" 'magit-blame-date))
(?C . ,(p2 "committer-time" "committer-tz" 'magit-blame-date))
(?f . "")))))))
(-if-let (width (and (string-suffix-p "%f" format)
(magit-blame--style-get 'margin-width)))
(concat str
(propertize (make-string (max 0 (- width (length str))) ?\s)
'face face))
str)))
(defun magit-blame--format-separator ()
(propertize
......
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