martinvonz / jj

A Git-compatible VCS that is both simple and powerful
https://martinvonz.github.io/jj/
Apache License 2.0
8.84k stars 307 forks source link

Panic during an incomplete conflict resolution #2611

Closed PhilipMetzger closed 1 month ago

PhilipMetzger commented 11 months ago

Description

This happened at $WORK, so this is a recollection. This happened while resolving another large conflict (8-sided if I remember correctly). It would be nice if we didn't panic during merge-tree creation, as it renders jj st and other commands useless.

Steps to Reproduce the Problem

  1. Create a conflicted file
  2. During conflict resolution, delete an unbalanced amount of diff markers
  3. Try to jj st to see if we have pending conflicts to solve.

Expected Behavior

jj log or jj st don't panic.

Actual Behavior

We hit an assertion in lib/src/merge.rs, which expects an even amount of adds and an odd amount of removes.

Specifications

PhilipMetzger commented 11 months ago

We've discussed this thoroughly in Discord and Martin recognized that this can happen when intermediate conflicts aren't resolved and any further command auto-squashes the still unfinished resolution.

We still shouldn't fail on an assertion but the immediate action to warn on incomplete resolutions should prevent anyone else hitting it.

paulzzy commented 1 month ago

Does resolving all conflicts in the working copy fix the panic? I'm trying to figure out how to recover from this state.

EDIT: It does fix the panic!

PhilipMetzger commented 1 month ago

Also just balancing the conflicts to not hit the assertion also helps.