diff --git a/CHANGELOG.md b/CHANGELOG.md index ce294db897b..96f780f1684 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed bugs + * Fixed panic when parsing conflict markers of a particular form. + ([#2611](https://github.com/martinvonz/jj/pull/2611)) + ## [0.21.0] - 2024-09-04 ### Breaking changes diff --git a/lib/src/conflicts.rs b/lib/src/conflicts.rs index 80509718576..dfc677172ed 100644 --- a/lib/src/conflicts.rs +++ b/lib/src/conflicts.rs @@ -473,7 +473,12 @@ fn parse_conflict_hunk(input: &[u8]) -> Merge { } } - Merge::from_removes_adds(removes, adds) + if adds.len() == removes.len() + 1 { + Merge::from_removes_adds(removes, adds) + } else { + // Doesn't look like a conflict + return Merge::resolved(BString::new(vec![])); + } } /// Parses conflict markers in `content` and returns an updated version of diff --git a/lib/tests/test_conflicts.rs b/lib/tests/test_conflicts.rs index 1a9b6b37b5e..3812a7007e7 100644 --- a/lib/tests/test_conflicts.rs +++ b/lib/tests/test_conflicts.rs @@ -749,8 +749,6 @@ fn test_parse_conflict_wrong_arity() { } #[test] -// TODO: Should *not* panic -#[should_panic] fn test_parse_conflict_missing_removes() { assert_eq!( parse_conflict(