Skip to content

Commit

Permalink
Insert artificial commits if filter without any matches is applied (#…
Browse files Browse the repository at this point in the history
…10163)

Handle selection after refresh if artificial commits are
removed from the view
  • Loading branch information
gerhardol committed Aug 25, 2022
1 parent 1d19b10 commit 9602c30
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions GitUI/UserControls/RevisionGrid/RevisionGridControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1196,13 +1196,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 @@ -1262,7 +1263,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 @@ -1295,7 +1296,7 @@ void OnRevisionReadCompleted()
IEnumerable<ObjectId> headParents = null;
bool refresh = false;
if (firstRevisionReceived && !headIsHandled && ShowArtificialRevisions())
if (!headIsHandled && ShowArtificialRevisions())
{
if (CurrentCheckout is not null)
{
Expand All @@ -1305,7 +1306,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 @@ -1326,8 +1327,9 @@ void OnRevisionReadCompleted()
{
parents = headParents.Skip(index + 1).ToList();
}
else
else if (!notSelectedId.IsArtificial)
{
// Ignore if the not selected is artificial, it is likely that the settings was changed
parents = TryGetParents(Module, _filterInfo, notSelectedId);
}
Expand Down

0 comments on commit 9602c30

Please sign in to comment.