Function: diff-hl-diff-against-reference
diff-hl-diff-against-reference is a natively compiled function defined
in diff-hl.el.
Signature
(diff-hl-diff-against-reference FILE BACKEND BUFFER &optional NEW-REV)
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-against-reference (file backend buffer &optional new-rev)
(cond
((and (not new-rev)
(diff-hl--use-git-index-base-p backend))
(apply #'vc-git-command buffer
(if (diff-hl--use-async-p) 'async 1)
(list file)
"diff-files"
(cons "-p" (vc-switches 'git 'diff))))
((eq new-rev 'git-index)
(apply #'vc-git-command buffer
(if (diff-hl--use-async-p) 'async 1)
(list file)
"diff-index"
(append
(vc-switches 'git 'diff)
(list "-p" "--cached"
(or diff-hl-reference-revision
(if (vc-git--empty-db-p)
diff-hl--git-empty-tree)
(diff-hl-head-revision backend))
"--"))))
(t
(condition-case err
(vc-call-backend backend 'diff (list file)
diff-hl-reference-revision
new-rev
buffer
(diff-hl--use-async-p))
(error
;; https://github.com/dgutov/diff-hl/issues/117
(when (string-match-p "\\`Failed (status 128)" (error-message-string err))
(vc-call-backend backend 'diff (list file)
diff-hl--git-empty-tree
nil
buffer
(diff-hl--use-async-p)))))))
buffer)