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:
Nick Cameron 2017-06-07 10:05:36 +12:00 committed by GitHub
commit c879d5ebd7

View File

@ -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)?;