fix: Fix crash when current head no longer exists#186
Conversation
When e.g. issuing a `jj new` command in a different window that causes the current head to disappear (because it was empty), we currently crash when trying to find the latest version of that head. Instead, we should just switch to the `@` revision in that case.
2360c33 to
6bd9456
Compare
There was a problem hiding this comment.
I think self.set_head(..) will set current head, refresh files, and refresh diff. Why not call self.set_head in both cases? This would lead to a simpler solution (warning! not tested with compiler)
let next_head = commander.get_head_latest(&self.head)
.or_else(|_| commander.get_current_head())?;
self.set_head(commander, next_head);
There was a problem hiding this comment.
I think there was something that I thought made this necessary, but neither did I document it, nor can I recall it, and @Edgpaez's fix seems to work just fine. And we likely can't merge this PR anyway due to having no reviewers 🤷🏻
|
This also crashes when doing a fetch that removes the current head (for instance because you were in a branch that is merged). I took a look and I think this is caused by #181 That fixes the crash but doesn't update the UI to show the new change. For that, we also need to do I implemented this in #188 that fixes this in both log_tab and files_tab 👍 |
When e.g. issuing a
jj newcommand in a different window that causes the current head to disappear (because it was empty), we currently crash when trying to find the latest version of that head. Instead, we should just switch to the@revision in that case.