Function: magit-show-commit

magit-show-commit is an autoloaded, interactive and byte-compiled function defined in magit-diff.el.

Signature

(magit-show-commit REV &optional ARGS FILES MODULE)

Documentation

Visit the revision at point in another buffer.

If there is no revision at point or with a prefix argument prompt for a revision.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-diff.el
;;;###autoload
(defun magit-show-commit (rev &optional args files module)
  "Visit the revision at point in another buffer.
If there is no revision at point or with a prefix argument prompt
for a revision."
  (interactive
    (pcase-let* ((mcommit (magit-section-value-if 'module-commit))
                 (atpoint (or mcommit
                              (magit-thing-at-point 'git-revision t)
                              (magit-branch-or-commit-at-point)))
                 (`(,args ,files) (magit-show-commit--arguments)))
      (list (or (and (not current-prefix-arg) atpoint)
                (magit-read-branch-or-commit "Show commit" atpoint))
            args
            files
            (and mcommit
                 (magit-section-parent-value (magit-current-section))))))
  (require 'magit)
  (let* ((file (magit-file-relative-name))
         (line (and file (line-number-at-pos))))
    (magit-with-toplevel
      (when module
        (setq default-directory
              (expand-file-name (file-name-as-directory module))))
      (unless (magit-commit-oid rev t)
        (user-error "%s cannot be dereferenced as a commit" rev))
      (when file
        (save-buffer))
      (let ((buf (magit-revision-setup-buffer rev args files)))
        (when file
          (let ((line (magit-diff-visit--offset line file "-R" rev))
                (col (current-column)))
            (with-current-buffer buf
              (magit-diff--goto-file-position file line col))))))))