Function: diff-hl-set-reference-rev
diff-hl-set-reference-rev is an interactive and natively compiled
function defined in diff-hl.el.
Signature
(diff-hl-set-reference-rev REV)
Documentation
Set the reference revision globally to REV.
When called interactively, REV read with completion.
When called with a prefix argument, reset the global reference to the most
recent one instead. With two prefix arguments, do the same and discard
every per-project reference created by
`diff-hl-set-reference-rev-in-project`.
The default value chosen using one of methods below:
- In a log view buffer, it uses the revision of current entry.
Call vc-print-log or vc-print-root-log first to open a log
view buffer.
- In a VC annotate buffer, it uses the revision of current line.
- In other situations, it uses the symbol at point.
Notice that this sets the reference revision globally, so in files from
other repositories, diff-hl-mode(var)/diff-hl-mode(fun) will not highlight changes correctly,
until you run diff-hl-reset-reference-rev. To set the reference on a
per-project basis, see `diff-hl-set-reference-rev-in-project`.
Also notice that this will disable diff-hl-amend-mode in
buffers that enables it, since diff-hl-amend-mode overrides its
effect.
Key Bindings
This command is not in any keymaps.
Source Code
;; Defined in /nix/store/cfz56rl3lp066226i0bmmgiicls3gcq7-emacs-packages-deps/share/emacs/site-lisp/elpa/diff-hl-20261001.135/diff-hl.el
;;;###autoload
(defun diff-hl-set-reference-rev (rev)
"Set the reference revision globally to REV.
When called interactively, REV read with completion.
When called with a prefix argument, reset the global reference to the most
recent one instead. With two prefix arguments, do the same and discard
every per-project reference created by
`diff-hl-set-reference-rev-in-project`.
The default value chosen using one of methods below:
- In a log view buffer, it uses the revision of current entry.
Call `vc-print-log' or `vc-print-root-log' first to open a log
view buffer.
- In a VC annotate buffer, it uses the revision of current line.
- In other situations, it uses the symbol at point.
Notice that this sets the reference revision globally, so in files from
other repositories, `diff-hl-mode' will not highlight changes correctly,
until you run `diff-hl-reset-reference-rev'. To set the reference on a
per-project basis, see `diff-hl-set-reference-rev-in-project`.
Also notice that this will disable `diff-hl-amend-mode' in
buffers that enables it, since `diff-hl-amend-mode' overrides its
effect."
(interactive
(if current-prefix-arg current-prefix-arg
(let* ((def (or (and (equal major-mode 'vc-annotate-mode)
(car (vc-annotate-extract-revision-at-line)))
(log-view-current-tag)
(thing-at-point 'symbol t)))
(prompt (if def
(format "Reference revision (default %s): " def)
"Reference revision: ")))
(list (vc-read-revision prompt nil nil def)))))
(unless rev
(user-error "No reference revision specified"))
(cond
((equal '(4) current-prefix-arg)
;; reset global value
(diff-hl-reset-reference-rev))
((equal '(16) current-prefix-arg)
;; reset global value and remove per-project value
(diff-hl-reset-reference-rev '(4)))
;; change only global value
(t (setq-default diff-hl-reference-revision rev)
(unless current-prefix-arg
(message "Set global reference revision to %s" rev))
(dolist (buf (buffer-list))
(with-current-buffer buf
(when diff-hl-mode
(when (bound-and-true-p diff-hl-amend-mode)
(diff-hl-amend-mode -1))
(when (not (local-variable-p 'diff-hl-reference-revision))
(diff-hl-update))))))))