branch: elpa/git-commit commit 87fe66662a1068239e7eafdf26fc0d3ef310a4e7 Author: Kyle Meyer <k...@kyleam.com> Commit: Kyle Meyer <k...@kyleam.com>
magit-diff-working-tree: Change diff type to committed magit-diff-range with a single revision and magit-diff-working-tree both show a diff between the revision and the working tree. Whether magit-reverse aborted in these buffers used to be determined by whether the specified revision resolved to HEAD. If so, magit-reverse aborted with "Cannot reverse unstaged changes". magit-reverse aborting here wasn't entirely right because a diff of HEAD versus the working tree may contain staged changes too. e94b6ebf (Record diff-type in magit-diff-mode buffers, 2023-03-18) moved magit-diff-range and magit-diff-working-tree in different directions. With that change, magit-diff-range with any revision, including HEAD, allows reversing. On the other hand, magit-diff-working-tree with any revision forbids reversing. Update magit-diff-working-tree to pass `committed' instead of `unstaged' for the diff type. As a description, `committed' is a bit off (the diff can include a mix of unstaged, staged, and committed changes), but it allows reversing and matches what magit-diff-range does. For a diff of any revision against the working tree, magit-apply is bound to fail. Before e94b6ebf, magit-apply used to abort when the diff was between _HEAD_ and the working tree. After e94b6ebf and this change, magit-apply leaves the failure to git-apply. To abort early, we could mark working tree diffs with a distinct diff type, but leaving the failure to apply time is good enough, at least for now. Closes #5090. --- docs/RelNotes/4.0.0.org | 3 +++ lisp/magit-diff.el | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/RelNotes/4.0.0.org b/docs/RelNotes/4.0.0.org index 30e8c8caae..682e81e994 100644 --- a/docs/RelNotes/4.0.0.org +++ b/docs/RelNotes/4.0.0.org @@ -171,6 +171,9 @@ - Improve the diff shown while committing. #3246 +- ~magit-reverse~ is now permitted in diff buffers between HEAD and + the working tree. e94b6ebfdb #5090 + - Register a ~bookmark-handler-type~ for our handler. adf5848ea7 - Added new option ~magit-log-merged-commit-count~. #4711 diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el index 5ad87868f7..5aeba13c87 100644 --- a/lisp/magit-diff.el +++ b/lisp/magit-diff.el @@ -1235,7 +1235,7 @@ a commit read from the minibuffer." (cons (and current-prefix-arg (magit-read-branch-or-commit "Diff working tree and commit")) (magit-diff-arguments))) - (magit-diff-setup-buffer (or rev "HEAD") nil args files 'unstaged)) + (magit-diff-setup-buffer (or rev "HEAD") nil args files 'committed)) ;;;###autoload (defun magit-diff-staged (&optional rev args files)