Skip to content

Commit

Permalink
ShowOnlyCurrentBranch were not showing commits
Browse files Browse the repository at this point in the history
Git Notes must be excluded for -all only
  • Loading branch information
gerhardol committed Oct 5, 2022
1 parent 22263a5 commit 96bb739
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 30 deletions.
41 changes: 19 additions & 22 deletions GitUI/UserControls/RevisionGrid/FilterInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,42 +310,39 @@ 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)
{
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");
}
}

Expand Down
23 changes: 15 additions & 8 deletions UnitTests/GitUI.Tests/UserControls/FilterInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 96bb739

Please sign in to comment.