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))