@matheusbsbs / matheus-bagliano / commits / 8b30aa5059
Fork 0

git.el: Support for getting diffs from inside the log-edit buffer.

Take advantage of the new log-edit feature that allows to show a diff with C-c C-d while editing the log message. Signed-off-by: Alexandre Julliard <julliard@winehq.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Alexandre Julliard committed Jan 6, 2008 at 12:12 UTC 8b30aa50593b159791fe1478cb5725caaf219d06
1 file changed +12 -2
contrib/emacs/git.el
+12 -2
@@ -1024,7 +1024,9 @@ Return the list of files that haven't been handled."
1024 (setq default-directory dir)
1025 (setq buffer-read-only t)))
1026 (display-buffer buffer)
1027 - (shrink-window-if-larger-than-buffer))
1027 + ; shrink window only if it displays the status buffer
1028 + (when (eq (window-buffer) (current-buffer))
1029 + (shrink-window-if-larger-than-buffer)))
1030
1031 (defun git-diff-file ()
1032 "Diff the marked file(s) against HEAD."
@@ -1097,6 +1099,11 @@ Return the list of files that haven't been handled."
1099 (with-current-buffer log-edit-parent-buffer
1100 (git-get-filenames (git-marked-files-state 'added 'deleted 'modified))))
1101
1102 +(defun git-log-edit-diff ()
1103 + "Run a diff of the current files being committed from a log-edit buffer."
1104 + (with-current-buffer log-edit-parent-buffer
1105 + (git-diff-file)))
1106 +
1107 (defun git-append-sign-off (name email)
1108 "Append a Signed-off-by entry to the current buffer, avoiding duplicates."
1109 (let ((sign-off (format "Signed-off-by: %s <%s>" name email))
@@ -1169,7 +1176,10 @@ Return the list of files that haven't been handled."
1176 (when (re-search-forward "^Date: \\(.*\\)$" nil t)
1177 (setq date (match-string 1)))))
1178 (git-setup-log-buffer buffer author-name author-email subject date))
1172 - (log-edit #'git-do-commit nil #'git-log-edit-files buffer)
1179 + (if (boundp 'log-edit-diff-function)
1180 + (log-edit 'git-do-commit nil '((log-edit-listfun . git-log-edit-files)
1181 + (log-edit-diff-function . git-log-edit-diff)) buffer)
1182 + (log-edit 'git-do-commit nil 'git-log-edit-files buffer))
1183 (setq font-lock-keywords (font-lock-compile-keywords git-log-edit-font-lock-keywords))
1184 (setq buffer-file-coding-system coding-system)
1185 (re-search-forward (regexp-quote (concat git-log-msg-separator "\n")) nil t))))