Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make showing commit message body in the revision graph optional #9301

Merged
merged 5 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions GitCommands/Settings/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,12 @@ public static int RevisionGridQuickSearchTimeout
set => SetInt("revisiongridquicksearchtimeout", value);
}

public static bool ShowCommitBodyInRevisionGrid
{
get => GetBool("ShowCommitBodyInRevisionGrid", true);
set => SetBool("ShowCommitBodyInRevisionGrid", value);
}

/// <summary>Gets or sets the path to the git application executable.</summary>
public static string GitBinDir
{
Expand Down
2 changes: 1 addition & 1 deletion GitUI/CommandsDialogs/FormBrowse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct when toggling the option?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also applied this from the original commit, but I think it is wrong.
Even if the option is disabled, the grid should be refreshed to display the multi-line indicator in case someone changed a commit message from single to multi-line, e.g. during amend.
This should probably be removed unless I'm wrong about the mechanics.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is correct. The comment above explains why.
[Toggle]ShowCommitBodyInRevisionGrid() calls RevisionGridControl.Refresh().

{
RevisionGrid.Refresh();
}
Expand Down
4 changes: 4 additions & 0 deletions GitUI/Translation/English.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -8867,6 +8867,10 @@ See the changes in the commit form.</source>
<source>Show build status text</source>
<target />
</trans-unit>
<trans-unit id="showCommitMessageBodyToolStripMenuItem.Text">
<source>Show commit message body</source>
<target />
</trans-unit>
<trans-unit id="showDateColumnToolStripMenuItem.Text">
<source>Show date column</source>
<target />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ private void DrawCommitMessage(
return;
}

if (lines.Length > 1)
if (lines.Length > 1 && AppSettings.ShowCommitBodyInRevisionGrid)
{
var commitBody = string.Concat(lines.Skip(1).Select(_ => " " + _));
var bodyBounds = messageBounds.ReduceLeft(offset);
Expand Down
7 changes: 7 additions & 0 deletions GitUI/UserControls/RevisionGrid/RevisionGridControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2185,6 +2185,13 @@ internal void ToggleShowMergeCommits()
ForceRefreshRevisions();
}

internal void ToggleShowCommitBodyInRevisionGrid()
{
AppSettings.ShowCommitBodyInRevisionGrid = !AppSettings.ShowCommitBodyInRevisionGrid;
MenuCommands.TriggerMenuChanged();
Refresh();
}

internal void ShowFirstParent()
{
AppSettings.ShowFirstParent = !AppSettings.ShowFirstParent;
Expand Down
7 changes: 7 additions & 0 deletions GitUI/UserControls/RevisionGrid/RevisionGridMenuCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,13 @@ private IReadOnlyList<MenuCommand> CreateViewMenuCommands()
ExecuteAction = () => _revisionGrid.ToggleShowGitNotes(),
IsCheckedFunc = () => AppSettings.ShowGitNotes
},
new MenuCommand
{
Name = "showCommitMessageBodyToolStripMenuItem",
Text = "Show commit message body",
ExecuteAction = () => _revisionGrid.ToggleShowCommitBodyInRevisionGrid(),
IsCheckedFunc = () => AppSettings.ShowCommitBodyInRevisionGrid
},

MenuCommand.CreateSeparator(),

Expand Down
1 change: 1 addition & 0 deletions contributors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,4 @@ YYYY/MM/DD, github id, Full name, email
2021/03/31, darkcamper, Rubén Ruiz, darkcamper(at)gmail.com
2021/05/05, mrjithil, Jithil P Ponnan, jithil(at)outlook.com
2021/05/07, dasiths, Dasith Wijesiriwardena, gitextensions.github(at)dasith.me
2021/06/18, jwfx, Jörg Winkler, jwfx at bitmx.net