--replace: Actually check if the file needs overwriting

This commit looks beautiful in `git show --ignore-space-change`.
This commit is contained in:
Andreas Nordal 2018-05-15 18:28:04 +02:00
parent a1ecff6971
commit 3557b54912

@ -271,12 +271,14 @@ impl<'a> FileOut<'a> {
Ok(())
}
fn commit(&mut self, path: &std::ffi::OsString) -> Result<(), std::io::Error> {
match &self.sink {
&OutputSink::Soak(ref vec) => {
let mut overwrite = try!(OpenOptions::new().write(true).truncate(true).create(false).open(path));
try!(overwrite.write_all(vec));
},
_ => {},
if self.change {
match &self.sink {
&OutputSink::Soak(ref vec) => {
let mut overwrite = try!(OpenOptions::new().write(true).truncate(true).create(false).open(path));
try!(overwrite.write_all(vec));
},
_ => {},
}
}
Ok(())
}