Function: magit-diff-buffer-file
magit-diff-buffer-file is an autoloaded, interactive and byte-compiled
function defined in magit-diff.el.
Signature
(magit-diff-buffer-file)
Documentation
Show diff for the blob or file visited in the current buffer.
When the buffer visits a blob, then show the respective commit.
When the buffer visits a file, then show the differences between
HEAD and the working tree. In both cases limit the diff to
the file or blob.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-diff.el
;;;###autoload
(defun magit-diff-buffer-file ()
"Show diff for the blob or file visited in the current buffer.
When the buffer visits a blob, then show the respective commit.
When the buffer visits a file, then show the differences between
`HEAD' and the working tree. In both cases limit the diff to
the file or blob."
(interactive)
(require 'magit)
(if-let ((file (magit-file-relative-name)))
(if magit-buffer-revision
(magit-show-commit magit-buffer-revision
(car (magit-show-commit--arguments))
(list file))
(save-buffer)
(let ((line (line-number-at-pos))
(col (current-column)))
(with-current-buffer
(magit-diff-setup-buffer (or (magit-get-current-branch) "HEAD")
nil
(car (magit-diff-arguments))
(list file)
'unstaged
magit-diff-buffer-file-locked)
(magit-diff--goto-file-position file line col))))
(user-error "Buffer isn't visiting a file")))