diff --git a/GitUI/UserControls/RevisionGrid/FilterInfo.cs b/GitUI/UserControls/RevisionGrid/FilterInfo.cs index 6901ea80c19..5735539255e 100644 --- a/GitUI/UserControls/RevisionGrid/FilterInfo.cs +++ b/GitUI/UserControls/RevisionGrid/FilterInfo.cs @@ -310,15 +310,24 @@ public ArgumentString GetRevisionFilter() { filter.Add("--reflog"); } + else if (ShowCurrentBranchOnly) + { + // Default git-log, only current branch, no option + } + else if (!string.IsNullOrWhiteSpace(BranchFilter)) + { + // Show filtered branches only + filter.Add(IsSimpleBranchFilter(BranchFilter) ? BranchFilter : "--branches=" + BranchFilter); + } else { - // Note that some refs (like notes) requires --all or explicit inclusion (--glob) - // (None is evaluated as HEAD) + // refs (like notes) requires --all or explicit inclusion (--glob) + // (not explicitly added for other than --all) // These options are explicitly excluded when not desired // "other refs" include Gerrit refs like refs/for/ and refs/changes/ if (!AppSettings.ShowGitNotes) { - filter.Add("--not --glob=notes --not"); + filter.Add("--exclude=refs/notes"); } if (!AppSettings.ShowStashes) @@ -326,26 +335,14 @@ public ArgumentString GetRevisionFilter() filter.Add("--exclude=refs/stash"); } - if (ShowCurrentBranchOnly) - { - // Default git-log, only current branch, no option - } - else if (!string.IsNullOrWhiteSpace(BranchFilter)) - { - // Show filtered branches only - filter.Add(IsSimpleBranchFilter(BranchFilter) ? BranchFilter : "--branches=" + BranchFilter); - } - else - { - // All branches - filter.Add("--all"); + // All branches + filter.Add("--all"); - // The inclusion of boundary parents to matches is historical - // (why Message etc is handled as a special case) - if (!string.IsNullOrWhiteSpace(Message) && !string.IsNullOrWhiteSpace(DiffContent)) - { - filter.Add("--boundary"); - } + // The inclusion of boundary parents to matches is historical + // (why Message etc is handled as a special case) + if (!string.IsNullOrWhiteSpace(Message) && !string.IsNullOrWhiteSpace(DiffContent)) + { + filter.Add("--boundary"); } } diff --git a/UnitTests/GitUI.Tests/UserControls/FilterInfoTests.cs b/UnitTests/GitUI.Tests/UserControls/FilterInfoTests.cs index 09c468702ed..617567939c2 100644 --- a/UnitTests/GitUI.Tests/UserControls/FilterInfoTests.cs +++ b/UnitTests/GitUI.Tests/UserControls/FilterInfoTests.cs @@ -810,7 +810,7 @@ public void FilterInfo_ResetAllFilters_expected(bool byDateFrom, bool byDateTo, [TestCase("author1", "committer2", "message3", "diffContent4", true, false, "pathFilter7", false, false, "branchFilter8", "Path filter: pathFilter7\r\nBranches: branchFilter8\r\nAuthor: author1\r\nCommitter: committer2\r\nMessage: message3\r\nDiff contains: diffContent4\r\nSince: 10/1/2021 1:30:34 AM\r\nUntil: 11/1/2021 1:30:34 AM\r\nSimplify by decoration\r\n", - @"--max-count=100000 --not --glob=notes --not branchFilter8 --parents --no-merges --simplify-by-decoration --author=""author1"" --committer=""committer2"" --grep=""message3"" -G""diffContent4"" --regexp-ignore-case --since=""2021-10-01 01:30:34"" --until=""2021-11-01 01:30:34""")] + @"--max-count=100000 branchFilter8 --parents --no-merges --simplify-by-decoration --author=""author1"" --committer=""committer2"" --grep=""message3"" -G""diffContent4"" --regexp-ignore-case --since=""2021-10-01 01:30:34"" --until=""2021-11-01 01:30:34""")] public void FilterInfo_GetRevisionFilter(string author, string committer, string message, string diffContent, bool showSimplifyByDecoration, bool showMergeCommits, string pathFilter, bool showReflog, bool showCurrentBranchOnly, string branchFilter, string expectedSummary, string expectedArgs) { DateTime dateFrom = new(2021, 10, 1, 1, 30, 34, DateTimeKind.Local); @@ -1000,24 +1000,31 @@ public void FilterInfo_Stashes(bool expected) } } - [TestCase(false)] - [TestCase(true)] - public void FilterInfo_GitNotes(bool expected) + [TestCase(false, false, false)] + [TestCase(false, true, true)] + [TestCase(true, false, true)] + [TestCase(true, true, true)] + public void FilterInfo_GitNotes(bool showGitNotes, bool currentBranchOnly, bool expected) { bool originalShowGitNotes = AppSettings.ShowGitNotes; - AppSettings.ShowGitNotes = expected; - FilterInfo filterInfo = new(); + AppSettings.ShowGitNotes = showGitNotes; + FilterInfo filterInfo = new() + { + ShowReflogReferences = false, + ShowCurrentBranchOnly = currentBranchOnly, + ByBranchFilter = false + }; string args = filterInfo.GetRevisionFilter(); try { if (expected) { - args.ToString().Should().NotMatchRegex(@"[^\s]?--not --glob=notes --not"); + args.ToString().Should().NotMatchRegex(@"[^\s]?--exclude=refs/notes"); } else { - args.ToString().Should().MatchRegex(@"[^\s]?--not --glob=notes --not"); + args.ToString().Should().MatchRegex(@"[^\s]?--exclude=refs/notes"); } } finally