From a5e7bf688ebf78c7ebc0943ef6a08eae30f35687 Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Sat, 16 Nov 2024 21:47:55 +0100 Subject: [PATCH] fix: in commit view get file histories by commit When file histories are accessed from the commit details view, run git log for the inspected commit. Previously the log was ran against current branch regardless whether the inspected commit belongs to that branch. --- src/ViewModels/CommitDetail.cs | 4 ++-- src/ViewModels/FileHistories.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index ef060f04..7ef8ce85 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -293,7 +293,7 @@ namespace SourceGit.ViewModels history.Icon = App.CreateMenuIcon("Icons.Histories"); history.Click += (_, ev) => { - var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, change.Path) }; + var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, change.Path, _commit.SHA) }; window.Show(); ev.Handled = true; }; @@ -434,7 +434,7 @@ namespace SourceGit.ViewModels history.Icon = App.CreateMenuIcon("Icons.Histories"); history.Click += (_, ev) => { - var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, file.Path) }; + var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, file.Path, _commit.SHA) }; window.Show(); ev.Handled = true; }; diff --git a/src/ViewModels/FileHistories.cs b/src/ViewModels/FileHistories.cs index 035cadfd..52ed6b01 100644 --- a/src/ViewModels/FileHistories.cs +++ b/src/ViewModels/FileHistories.cs @@ -57,14 +57,14 @@ namespace SourceGit.ViewModels private set => SetProperty(ref _viewContent, value); } - public FileHistories(Repository repo, string file) + public FileHistories(Repository repo, string file, string commit = null) { _repo = repo; _file = file; Task.Run(() => { - var commits = new Commands.QueryCommits(_repo.FullPath, $"-n 10000 -- \"{file}\"", false).Result(); + var commits = new Commands.QueryCommits(_repo.FullPath, $"-n 10000 {commit} -- \"{file}\"", false).Result(); Dispatcher.UIThread.Invoke(() => { IsLoading = false;