@matheusbsbs / matheus-bagliano / commits / 9f85fb324d
Fork 0

Handle uncommitted changes and cache descriptions

Signed-off-by: David Kågedal <davidk@lysator.liu.se> Signed-off-by: Junio C Hamano <junkio@cox.net>

David Kågedal committed Feb 9, 2007 at 09:20 UTC 9f85fb324dc21b595a77313936b39930437209e7
1 file changed +20 -6
contrib/emacs/git-blame.el
+20 -6
@@ -187,8 +187,10 @@
187 (res-line (string-to-number (match-string 3)))
188 (num-lines (string-to-number (match-string 4))))
189 (setq git-blame-current
190 - (git-blame-new-commit
191 - hash src-line res-line num-lines)))
190 + (if (string= hash "0000000000000000000000000000000000000000")
191 + nil
192 + (git-blame-new-commit
193 + hash src-line res-line num-lines))))
194 (delete-region (point) (match-end 0))
195 t)
196 ((looking-at "filename \\(.+\\)\n")
@@ -220,6 +222,7 @@
222 (unless color
223 (setq color git-blame-ancient-color))
224 (setq info (list hash src-line res-line num-lines
225 + (git-describe-commit hash)
226 (cons 'color color))))
227 (puthash hash info git-blame-cache))
228 (goto-line res-line)
@@ -233,7 +236,8 @@
236 (overlay-put ovl 'git-blame info)
237 (overlay-put ovl 'help-echo hash)
238 (overlay-put ovl 'face (list :background
236 - (cdr (assq 'color (cddddr info)))))
239 + (cdr (assq 'color (nthcdr 5 info)))))
240 + ;; the point-entered property doesn't seem to work in overlays
241 ;;(overlay-put ovl 'point-entered
242 ;; `(lambda (x y) (git-blame-identify ,hash)))
243 (let ((modified (buffer-modified-p)))
@@ -253,11 +257,21 @@
257 (car info)
258 (error "No commit info"))))
259
260 +(defun git-describe-commit (hash)
261 + (with-temp-buffer
262 + (call-process "git" nil t nil
263 + "log" "-1" "--pretty=oneline"
264 + hash)
265 + (buffer-substring (point-min) (1- (point-max)))))
266 +
267 +(defvar git-blame-last-identification nil)
268 +(make-variable-buffer-local 'git-blame-last-identification)
269 (defun git-blame-identify (&optional hash)
270 (interactive)
258 - (shell-command
259 - (format "git log -1 --pretty=oneline %s" (or hash
260 - (git-blame-current-commit)))))
271 + (let ((info (gethash (or hash (git-blame-current-commit)) git-blame-cache)))
272 + (when (and info (not (eq info git-blame-last-identification)))
273 + (message "%s" (nth 4 info))
274 + (setq git-blame-last-identification info))))
275
276 (provide 'git-blame)
277