Merge pull request #1640 from topecongiro/issue-1632
Do not overwrite files when there are no diffs in Overwrite mode
This commit is contained in:
commit
c879d5ebd7
@ -128,9 +128,12 @@ fn create_diff(filename: &str,
|
||||
}
|
||||
}
|
||||
WriteMode::Overwrite => {
|
||||
// Write text directly over original file.
|
||||
let file = File::create(filename)?;
|
||||
write_system_newlines(file, text, config)?;
|
||||
// Write text directly over original file if there is a diff.
|
||||
let (source, formatted) = source_and_formatted_text(text, filename, config)?;
|
||||
if source != formatted {
|
||||
let file = File::create(filename)?;
|
||||
write_system_newlines(file, text, config)?;
|
||||
}
|
||||
}
|
||||
WriteMode::Plain => {
|
||||
write_system_newlines(out, text, config)?;
|
||||
|
Loading…
Reference in New Issue
Block a user