diff --git a/SourceGit/Git/Commit.cs b/SourceGit/Git/Commit.cs index 2b3c5c89..ef0480f7 100644 --- a/SourceGit/Git/Commit.cs +++ b/SourceGit/Git/Commit.cs @@ -12,6 +12,22 @@ namespace SourceGit.Git { private static readonly string GPGSIG_START = "gpgsig -----BEGIN PGP SIGNATURE-----"; private static readonly string GPGSIG_END = " -----END PGP SIGNATURE-----"; + /// + /// Object in commit. + /// + public class Object { + public enum Type { + Tag, + Blob, + Tree, + Commit, + } + + public string Path { get; set; } + public Type Kind { get; set; } + public string SHA { get; set; } + } + /// /// SHA /// @@ -173,11 +189,27 @@ namespace SourceGit.Git { /// /// /// - public List GetFiles(Repository repo) { - var files = new List(); + public List GetFiles(Repository repo) { + var files = new List(); + var test = new Regex(@"^\d+\s+(\w+)\s+([0-9a-f]+)\s+(.*)$"); - var errs = repo.RunCommand($"ls-tree --name-only -r {SHA}", line => { - files.Add(line); + var errs = repo.RunCommand($"ls-tree -r {SHA}", line => { + var match = test.Match(line); + if (!match.Success) return; + + var obj = new Object(); + obj.Path = match.Groups[3].Value; + obj.Kind = Object.Type.Blob; + obj.SHA = match.Groups[2].Value; + + switch (match.Groups[1].Value) { + case "tag": obj.Kind = Object.Type.Tag; break; + case "blob": obj.Kind = Object.Type.Blob; break; + case "tree": obj.Kind = Object.Type.Tree; break; + case "commit": obj.Kind = Object.Type.Commit; break; + } + + files.Add(obj); }); if (errs != null) App.RaiseError(errs); diff --git a/SourceGit/UI/CommitViewer.xaml b/SourceGit/UI/CommitViewer.xaml index fdc54f16..4a11d083 100644 --- a/SourceGit/UI/CommitViewer.xaml +++ b/SourceGit/UI/CommitViewer.xaml @@ -405,6 +405,11 @@ x:Name="filePreview"/> + + + +