summaryrefslogtreecommitdiff
path: root/core/hunks.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/hunks.zig')
-rw-r--r--core/hunks.zig9
1 files changed, 7 insertions, 2 deletions
diff --git a/core/hunks.zig b/core/hunks.zig
index e109b788..db2401f6 100644
--- a/core/hunks.zig
+++ b/core/hunks.zig
@@ -703,7 +703,9 @@ fn trimmedWidth(ctx: *const Ctx, section: []const u8) usize {
/// a digit among them), `git show` of it, paged into a +Pager that stacks
/// its hunks (ctl.fillPager), run in the pane's git work tree; with a jj
/// change (`Diff wrnnmymq [path[:line]]`: jj.diffChange), its patch, header
-/// and all, the cursor at that place in it. A plumbing
+/// and all, the cursor at that place in it; with any other word that names
+/// no file, in a jj repository, the revision jj takes it for (`Diff @-`, a
+/// bookmark), the same. A plumbing
/// rule's Diff that cannot (no hunk, no work tree) declines, saying
/// nothing (Pardes.plumb_declined), and the look looks itself.
pub fn word(c: pardes.builtins.Ctx) void {
@@ -734,12 +736,15 @@ pub fn word(c: pardes.builtins.Ctx) void {
return;
}
// A jj change (its letters k to z), with a place in its patch to stand at.
- if (@import("jj.zig").diffChange(p, c.id, arg)) return;
+ if (@import("jj.zig").diffChange(p, c.id, arg, false)) return;
if (@import("jj.zig").isChangeId(arg[0 .. std.mem.indexOfAny(u8, arg, " \t") orelse arg.len])) return declined(p, c.id, "Diff: no such change");
var buf: [4096]u8 = undefined;
const path = if (arg[0] == '/') arg else std.fmt.bufPrint(&buf, "{s}/{s}", .{ std.mem.trimEnd(u8, Pardes.paneDir(c.pane), "/"), arg }) catch arg;
const bytes = pardes.filesystem.read(p, path) catch |err| {
if (p.plumb_declined != null) return declined(p, c.id, "");
+ // No such file: a revision jj takes (`Diff @-`, a bookmark), its
+ // patch with its header, as a change's.
+ if (err == error.FileNotFound and @import("jj.zig").diffChange(p, c.id, arg, true)) return;
return p.reportError(.at(c.id), path, err);
};
defer p.gpa.free(bytes);