FR: Recover command for corrupt repo and/or troubleshooting documentation
Is your feature request related to a problem? Please describe. Yes; the repository can become corrupt as in #4423.
Describe the solution you'd like
While investigating a corrupt repo (no valid operation in .jj/repo/op_heads/heads/), I was able to find the last valid prior operation in .jj/repo/op_store/operations/. There should be some command (or at least a how-to) for restoring to such an operation.
jj op restore HASH fails since the first thing fn cmd_op_restore tries to do is construct a workspace:
// NOTE: this fails since the op log does not have a valid head
let mut workspace_command = command.workspace_helper(ui)?;
It is trivial to resolve the target_op without a workspace_command:
let target_op = jj_lib::op_walk::resolve_op_for_load(workspace.repo_loader(), &args.operation)?;
However, it is very much not trivial to apply a transaction — I'm not even sure it makes sense to try given that a transaction must have a valid initial state!
Describe alternatives you've considered Ideally, it would be impossible for a repo to become corrupted. But even if all filesystem commits were atomic and all bugs squashed, there would still be other possible causes (especially user error).
There might be a dedicated recovery command for common (resolvable) issues?
There could simply be good documentation on the filesystem format with tips on troubleshooting.
Describe alternatives you've considered Ideally, it would be impossible for a repo to become corrupted. But even if all filesystem commits were atomic and all bugs squashed, there would still be other possible causes (especially user error).
There might be a dedicated recovery command for common (resolvable) issues?
We previously talked about a jj doctor/jj util recover command in the Discord but nothing has happened in its direction.
I updated my "guide" on recovering the repo in the other thread. Unfortunately it leaves another unsolved problem: commits which appear in jj's log but which do not exist when I attempt to edit / new / diff -r / abandon them.