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

Insert artificial commits if filter without any matches is applied #10163

Merged
Changes from 1 commit
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
21 changes: 16 additions & 5 deletions GitUI/UserControls/RevisionGrid/RevisionGridControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1192,13 +1192,14 @@ bool ShowArtificialRevisions()
&& !Module.IsBareRepository();
}

bool AddArtificialRevisions(bool insertWithMatch = false, IEnumerable<ObjectId> headParents = null)
bool AddArtificialRevisions(IEnumerable<ObjectId> headParents = null)
{
if (!ShowArtificialRevisions())
{
return false;
}

bool insertWithMatch = headParents is not null;
var userName = Module.GetEffectiveSetting(SettingKeyString.UserName);
var userEmail = Module.GetEffectiveSetting(SettingKeyString.UserEmail);

Expand Down Expand Up @@ -1258,7 +1259,7 @@ void OnRevisionReadCompleted()
{
await TaskScheduler.Default;

// No revisions at all received
// No revisions at all received without any filter
await semaphoreUpdateGrid.WaitAsync(cancellationToken);

bool showArtificial = AddArtificialRevisions();
Expand Down Expand Up @@ -1291,7 +1292,7 @@ void OnRevisionReadCompleted()

IEnumerable<ObjectId> headParents = null;
bool refresh = false;
if (firstRevisionReceived && !headIsHandled && ShowArtificialRevisions())
if (!headIsHandled && ShowArtificialRevisions())
{
if (CurrentCheckout is not null)
{
Expand All @@ -1301,7 +1302,7 @@ void OnRevisionReadCompleted()

// If parents are rewritten HEAD may not be included
// Insert the artificial commits where relevant if possible, otherwise first
refresh = AddArtificialRevisions(insertWithMatch: true, headParents);
refresh = AddArtificialRevisions(headParents);
}

// All revisions are loaded (but maybe not yet the grid)
Expand All @@ -1324,7 +1325,17 @@ void OnRevisionReadCompleted()
}
else
{
parents = TryGetParents(Module, _filterInfo, notSelectedId);
if (notSelectedId.IsArtificial)
{
notSelectedId = CurrentCheckout is not null
? CurrentCheckout
: _gridView.ToBeSelectedObjectIds.Where(id => !id.IsArtificial).FirstOrDefault();
}

if (notSelectedId is not null)
{
parents = TryGetParents(Module, _filterInfo, notSelectedId);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

To keep it simple, the following can be reduced with the drawback that unselecting ShowArtificial while artificial is selected will not select anything

Suggested change
if (notSelectedId.IsArtificial)
{
notSelectedId = CurrentCheckout is not null
? CurrentCheckout
: _gridView.ToBeSelectedObjectIds.Where(id => !id.IsArtificial).FirstOrDefault();
}
if (notSelectedId is not null)
{
parents = TryGetParents(Module, _filterInfo, notSelectedId);
}
if (!notSelectedId.IsArtificial)
{
parents = TryGetParents(Module, _filterInfo, notSelectedId);
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Simplified this, added a comment instead
(The snippet was written when the solution was slightly different, I kept it though)

}

// Try to select the first of the parents
Expand Down