I want an analog of git show $REV / hg diff -c $REV / svn diff -c $REV in Emacs when I know $REV.

Currently I open full history via C-x v L and search for specific revision and then type d or l ((

2 Answers 2


vc-diff-internal doesn't show single changeset but always diff between two revisions.

vc-diff-build-argument-list-internal function used by commands vc-version-diff and vc-root-version-diff will ask for revisions to compare.

log-view-diff-common used to view diff from log view compute previous revision by calling backend for previous revision so we can do the same:

(require 'vc)
(require 'vc-hooks)

(defun my/vc-view-diff-single-rev (rev)
  "Show diff for REV."
  (interactive "sRevision: ")
  (let ((backend (vc-responsible-backend default-directory)))
    (when backend
      (let ((rev-from (vc-call-backend backend 'previous-revision nil rev)))
        (when rev-from
          (vc-diff-internal t (list backend nil) rev-from rev))))))
  • Great! I know each VCS has CLI option to show specific REV, like git show $REV, hg log -p -r $REV, svn log -p -c $REV. Calling previous-revision discloses VC weakness... BTW I looked to the same source code but stopped at necessity to call previous-revision ((
    – gavenkoa
    Jun 4, 2019 at 16:35

Magit solution:

magit-show-commit Show the commit at point. If there is no commit at point or with a prefix argument, prompt for a commit.

In VC internals I can't see direct solution for the problem. vc-git-diff requires fileset, I am unable to get it works:

(vc-git-diff (cadr (vc-deduce-fileset t)) (vc-read-revision "Rev: "))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.