Skip to content

Commit 7407d46

Browse files
author
Stephan Dilly
committed
fix diff binary file once more
1 parent c0b48b8 commit 7407d46

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

asyncgit/src/sync/diff.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
use super::utils;
44
use crate::hash;
55
use git2::{
6-
Delta, Diff, DiffDelta, DiffFlags, DiffFormat, DiffHunk,
7-
DiffOptions, Patch, Repository,
6+
Delta, Diff, DiffDelta, DiffFormat, DiffHunk, DiffOptions, Patch,
7+
Repository,
88
};
9-
use log::debug;
109
use scopetime::scope_time;
1110
use std::{fs, path::Path};
1211

@@ -173,13 +172,8 @@ pub fn get_diff(repo_path: &str, p: String, stage: bool) -> FileDiff {
173172
let newfile_path =
174173
repo_path.join(delta.new_file().path().unwrap());
175174

176-
let newfile_content =
177-
if delta.flags().contains(DiffFlags::NOT_BINARY) {
178-
new_file_content(&newfile_path)
179-
.unwrap_or(String::from("file not found"))
180-
} else {
181-
String::from("binary file")
182-
};
175+
let newfile_content = new_file_content(&newfile_path)
176+
.unwrap_or(String::from("file not found"));
183177

184178
let mut patch = Patch::from_buffers(
185179
&[],
@@ -232,12 +226,12 @@ fn new_file_content(path: &Path) -> Option<String> {
232226
} else if meta.file_type().is_file() {
233227
if let Ok(content) = fs::read_to_string(path) {
234228
return Some(content);
229+
} else {
230+
return Some(String::from("no text file"));
235231
}
236232
}
237233
}
238234

239-
debug!("could not read: {:?}", path);
240-
241235
None
242236
}
243237

0 commit comments

Comments
 (0)