Function: vc-jj-diff

vc-jj-diff is a natively compiled function defined in vc-jj.el.

Signature

(vc-jj-diff FILES &optional REV1 REV2 BUFFER ASYNC)

Documentation

Display diffs for FILES between revisions REV1 and REV2.

FILES is a list of file paths. REV1 and REV2 are the full change IDs of two revisions. REV1 is the earlier revision and REV2 is the later revision.

When BUFFER is non-nil, it is the buffer object or name to insert the diff into. Otherwise, when nil, insert the diff into the *vc-diff* buffer. If _ASYNC is non-nil, run asynchronously. This is currently unsupported.

Source Code

;; Defined in /nix/store/j1ql1qsv99iszr5pqf5fk9yfcl5pq4nv-emacs-packages-deps/share/emacs/site-lisp/elpa/vc-jj-0.5/vc-jj.el
;;;; comment-history

;;;; update-changelog

;;;; diff

(defun vc-jj-diff (files &optional rev1 rev2 buffer _async)
  "Display diffs for FILES between revisions REV1 and REV2.
FILES is a list of file paths.  REV1 and REV2 are the full change IDs of
two revisions.  REV1 is the earlier revision and REV2 is the later
revision.

When BUFFER is non-nil, it is the buffer object or name to insert the
diff into.  Otherwise, when nil, insert the diff into the *vc-diff*
buffer.  If _ASYNC is non-nil, run asynchronously.  This is currently
unsupported."
  ;; TODO: handle async
  (setq buffer (get-buffer-create (or buffer "*vc-diff*"))
        files (mapcar #'vc-jj--filename-to-fileset files))
  (cond
   ((not (or rev1 rev2))
    ;; Use `vc-jj-previous-revision' instead of "@-" because the
    ;; former handles edge cases like e.g. multiple parents
    (setq rev1 (vc-jj-previous-revision nil "@")))
   ((null rev1)
    (setq rev1 "root()")))
  (setq rev2 (or rev2 "@"))
  (let ((inhibit-read-only t)
        ;; When REV1 and REV2 are the same revision, "-f REV1 -t REV2"
        ;; (erroneously) returns an empty diff.  So we check for that
        ;; case and use "-r REV1" instead, which returns the correct
        ;; diff
        (args (append (if (string= rev1 rev2)
                          (list "-r" rev1)
                        (list "-f" rev1 "-t" rev2))
                      (vc-switches 'jj 'diff)
                      (list "--") files)))
    (with-current-buffer buffer
      (erase-buffer))
    (apply #'call-process vc-jj-program nil buffer nil "diff" args)
    (if (seq-some (lambda (line) (string-prefix-p "M " line))
                  (apply #'vc-jj--process-lines "diff" "--summary" "--" files))
        1
      0)))