-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show a warning when undoing an undo operation #5580
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,20 @@ pub fn cmd_op_undo( | |
let template = tx.base_workspace_helper().operation_summary_template(); | ||
template.format(&bad_op, formatter.as_mut())?; | ||
writeln!(formatter)?; | ||
|
||
let was_undo_op = *tx.repo().view() == parent_op.view()?; | ||
if args.operation == "@" && was_undo_op { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a review to discuss the The hint will still not be displayed if the user attempts to undo a specific operation (e.g. |
||
writeln!( | ||
ui.hint_default(), | ||
"This action reverted an 'undo' operation. The repository is now in the same \ | ||
state as it was before the original 'undo'." | ||
)?; | ||
writeln!( | ||
ui.hint_default(), | ||
"If your goal is to undo multiple operations, consider using `jj op log` to see \ | ||
past states, and `jj op restore` to restore one of these states." | ||
)?; | ||
} | ||
} | ||
tx.finish(ui, format!("undo operation {}", bad_op.id().hex()))?; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jj restore
restores filesets from a revision. It is probablyjj op restore
instead that we want to suggest here, which restores the repo to an earlier state.