Skip to content

Instantly share code, notes, and snippets.

@thisirs
Created November 29, 2012 15:25
Show Gist options
  • Save thisirs/4169777 to your computer and use it in GitHub Desktop.
Save thisirs/4169777 to your computer and use it in GitHub Desktop.
Seeing a diff when writing a commit in magit
;; look at diff when writing a commit message
(defun magit-log-show-diff ()
(interactive)
(let ((content (magit-cmd-output "git" '("diff" "--cached" "-U5"))))
(with-current-buffer (get-buffer-create "*vc-diff*")
(let ((buffer-undo-list t)
(inhibit-read-only t))
(erase-buffer)
(insert content))
(diff-mode)
(setq buffer-read-only t)
(display-buffer (current-buffer)))))
(define-key magit-log-edit-mode-map (kbd "C-c C-d") 'magit-log-show-diff)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment