Skip to content

Commit ba2d3b7

Browse files
committed
undo/redo cli docs: add details about new behavior
I considered adding more details, but ultimately decided to err on the side of brevity. We could later write a short doc detailing the behavior (see the comments in the source) and point the CLI docs to it. For now, I tried to explain the smallest mental model the users should have in mind to feel comfortable with these commands. Since `jj redo` is the command that really makes the notion of an "undo stack" tick, I only mentioned that notion in there. Follows up on #7293 and #7277
1 parent 300f761 commit ba2d3b7

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

cli/src/commands/redo.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ use crate::ui::Ui;
2727

2828
/// Redo the most recently undone operation
2929
///
30-
/// This is the natural counterpart of `jj undo`.
30+
/// This is the natural counterpart of `jj undo`. Repeated invocations of `jj
31+
/// undo` and `jj redo` act similarly to Undo/Redo commands in a text editor.
32+
///
33+
/// Use `jj op log` to visualize the log of past operations, including a
34+
/// detailed description of any past undo/redo operations. See also `jj op
35+
/// restore` to explicitly restore an older operation by its id (available in
36+
/// the operation log).
3137
#[derive(clap::Args, Clone, Debug)]
3238
pub struct RedoArgs {}
3339

cli/src/commands/undo.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,17 @@ use crate::ui::Ui;
3131

3232
/// Undo the last operation
3333
///
34-
/// This undoes the last operation by restoring its parent operation.
34+
/// If used once after a normal (non-`undo`) operation, this will undo that last
35+
/// operation by restoring its parent. If `jj undo` is used repeatedly, it will
36+
/// restore increasingly older operations, going further back into the past.
3537
///
36-
/// There is also a matching `jj redo` command.
38+
/// There is also a complementary `jj redo` command that would instead move in
39+
/// the direction of the future after one or more `jj undo`s.
40+
///
41+
/// Use `jj op log` to visualize the log of past operations, including a
42+
/// detailed description of any past undo/redo operations. See also `jj op
43+
/// restore` to explicitly restore an older operation by its id (available in
44+
/// the operation log).
3745
#[derive(clap::Args, Clone, Debug)]
3846
pub struct UndoArgs {
3947
/// (deprecated, use `jj op revert <operation>`)

cli/tests/[email protected]

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2305,7 +2305,9 @@ J J
23052305

23062306
Redo the most recently undone operation
23072307

2308-
This is the natural counterpart of `jj undo`.
2308+
This is the natural counterpart of `jj undo`. Repeated invocations of `jj undo` and `jj redo` act similarly to Undo/Redo commands in a text editor.
2309+
2310+
Use `jj op log` to visualize the log of past operations, including a detailed description of any past undo/redo operations. See also `jj op restore` to explicitly restore an older operation by its id (available in the operation log).
23092311

23102312
**Usage:** `jj redo`
23112313

@@ -2710,9 +2712,11 @@ Modify the metadata of a revision without changing its content
27102712

27112713
Undo the last operation
27122714

2713-
This undoes the last operation by restoring its parent operation.
2715+
If used once after a normal (non-`undo`) operation, this will undo that last operation by restoring its parent. If `jj undo` is used repeatedly, it will restore increasingly older operations, going further back into the past.
2716+
2717+
There is also a complementary `jj redo` command that would instead move in the direction of the future after one or more `jj undo`s.
27142718

2715-
There is also a matching `jj redo` command.
2719+
Use `jj op log` to visualize the log of past operations, including a detailed description of any past undo/redo operations. See also `jj op restore` to explicitly restore an older operation by its id (available in the operation log).
27162720

27172721
**Usage:** `jj undo [OPERATION]`
27182722

0 commit comments

Comments
 (0)