Commit d25fb656 authored by Jonas Bernoulli's avatar Jonas Bernoulli

magit-commit-diff: never give up

Fallback to the same base logic as `magit-diff-while-committing' to
decide what diff to display instead of giving up when we don't know
what diff to display based on `last-command'.

We cannot use that function, because if we did then we might end up
toggling to the "other diff" if the diff buffer already exists.

The "unrecord" and "abort" logic have be moved to the "outside".
parent a57e7c0b
......@@ -339,28 +339,31 @@ depending on the value of option `magit-commit-squash-confirm'."
;;; Pending Diff
(defun magit-commit-diff ()
(-when-let (fn (and git-commit-mode
(cl-case last-command
(apply-partially 'magit-diff-staged nil))
(apply-partially 'magit-diff-working-tree nil))
(when (and git-commit-mode magit-commit-show-diff)
(-when-let (diff-buffer (magit-mode-get-buffer 'magit-diff-mode))
;; This window just started displaying the commit message
;; buffer. Without this that buffer would immediately be
;; replaced with the diff buffer. See #2632.
(unrecord-window-buffer nil diff-buffer))
(condition-case nil
(let ((magit-inhibit-save-previous-winconf 'unset)
(let ((args (car (magit-diff-arguments)))
(magit-inhibit-save-previous-winconf 'unset)
(magit-display-buffer-noselect t)
(inhibit-quit nil))
(message "Diffing changes to be committed (C-g to abort diffing)")
(funcall fn (car (magit-diff-arguments))))
(-if-let (fn (cl-case last-command
(apply-partially 'magit-diff-staged nil))
(apply-partially 'magit-diff-working-tree nil))
(funcall fn args)
(if (magit-anything-staged-p)
(magit-diff-staged nil args)
(magit-diff-while-amending args))))
;; Mention `magit-diff-while-committing' because that's
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment