summaryrefslogtreecommitdiff
path: root/core/builtins.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/builtins.zig')
-rw-r--r--core/builtins.zig11
1 files changed, 11 insertions, 0 deletions
diff --git a/core/builtins.zig b/core/builtins.zig
index b516d543..18b49a41 100644
--- a/core/builtins.zig
+++ b/core/builtins.zig
@@ -983,6 +983,11 @@ pub const Save = struct {
};
const path = std.mem.trim(u8, c.arg orelse "", " \t\r\n");
if (path.len > 0) return exec.saveTo(c.p, c.id, path);
+ // A file at a revision (jj.zig) is read-only: written elsewhere only.
+ if (c.pane.file) |*file| if (@import("jj.zig").of(file) != null) {
+ var said: pardes.Kind.Buf(limits.host_path_cap + 64) = .{};
+ return c.p.reportFailure(c.id, said.print("Save: {s} is a revision, read-only (Save <path> writes it)", .{file.path[0..@min(file.path.len, limits.host_path_cap)]}));
+ };
// A `+` name is a generated pane's (+Tutor), no file of its own:
// a bare Save asks for a path, as a +New scratch's does.
if (c.pane.file) |file| if (file.output == null and !std.mem.startsWith(u8, std.Io.Dir.path.basename(file.path), "+")) return exec.saveFile(c.p, c.id);
@@ -1069,6 +1074,12 @@ pub const Syntax = struct {
}
};
+/// Show a file as it was at revision `rev` (jj), read-only, beside its pane; in such a pane, that file at another revision in its place, or bare, the file.
+pub const At = struct {
+ pub const takes_arg = true;
+ pub const run = @import("jj.zig").word;
+};
+
/// Stack a diff's hunks as a diff viewer shows them, each under its place and the declarations around it, in a +Diff; on a +Diff, show the diff itself as text. `Diff <file>` stacks that diff's, `Diff <revision>` git show's.
/// The diff viewer's one registration: its word and traits here, all else
/// its own (hunks.zig).