Created
November 29, 2012 15:25
-
-
Save thisirs/4169777 to your computer and use it in GitHub Desktop.
Seeing a diff when writing a commit in magit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; 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