Fix permissions always shown as 'changed' with git-difftool

pull/647/head
Wilfred Hughes 2024-02-20 00:17:18 +07:00
parent cbbcbb3094
commit bb9e864ffe
2 changed files with 11 additions and 0 deletions

@ -8,6 +8,9 @@ Added support for Smali.
### Display
Fixed an issue where all files would show a permissions change when
using difftastic with `git difftool`.
Fixed an issue with paths not showing the containing directory when
using difftastic with `git difftool`.

@ -321,6 +321,14 @@ impl FileArgument {
pub(crate) fn permissions(&self) -> Option<FilePermissions> {
match self {
FileArgument::NamedPath(path) => {
// When used with `git difftool`, the first argument
// is a temporary file that always has the same
// permissions. That doesn't mean the file permissions
// have changed, so we shouldn't compare.
if is_git_tmpfile(path) {
return None;
}
let metadata = std::fs::metadata(path).ok()?;
Some(metadata.permissions().into())
}