Skip to content

Commit

Permalink
Improve the documentation of jj prev
Browse files Browse the repository at this point in the history
This will hopefully make it clear that `jj prev` does not
move by [OFFSET] relative to `@`, which is a misconception
that I had and I think others may also have.

I am suggesting this change as a result of the vigorous discussion in
these two issues:

- #3426
- #3445

We should make similar changes to `jj next` as well since
it follows similar rules.
  • Loading branch information
emesterhazy committed Apr 4, 2024
1 parent b07fb3e commit 269fdc6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 7 additions & 2 deletions cli/src/commands/prev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ use crate::command_error::{user_error, CommandError};
use crate::commands::next::choose_commit;
use crate::ui::Ui;

/// Move the working-copy commit to the parent revision
/// Move the working-copy commit relative to the parent revision
///
///
/// The command moves you to the parent in a linear fashion.
/// The command moves `@-` (and therefore `@`) to an ancestor in a linear
/// fashion. If you run `jj prev n` and `--edit` is not used or implied, then
/// `jj prev` will operate as if `@` had been moved to its parent and then moved
/// backwards by `n` revisions before running `jj new` to create a new commit.
/// If `@-` resolves to multiple revisions, then the command fails.
///
///
/// ```text
/// D @ D
Expand Down
11 changes: 8 additions & 3 deletions cli/tests/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ To get started, see the tutorial at https://github.com/martinvonz/jj/blob/main/d
* `next`Move the working-copy commit to the child revision
* `obslog`Show how a change has evolved
* `operation`Commands for working with the operation log
* `prev`Move the working-copy commit to the parent revision
* `prev`Move the working-copy commit relative to the parent revision
* `rebase`Move revisions to different parent(s)
* `resolve`Resolve a conflicted file with an external merge tool
* `restore`Restore paths from another revision
Expand Down Expand Up @@ -1347,10 +1347,15 @@ This restores the repo to the state at the specified operation, effectively undo
## `jj prev`
Move the working-copy commit to the parent revision
Move the working-copy commit relative to the parent revision
The command moves you to the parent in a linear fashion.
The command moves `@-` (and therefore `@`) to an ancestor in a linear
fashion. If you run `jj prev n` and `--edit` is not used or implied, then
`jj prev` will operate as if `@` had been moved to its parent and then moved
backwards by `n` revisions before running `jj new` to create a new commit.
If `@-` resolves to multiple revisions, then the command fails.
```text
D @ D
Expand Down

0 comments on commit 269fdc6

Please sign in to comment.