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

Handle all message filters starting with -- as git-log options #10943

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 3 additions & 8 deletions GitUI/UserControls/RevisionGrid/FilterInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ public record FilterInfo
private string _branchFilter = string.Empty;
private int _commitsLimit = -1;

/// <summary>
/// Prefix to "Message" filters that forces the text to be interpreted as Git options.
/// This enables use of options not available in the GUI.
/// </summary>
private readonly string[] _messageAsGitOptions = new[] { "--not ", "--exclude=" };

/// <summary>
/// Gets whether all properties will unconditionally return the underlying data.
/// Otherwise return values will depend on the respective filter, e.g. "get => ByXyz ? Xyz : default".
Expand Down Expand Up @@ -388,8 +382,9 @@ private void GetLimitingRevisionFilter(ArgumentBuilder filter)

if (ByMessage && !string.IsNullOrWhiteSpace(Message))
{
if (Message.StartsWithAny(_messageAsGitOptions))
if (Message.StartsWith("--"))
{
// Add as git-log options
filter.Add(Message);
}
else
Expand Down Expand Up @@ -560,7 +555,7 @@ private void GetLimitingFilterSummary(StringBuilder filter)

if (ByMessage && !string.IsNullOrEmpty(Message))
{
if (Message.StartsWithAny(_messageAsGitOptions))
if (Message.StartsWith("--"))
{
filter.AppendLine(Message);
}
Expand Down
4 changes: 2 additions & 2 deletions UnitTests/GitUI.Tests/UserControls/FilterInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,10 +1183,10 @@ string GetFilterRefName(string gitRef)

[TestCase("message1", true)]
[TestCase("message1 --not", true)]
[TestCase("--not=message1", true)]
[TestCase("--not=message1", false)]
[TestCase("--not message1", false)]
[TestCase(" --not message1", true)]
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 intended? Else .TrimLeft().StartsWith("--")?

Copy link
Member Author

Choose a reason for hiding this comment

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

(unchanged from before)
The message to search for is not trimmed, initial and trailing whitespace is searched for.

[TestCase("--exclude message1", true)]
[TestCase("--exclude message1", false)]
[TestCase("--exclude= message1", false)]
[TestCase("--exclude= message1 ", false)]
[TestCase("\t--exclude= message1", true)]
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Expand Down