Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
conflicts: don't panic when a conflict marker is missing removes
Browse files Browse the repository at this point in the history
Closes #2611
martinvonz committed Sep 5, 2024
1 parent 333021f commit ae60b96
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
7 changes: 6 additions & 1 deletion lib/src/conflicts.rs
Original file line number Diff line number Diff line change
@@ -473,7 +473,12 @@ fn parse_conflict_hunk(input: &[u8]) -> Merge<BString> {
}
}

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
2 changes: 0 additions & 2 deletions lib/tests/test_conflicts.rs
Original file line number Diff line number Diff line change
@@ -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(

0 comments on commit ae60b96

Please sign in to comment.