From 680d864e1165ac5d334eef6d69e301f2094ff4c3 Mon Sep 17 00:00:00 2001 From: Nicolas GB Date: Thu, 29 Jan 2026 09:28:50 +0100 Subject: [PATCH] fix(diff): Correctly compare against `@-` instead of `HEAD~1` when (#76) --- lua/jj/diff/codediff.lua | 12 +++++------- lua/jj/diff/diffview.lua | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/lua/jj/diff/codediff.lua b/lua/jj/diff/codediff.lua index 163f527..6783508 100644 --- a/lua/jj/diff/codediff.lua +++ b/lua/jj/diff/codediff.lua @@ -31,13 +31,11 @@ diff.register_backend("codediff", { end -- Extract the commit id from opts.rev - local commit_id = "HEAD~1" - if opts.rev then - local t_commit_id = utils.get_commit_id(opts.rev) - if t_commit_id == nil then - return - end - commit_id = t_commit_id + local revset = opts.rev or "@-" + + local commit_id = utils.get_commit_id(revset) + if not commit_id then + return end vim.cmd(string.format("CodeDiff file %s", commit_id)) diff --git a/lua/jj/diff/diffview.lua b/lua/jj/diff/diffview.lua index db47209..c269919 100644 --- a/lua/jj/diff/diffview.lua +++ b/lua/jj/diff/diffview.lua @@ -32,13 +32,11 @@ diff.register_backend("diffview", { end -- Extract the commit id from opts.rev - local commit_id = "HEAD~1" - if opts.rev then - local t_commit_id = utils.get_commit_id(opts.rev) - if t_commit_id == nil then - return - end - commit_id = t_commit_id + local revset = opts.rev or "@-" + + local commit_id = utils.get_commit_id(revset) + if not commit_id then + return end vim.cmd(string.format("DiffviewOpen %s -- %%", commit_id))