branch: externals/vc-jj
commit 9b46272f1284cc373762fd8e472aca4d3bf3a8e6
Author: Kristoffer Balintona <[email protected]>
Commit: Kristoffer Balintona <[email protected]>

    fix: `vc-jj-diff' behavior for parallelized parent commits
    
    Previously, we used "@-" for REV2 when none was passed to
    `vc-jj-diff`.  However, that fails when the working copy has multiple
    parents.
    
    Instead, defer the work to `vc-jj-previous-revision` which handles
    such edge cases.  Also make the docstring of `vc-jj-diff` more
    informative.
    
    Fixes #41
---
 NEWS.org |  3 ++-
 vc-jj.el | 14 ++++++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/NEWS.org b/NEWS.org
index 9fd25710c7..cdce014e73 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -27,9 +27,10 @@
 
 - Fixed =vc-jj-diff= not transforming filenames into jj fileset syntax. This 
means commands like =vc-diff= and =log-view-diff= do not fail.
 - Fixed a bug related to vc-jj's integration with project.el in cases where a 
.git repo is within a subdirectory of a .jj repo.  Previously, when inside the 
.git repo, project.el would erroneously detect the .jj repo to be current one 
(instead of the .git repo, which is closer).  Now, project.el correctly detects 
the closer .git repo.
-+ =vc-jj-bookmark-delete= now properly recognizes the names of local bookmarks 
that are pushable to a remote.
+- =vc-jj-bookmark-delete= now properly recognizes the names of local bookmarks 
that are pushable to a remote.
 - Prevent the possibility of operating on the wrong revisions when in stale JJ 
Log View buffers (Log View buffers that are not up-to-date with the repository).
 - Show the correct diff in log-edit buffers created by 
=log-view-modify-change-comment=.
+- Fix =vc-diff= in files whose revision has multiple parents.
 
 ** [[https://codeberg.org/emacs-jj-vc/vc-jj.el/compare/v0.3...v0.4][0.4]] - 
2025-09-03
 
diff --git a/vc-jj.el b/vc-jj.el
index 066f3484df..52d386b365 100644
--- a/vc-jj.el
+++ b/vc-jj.el
@@ -986,13 +986,23 @@ delete."
 ;;;; diff
 
 (defun vc-jj-diff (files &optional rev1 rev2 buffer _async)
-  "Display diffs for FILES between revisions REV1 and REV2."
+  "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))
-    (setq rev1 "@-"))
+    ;; 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 "@"))

Reply via email to