Function: diff-hl-diff-buffer-with-reference
diff-hl-diff-buffer-with-reference is a natively compiled function
defined in diff-hl.el.
Signature
(diff-hl-diff-buffer-with-reference FILE &optional DEST-BUFFER BACKEND CONTEXT-LINES)
Documentation
Compute the diff between the current buffer contents and reference in BACKEND.
The diffs are computed in the buffer DEST-BUFFER. This requires
the diff-program to be in your exec-path(var)/exec-path(fun).
CONTEXT-LINES is the size of the unified diff context, defaults to 0.
Source Code
;; Defined in /nix/store/cfz56rl3lp066226i0bmmgiicls3gcq7-emacs-packages-deps/share/emacs/site-lisp/elpa/diff-hl-20261001.135/diff-hl.el
(defun diff-hl-diff-buffer-with-reference (file &optional dest-buffer backend context-lines)
"Compute the diff between the current buffer contents and reference in BACKEND.
The diffs are computed in the buffer DEST-BUFFER. This requires
the `diff-program' to be in your `exec-path'.
CONTEXT-LINES is the size of the unified diff context, defaults to 0."
(require 'diff)
(unless file
(error "Buffer %s is not visiting a file" (buffer-name)))
(setq backend (or backend (vc-backend file)))
(unless backend
(error "File %s is not under version control" file))
(save-current-buffer
(let* ((dest-buffer (or dest-buffer "*diff-hl-diff-buffer-with-reference*"))
(temporary-file-directory diff-hl-temporary-directory)
(enable-local-variables nil)
(rev
(if (diff-hl--use-git-index-base-p backend)
(diff-hl-git-index-revision
file
(diff-hl-git-index-object-name file))
(diff-hl-create-revision
file
(or (diff-hl-resolved-revision
backend
(or diff-hl-reference-revision
(assoc-default backend diff-hl-head-revision-alist)))
(diff-hl-working-revision (diff-hl--buffer-file-name) backend)))))
(switches (format "-U %d --strip-trailing-cr" (or context-lines 0))))
(diff-no-select rev (current-buffer) switches (not (diff-hl--use-async-p))
(get-buffer-create dest-buffer))
;; Function `diff-sentinel' adds a summary line, but that seems fine.
;; In all commands which use exact text we call it synchronously.
(get-buffer-create dest-buffer))))