diff --git a/src/Models/DiffResult.cs b/src/Models/DiffResult.cs index 64ec2393..a0a02c6f 100644 --- a/src/Models/DiffResult.cs +++ b/src/Models/DiffResult.cs @@ -587,10 +587,16 @@ namespace SourceGit.Models public string New { get; set; } = string.Empty; } + public class SubmoduleRevision + { + public Commit Commit { get; set; } = null; + public string FullMessage { get; set; } = string.Empty; + } + public class SubmoduleDiff { - public Commit Old { get; set; } = null; - public Commit New { get; set; } = null; + public SubmoduleRevision Old { get; set; } = null; + public SubmoduleRevision New { get; set; } = null; } public class DiffResult diff --git a/src/ViewModels/DiffContext.cs b/src/ViewModels/DiffContext.cs index 1e6e105e..53f6839c 100644 --- a/src/ViewModels/DiffContext.cs +++ b/src/ViewModels/DiffContext.cs @@ -131,12 +131,12 @@ namespace SourceGit.ViewModels if (line.Type == Models.TextDiffLineType.Added) { var sha = line.Content.Substring("Subproject commit ".Length); - submoduleDiff.New = new Commands.QuerySingleCommit(submoduleRoot, sha).Result() ?? new Models.Commit() { SHA = sha }; + submoduleDiff.New = QuerySubmoduleRevision(submoduleRoot, sha); } else if (line.Type == Models.TextDiffLineType.Deleted) { var sha = line.Content.Substring("Subproject commit ".Length); - submoduleDiff.Old = new Commands.QuerySingleCommit(submoduleRoot, sha).Result() ?? new Models.Commit() { SHA = sha }; + submoduleDiff.Old = QuerySubmoduleRevision(submoduleRoot, sha); } } rs = submoduleDiff; @@ -219,6 +219,22 @@ namespace SourceGit.ViewModels return size > 0 ? (new Bitmap(stream), size) : (null, size); } + private Models.SubmoduleRevision QuerySubmoduleRevision(string repo, string sha) + { + var commit = new Commands.QuerySingleCommit(repo, sha).Result(); + if (commit != null) + { + var body = new Commands.QueryCommitFullMessage(repo, sha).Result(); + return new Models.SubmoduleRevision() { Commit = commit, FullMessage = body }; + } + + return new Models.SubmoduleRevision() + { + Commit = new Models.Commit() { SHA = sha }, + FullMessage = string.Empty, + }; + } + private static readonly HashSet IMG_EXTS = new HashSet() { ".ico", ".bmp", ".jpg", ".png", ".jpeg" diff --git a/src/Views/DiffView.axaml b/src/Views/DiffView.axaml index 713e4338..081abdf0 100644 --- a/src/Views/DiffView.axaml +++ b/src/Views/DiffView.axaml @@ -151,9 +151,9 @@ - + - + @@ -167,7 +167,7 @@ - + @@ -239,7 +239,7 @@ UseSideBySideDiff="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSideBySideDiff, Mode=OneWay}"/> - +