Skip to content

jj resolve panics when resolving conflicts involving deleted files #6250

@scott2000

Description

@scott2000

Description

jj resolve panics whenever resolving a conflict involving deleted files using an external merge tool (or :ours or :theirs).

This was found by saber on Discord for :ours and :theirs, but I tested it and the same issue occurs with external merge tools as well.

Steps to Reproduce the Problem

  1. Create a modify-delete conflict (2-sided conflict including 1 deletion).
  2. Run jj resolve with an external merge tool (or with :ours or :theirs).
  3. Resolve the conflict using the merge tool.

Expected Behavior

The resolution of the conflict is saved in the working copy. Due to executable bit handling, it may not be possible to resolve the conflict fully, but at least it shouldn't panic. Alternatively, we could just disallow jj resolve when one of the sides is a deletion.

Actual Behavior

A panic like this when the resolution doesn't delete the file (which is normally the case for external merge tools):

thread 'main' panicked at lib/src/merge.rs:626:21:
assertion failed: file_id.is_none()
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: jj_lib::merge::Merge<core::option::Option<T>>::with_new_file_ids::{{closure}}
   4: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next
   5: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   6: <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter
   7: core::iter::traits::iterator::Iterator::collect
   8: jj_lib::merge::Merge<core::option::Option<T>>::with_new_file_ids
   9: jj_cli::merge_tools::external::run_mergetool_external_single_file
  10: jj_cli::merge_tools::external::run_mergetool_external
  11: jj_cli::merge_tools::MergeEditor::edit_files
  12: jj_cli::commands::resolve::cmd_resolve

Otherwise, a panic like this when the resolution deletes the file (which may be the case for :ours or :theirs):

thread 'main' panicked at lib/src/merge.rs:621:46:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: jj_lib::merge::Merge<core::option::Option<T>>::with_new_file_ids::{{closure}}
   5: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next
   6: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   7: <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter
   8: core::iter::traits::iterator::Iterator::collect
   9: jj_lib::merge::Merge<core::option::Option<T>>::with_new_file_ids
  10: jj_cli::merge_tools::pick_conflict_side
  11: jj_cli::merge_tools::MergeEditor::edit_files
  12: jj_cli::commands::resolve::cmd_resolve

Specifications

  • Platform: NixOS
  • Version: jj 0.28.0-29f24ad2d8746e497abb701a99ba00b874f0cea7

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions