diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index faef94ef..d1db5a46 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -536,7 +536,7 @@ namespace SourceGit.ViewModels private static readonly HashSet IMG_EXTS = new HashSet() { - ".ico", ".bmp", ".jpg", ".png", ".jpeg" + ".ico", ".bmp", ".jpg", ".png", ".jpeg", ".webp" }; private Repository _repo = null; diff --git a/src/ViewModels/DiffContext.cs b/src/ViewModels/DiffContext.cs index c6b0e871..08499d89 100644 --- a/src/ViewModels/DiffContext.cs +++ b/src/ViewModels/DiffContext.cs @@ -139,7 +139,7 @@ namespace SourceGit.ViewModels else if (latest.IsBinary) { var oldPath = string.IsNullOrEmpty(_option.OrgPath) ? _option.Path : _option.OrgPath; - var ext = Path.GetExtension(oldPath); + var ext = Path.GetExtension(_option.Path); if (IMG_EXTS.Contains(ext)) { @@ -147,13 +147,14 @@ namespace SourceGit.ViewModels if (_option.Revisions.Count == 2) { (imgDiff.Old, imgDiff.OldFileSize) = BitmapFromRevisionFile(_repo, _option.Revisions[0], oldPath); - (imgDiff.New, imgDiff.NewFileSize) = BitmapFromRevisionFile(_repo, _option.Revisions[1], oldPath); + (imgDiff.New, imgDiff.NewFileSize) = BitmapFromRevisionFile(_repo, _option.Revisions[1], _option.Path); } else { - var fullPath = Path.Combine(_repo, _option.Path); - (imgDiff.Old, imgDiff.OldFileSize) = BitmapFromRevisionFile(_repo, "HEAD", oldPath); + if (!oldPath.Equals("/dev/null", StringComparison.Ordinal)) + (imgDiff.Old, imgDiff.OldFileSize) = BitmapFromRevisionFile(_repo, "HEAD", oldPath); + var fullPath = Path.Combine(_repo, _option.Path); if (File.Exists(fullPath)) { imgDiff.New = new Bitmap(fullPath); @@ -226,7 +227,7 @@ namespace SourceGit.ViewModels private static readonly HashSet IMG_EXTS = new HashSet() { - ".ico", ".bmp", ".jpg", ".png", ".jpeg" + ".ico", ".bmp", ".jpg", ".png", ".jpeg", ".webp" }; private readonly string _repo; diff --git a/src/ViewModels/FileHistories.cs b/src/ViewModels/FileHistories.cs index e9672e26..398293a3 100644 --- a/src/ViewModels/FileHistories.cs +++ b/src/ViewModels/FileHistories.cs @@ -186,7 +186,7 @@ namespace SourceGit.ViewModels private static readonly HashSet IMG_EXTS = new HashSet() { - ".ico", ".bmp", ".jpg", ".png", ".jpeg" + ".ico", ".bmp", ".jpg", ".png", ".jpeg", ".webp" }; private readonly Repository _repo = null;