Skip to content

Commit

Permalink
conflicts: don't panic when a conflict marker is missing removes
Browse files Browse the repository at this point in the history
Closes #2611
  • Loading branch information
martinvonz committed Sep 5, 2024
1 parent 333021f commit 8c9454a
Show file tree
Hide file tree
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
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion lib/src/conflicts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Merge::resolved(BString::new(vec![]))
}
}

/// Parses conflict markers in `content` and returns an updated version of
Expand Down
2 changes: 0 additions & 2 deletions lib/tests/test_conflicts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 8c9454a

Please sign in to comment.