From 900bcdca7d3cef6a6c998af4b2e87783e56d8dfa Mon Sep 17 00:00:00 2001 From: Michael Seibt <36601201+mstv@users.noreply.github.com> Date: Wed, 14 Jul 2021 01:38:19 +0200 Subject: [PATCH] Make showing commit message body in the revision graph optional (#9374) (cherry picked from commit 2c32e7e3ce43586ad1fde3b7562b6476463c575d) --- GitCommands/Settings/AppSettings.cs | 6 ++++++ GitUI/CommandsDialogs/FormBrowse.cs | 2 +- GitUI/Translation/English.xlf | 4 ++++ .../RevisionGrid/Columns/MessageColumnProvider.cs | 13 +++++-------- .../RevisionGrid/RevisionGridControl.cs | 7 +++++++ .../RevisionGrid/RevisionGridMenuCommands.cs | 7 +++++++ contributors.txt | 1 + 7 files changed, 31 insertions(+), 9 deletions(-) diff --git a/GitCommands/Settings/AppSettings.cs b/GitCommands/Settings/AppSettings.cs index b27e0d6fc8c..4d30be5d359 100644 --- a/GitCommands/Settings/AppSettings.cs +++ b/GitCommands/Settings/AppSettings.cs @@ -1267,6 +1267,12 @@ public static int RevisionGridQuickSearchTimeout set => SetInt("revisiongridquicksearchtimeout", value); } + public static bool ShowCommitBodyInRevisionGrid + { + get => GetBool("ShowCommitBodyInRevisionGrid", true); + set => SetBool("ShowCommitBodyInRevisionGrid", value); + } + /// Gets or sets the path to the git application executable. public static string GitBinDir { diff --git a/GitUI/CommandsDialogs/FormBrowse.cs b/GitUI/CommandsDialogs/FormBrowse.cs index 425f14bf1cb..5be995bcd5f 100644 --- a/GitUI/CommandsDialogs/FormBrowse.cs +++ b/GitUI/CommandsDialogs/FormBrowse.cs @@ -845,7 +845,7 @@ private void RefreshSelection() FillCommitInfo(selectedRevision); // If the revision's body has been updated then the grid needs to be refreshed to display it - if (selectedRevision is not null && selectedRevision.HasMultiLineMessage && oldBody != selectedRevision.Body) + if (AppSettings.ShowCommitBodyInRevisionGrid && selectedRevision is not null && selectedRevision.HasMultiLineMessage && oldBody != selectedRevision.Body) { RevisionGrid.Refresh(); } diff --git a/GitUI/Translation/English.xlf b/GitUI/Translation/English.xlf index a3bb84115a3..3060de4dcd8 100644 --- a/GitUI/Translation/English.xlf +++ b/GitUI/Translation/English.xlf @@ -8866,6 +8866,10 @@ See the changes in the commit form. Show build status text + + Show commit message body + + Show date column diff --git a/GitUI/UserControls/RevisionGrid/Columns/MessageColumnProvider.cs b/GitUI/UserControls/RevisionGrid/Columns/MessageColumnProvider.cs index 2b2bc6c20bf..63c84101538 100644 --- a/GitUI/UserControls/RevisionGrid/Columns/MessageColumnProvider.cs +++ b/GitUI/UserControls/RevisionGrid/Columns/MessageColumnProvider.cs @@ -406,17 +406,14 @@ void DrawSuperProjectRef(string label, ref int currentOffset) return; } - if (lines.Length == 1) + if (lines.Length > 1 && AppSettings.ShowCommitBodyInRevisionGrid) { - indicator.Render(); - return; + var commitBody = string.Concat(lines.Skip(1).Select(_ => " " + _)); + var bodyBounds = messageBounds.ReduceLeft(offset); + var bodyWidth = _grid.DrawColumnText(e, commitBody, font, style.CommitBodyForeColor, bodyBounds); + offset += bodyWidth; } - var commitBody = string.Concat(lines.Skip(1).Select(_ => " " + _)); - var bodyBounds = messageBounds.ReduceLeft(offset); - var bodyWidth = _grid.DrawColumnText(e, commitBody, font, style.CommitBodyForeColor, bodyBounds); - offset += bodyWidth; - // Draw the multi-line indicator indicator.Render(); } diff --git a/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs b/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs index 3db7be512a6..2073fa8ecde 100644 --- a/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs +++ b/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs @@ -2225,6 +2225,13 @@ internal void ToggleShowMergeCommits() ForceRefreshRevisions(); } + internal void ToggleShowCommitBodyInRevisionGrid() + { + AppSettings.ShowCommitBodyInRevisionGrid = !AppSettings.ShowCommitBodyInRevisionGrid; + MenuCommands.TriggerMenuChanged(); + Refresh(); + } + internal void ShowFirstParent() { AppSettings.ShowFirstParent = !AppSettings.ShowFirstParent; diff --git a/GitUI/UserControls/RevisionGrid/RevisionGridMenuCommands.cs b/GitUI/UserControls/RevisionGrid/RevisionGridMenuCommands.cs index 7acf5398206..caea50325f9 100644 --- a/GitUI/UserControls/RevisionGrid/RevisionGridMenuCommands.cs +++ b/GitUI/UserControls/RevisionGrid/RevisionGridMenuCommands.cs @@ -355,6 +355,13 @@ private IReadOnlyList CreateViewMenuCommands() ExecuteAction = () => _revisionGrid.ToggleShowGitNotes(), IsCheckedFunc = () => AppSettings.ShowGitNotes }, + new MenuCommand + { + Name = "showCommitMessageBodyToolStripMenuItem", + Text = "Show commit message body", + ExecuteAction = () => _revisionGrid.ToggleShowCommitBodyInRevisionGrid(), + IsCheckedFunc = () => AppSettings.ShowCommitBodyInRevisionGrid + }, MenuCommand.CreateSeparator(), diff --git a/contributors.txt b/contributors.txt index d51b863bb82..c38be453241 100644 --- a/contributors.txt +++ b/contributors.txt @@ -153,3 +153,4 @@ YYYY/MM/DD, github id, Full name, email 2021/01/25, guybark, Guy Barker, guybark(at)microsoft.com 2021/02/10, mabako, Marcus Bauer, mabako(at)gmail.com 2021/03/20, nyankoframe, Damit Senanayake, damit(at)outlook.com +2021/06/18, jwfx, Jörg Winkler, jwfx at bitmx.net