Skip to content

Commit

Permalink
Reorder and group items in View menu (#10189)
Browse files Browse the repository at this point in the history
Group the menu items to reflect how the items are used,
separated with group headings

A number of related fixes:

* stash and notes could be shown with current and filtered branches
This normally did not occur as they were filtered, but it affected tests.

* Decouple ShowMergeCommits and ShowRevisionGridGraphColumn
(column can be shown when this filter is enabled)

* Reflog was not coupled with other branch revision filters
Even if Reflog dominated the other branch revision filters,
this was not reflected in the menus.
Also toggling the reflog (with the button) would set the branchfilter
to all branches.

* Add reflog to branch filter dropdown, to show current filter

* Consistently name reflog/reflogs to "reflog"
Except for "noreflogs" for "fsck-objects --no-reflogs"

(cherry picked from commit 480458b)
  • Loading branch information
gerhardol committed Sep 21, 2022
1 parent b6b5706 commit 0d5e881
Show file tree
Hide file tree
Showing 15 changed files with 360 additions and 221 deletions.
11 changes: 7 additions & 4 deletions GitCommands/RevisionReader.RefFilterOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,26 @@ namespace GitCommands
[Flags]
public enum RefFilterOptions
{
None = 0x000,
None = 0x000, // Git default, current branch
Branches = 0x001, // --branches=<filter>

// Unused
// Remotes = 0x002, // --remotes
// Tags = 0x004, // --tags
All = 0x007, // --all (default is HEAD)
Reflog = 0x200, // --reflog

// Exclude some refs from --all
// Exclude some refs from other than reflog
NoStash = 0x008, // --exclude=refs/stash
NoGitNotes = 0x010, // --not --glob=notes --not

// Other revision filters
NoMerges = 0x020, // --no-merges
FirstParent = 0x040, // --first-parent
SimplifyByDecoration = 0x080, // --simplify-by-decoration
Boundary = 0x100, // --boundary
Reflogs = 0x200, // --reflog

// history simplification
SimplifyByDecoration = 0x080, // --simplify-by-decoration
}
#pragma warning restore SA1025 // Code should not contain multiple whitespace in a row
}
33 changes: 21 additions & 12 deletions GitCommands/RevisionReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,32 +189,34 @@ private IReadOnlyCollection<GitRevision> GetRevisionsFromArguments(GitArgumentBu
string pathFilter,
out bool parentsAreRewritten)
{
parentsAreRewritten = !string.IsNullOrWhiteSpace(pathFilter) || !string.IsNullOrWhiteSpace(revisionFilter);
parentsAreRewritten = !string.IsNullOrWhiteSpace(pathFilter)
|| !string.IsNullOrWhiteSpace(revisionFilter)
|| refFilterOptions.HasFlag(RefFilterOptions.NoMerges);

return new GitArgumentBuilder("log")
{
{ maxCount > 0, $"--max-count={maxCount}" },
"-z",
$"--pretty=format:\"{LogFormat}\"",

// sorting
{ AppSettings.RevisionSortOrder == RevisionSortOrder.AuthorDate, "--author-date-order" },
{ AppSettings.RevisionSortOrder == RevisionSortOrder.Topology, "--topo-order" },
{ refFilterOptions.HasFlag(RefFilterOptions.Boundary), "--boundary" },
{ refFilterOptions.HasFlag(RefFilterOptions.NoMerges), "--no-merges" },
{ refFilterOptions.HasFlag(RefFilterOptions.SimplifyByDecoration), "--simplify-by-decoration" },
{ refFilterOptions.HasFlag(RefFilterOptions.FirstParent), "--first-parent" },

// revision branch filter
{
refFilterOptions.HasFlag(RefFilterOptions.Reflogs),
refFilterOptions.HasFlag(RefFilterOptions.Reflog),
"--reflog",
new ArgumentBuilder
{
// refs to exclude
{ refFilterOptions.HasFlag(RefFilterOptions.NoGitNotes), "--not --glob=notes --not" },
{ refFilterOptions.HasFlag(RefFilterOptions.NoStash), "--exclude=refs/stash" },

// all, filtered or current (none)
{
refFilterOptions.HasFlag(RefFilterOptions.All),
new ArgumentBuilder
{
{ refFilterOptions.HasFlag(RefFilterOptions.NoGitNotes), "--not --glob=notes --not" },
{ refFilterOptions.HasFlag(RefFilterOptions.NoStash), "--exclude=refs/stash" },
"--all",
}.ToString(),
"--all",
new ArgumentBuilder
{
{
Expand All @@ -232,11 +234,18 @@ private IReadOnlyCollection<GitRevision> GetRevisionsFromArguments(GitArgumentBu
}
}.ToString()
},

// revision filters
{ refFilterOptions.HasFlag(RefFilterOptions.Boundary), "--boundary" },
{ refFilterOptions.HasFlag(RefFilterOptions.NoMerges), "--no-merges" },
{ refFilterOptions.HasFlag(RefFilterOptions.FirstParent), "--first-parent" },
{ refFilterOptions.HasFlag(RefFilterOptions.SimplifyByDecoration), "--simplify-by-decoration" },
revisionFilter,
{
parentsAreRewritten,
new ArgumentBuilder
{
// History simplification
{ AppSettings.FullHistoryInFileHistory, $"--full-history" },
{
AppSettings.FullHistoryInFileHistory && AppSettings.SimplifyMergesInFileHistory,
Expand Down
28 changes: 28 additions & 0 deletions GitUI/CommandsDialogs/BrowseDialog/MenuCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,36 @@ public static MenuCommand CreateSeparator()
return new MenuCommand { IsSeparator = true };
}

public static MenuCommand CreateGroupHeader(string text)
{
return new MenuCommand
{
IsGroupHeader = true,
Name = text.Replace(' ', '_') + "ToolStripMenuItem",
Text = text,
};
}

public static ToolStripItem CreateToolStripItem(MenuCommand menuCommand)
{
if (menuCommand.IsSeparator)
{
return new ToolStripSeparator();
}

if (menuCommand.IsGroupHeader)
{
ToolStripMenuItem headerToolStripMenuItem = new()
{
Name = menuCommand.Name,
Text = menuCommand.Text,
Enabled = false,
};
UserControls.RevisionGrid.MenuUtil.SetAsCaptionMenuItem(headerToolStripMenuItem);

return headerToolStripMenuItem;
}

ToolStripMenuItem toolStripMenuItem = new()
{
Name = menuCommand.Name,
Expand Down Expand Up @@ -60,6 +83,11 @@ public static ToolStripItem CreateToolStripItem(MenuCommand menuCommand)
/// </summary>
public bool IsSeparator { get; set; }

/// <summary>
/// if true just text property have a meaning.
/// </summary>
public bool IsGroupHeader { get; set; }

/// <summary>
/// used for ToolStripItem and translation identification.
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion GitUI/CommandsDialogs/FormBrowse.InitRevisionGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ private void InitRevisionGrid(ObjectId? selectedId, ObjectId? firstId, bool isBl
}
// Apply filtering when:
// 1. don't show reflogs, and
// 1. don't show reflog, and
// 2. one of the following
// a) show the current branch only, or
// b) filter on specific branch
// (this check ignores other revision filters)
bool isFiltering = !AppSettings.ShowReflogReferences
&& (AppSettings.ShowCurrentBranchOnly || AppSettings.BranchFilterEnabled);
repoObjectsTree.Refresh(isFiltering, e.ForceRefresh, e.GetRefs);
Expand Down
36 changes: 34 additions & 2 deletions GitUI/Translation/English.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3215,6 +3215,10 @@ Do you want to continue?</source>
<source>&amp;Translate</source>
<target />
</trans-unit>
<trans-unit id="tsbShowReflog.ToolTipText">
<source>Show reflog</source>
<target />
</trans-unit>
<trans-unit id="tsbtnAdvancedFilter.ToolTipText">
<source>Advanced filter</source>
<target />
Expand Down Expand Up @@ -3315,8 +3319,12 @@ Do you want to continue?</source>
<source>Show first parents</source>
<target />
</trans-unit>
<trans-unit id="tsmiShowReflogs.ToolTipText">
<source>Show reflogs</source>
<trans-unit id="tsmiShowReflog.Text">
<source>&amp;Reflog</source>
<target />
</trans-unit>
<trans-unit id="tsmiShowReflog.ToolTipText">
<source>Show reflog</source>
<target />
</trans-unit>
<trans-unit id="tsmiTelemetryEnabled.Text">
Expand Down Expand Up @@ -9611,6 +9619,18 @@ See the changes in the commit form.</source>
<source>&amp;Sort commits by author date</source>
<target />
</trans-unit>
<trans-unit id="BranchesToolStripMenuItem.Text">
<source>Branches</source>
<target />
</trans-unit>
<trans-unit id="ColumnsToolStripMenuItem.Text">
<source>Columns</source>
<target />
</trans-unit>
<trans-unit id="CommitsToolStripMenuItem.Text">
<source>Commits</source>
<target />
</trans-unit>
<trans-unit id="GotoChildCommit.Text">
<source>Go to c&amp;hild commit</source>
<target />
Expand All @@ -9635,6 +9655,14 @@ See the changes in the commit form.</source>
<source>Go to &amp;parent commit</source>
<target />
</trans-unit>
<trans-unit id="Grid_infoToolStripMenuItem.Text">
<source>Grid info</source>
<target />
</trans-unit>
<trans-unit id="Grid_labelsToolStripMenuItem.Text">
<source>Grid labels</source>
<target />
</trans-unit>
<trans-unit id="HighlightSelectedBranch.Text">
<source>Highlight selected branch (until refresh)</source>
<target />
Expand Down Expand Up @@ -9703,6 +9731,10 @@ See the changes in the commit form.</source>
<source>Show su&amp;perproject tags</source>
<target />
</trans-unit>
<trans-unit id="SortingToolStripMenuItem.Text">
<source>Sorting</source>
<target />
</trans-unit>
<trans-unit id="ToggleBetweenArtificialAndHeadCommits.Text">
<source>&amp;Toggle between artificial and HEAD commits</source>
<target />
Expand Down
46 changes: 28 additions & 18 deletions GitUI/UserControls/FilterToolBar.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0d5e881

Please sign in to comment.