whenever a hunk is reversed also reverse change type

This commit is contained in:
Kiril Videlov 2024-09-11 20:48:09 +02:00
parent 199129162d
commit 8ad8797b5d
No known key found for this signature in database
GPG Key ID: A4C733025427C471

View File

@ -387,6 +387,11 @@ fn reverse_patch(patch: &BStr) -> Option<BString> {
// returns `None` if the reversal failed
pub fn reverse_hunk(hunk: &GitHunk) -> Option<GitHunk> {
let new_change_type = match hunk.change_type {
ChangeType::Added => ChangeType::Deleted,
ChangeType::Deleted => ChangeType::Added,
ChangeType::Modified => ChangeType::Modified,
};
if hunk.binary {
None
} else {
@ -397,7 +402,7 @@ pub fn reverse_hunk(hunk: &GitHunk) -> Option<GitHunk> {
new_lines: hunk.old_lines,
diff_lines: diff.into(),
binary: hunk.binary,
change_type: hunk.change_type,
change_type: new_change_type,
})
}
}