|
|
@ -187,8 +187,10 @@ |
|
|
|
(res-line (string-to-number (match-string 3))) |
|
|
|
(res-line (string-to-number (match-string 3))) |
|
|
|
(num-lines (string-to-number (match-string 4)))) |
|
|
|
(num-lines (string-to-number (match-string 4)))) |
|
|
|
(setq git-blame-current |
|
|
|
(setq git-blame-current |
|
|
|
(git-blame-new-commit |
|
|
|
(if (string= hash "0000000000000000000000000000000000000000") |
|
|
|
hash src-line res-line num-lines))) |
|
|
|
nil |
|
|
|
|
|
|
|
(git-blame-new-commit |
|
|
|
|
|
|
|
hash src-line res-line num-lines)))) |
|
|
|
(delete-region (point) (match-end 0)) |
|
|
|
(delete-region (point) (match-end 0)) |
|
|
|
t) |
|
|
|
t) |
|
|
|
((looking-at "filename \\(.+\\)\n") |
|
|
|
((looking-at "filename \\(.+\\)\n") |
|
|
@ -220,6 +222,7 @@ |
|
|
|
(unless color |
|
|
|
(unless color |
|
|
|
(setq color git-blame-ancient-color)) |
|
|
|
(setq color git-blame-ancient-color)) |
|
|
|
(setq info (list hash src-line res-line num-lines |
|
|
|
(setq info (list hash src-line res-line num-lines |
|
|
|
|
|
|
|
(git-describe-commit hash) |
|
|
|
(cons 'color color)))) |
|
|
|
(cons 'color color)))) |
|
|
|
(puthash hash info git-blame-cache)) |
|
|
|
(puthash hash info git-blame-cache)) |
|
|
|
(goto-line res-line) |
|
|
|
(goto-line res-line) |
|
|
@ -233,7 +236,8 @@ |
|
|
|
(overlay-put ovl 'git-blame info) |
|
|
|
(overlay-put ovl 'git-blame info) |
|
|
|
(overlay-put ovl 'help-echo hash) |
|
|
|
(overlay-put ovl 'help-echo hash) |
|
|
|
(overlay-put ovl 'face (list :background |
|
|
|
(overlay-put ovl 'face (list :background |
|
|
|
(cdr (assq 'color (cddddr info))))) |
|
|
|
(cdr (assq 'color (nthcdr 5 info))))) |
|
|
|
|
|
|
|
;; the point-entered property doesn't seem to work in overlays |
|
|
|
;;(overlay-put ovl 'point-entered |
|
|
|
;;(overlay-put ovl 'point-entered |
|
|
|
;; `(lambda (x y) (git-blame-identify ,hash))) |
|
|
|
;; `(lambda (x y) (git-blame-identify ,hash))) |
|
|
|
(let ((modified (buffer-modified-p))) |
|
|
|
(let ((modified (buffer-modified-p))) |
|
|
@ -253,11 +257,21 @@ |
|
|
|
(car info) |
|
|
|
(car info) |
|
|
|
(error "No commit info")))) |
|
|
|
(error "No commit info")))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun git-describe-commit (hash) |
|
|
|
|
|
|
|
(with-temp-buffer |
|
|
|
|
|
|
|
(call-process "git" nil t nil |
|
|
|
|
|
|
|
"log" "-1" "--pretty=oneline" |
|
|
|
|
|
|
|
hash) |
|
|
|
|
|
|
|
(buffer-substring (point-min) (1- (point-max))))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defvar git-blame-last-identification nil) |
|
|
|
|
|
|
|
(make-variable-buffer-local 'git-blame-last-identification) |
|
|
|
(defun git-blame-identify (&optional hash) |
|
|
|
(defun git-blame-identify (&optional hash) |
|
|
|
(interactive) |
|
|
|
(interactive) |
|
|
|
(shell-command |
|
|
|
(let ((info (gethash (or hash (git-blame-current-commit)) git-blame-cache))) |
|
|
|
(format "git log -1 --pretty=oneline %s" (or hash |
|
|
|
(when (and info (not (eq info git-blame-last-identification))) |
|
|
|
(git-blame-current-commit))))) |
|
|
|
(message "%s" (nth 4 info)) |
|
|
|
|
|
|
|
(setq git-blame-last-identification info)))) |
|
|
|
|
|
|
|
|
|
|
|
(provide 'git-blame) |
|
|
|
(provide 'git-blame) |
|
|
|
|
|
|
|
|
|
|
|