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
Fix submodule status loading error #8881
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8881 +/- ##
==========================================
+ Coverage 56.03% 56.06% +0.02%
==========================================
Files 922 922
Lines 65944 65847 -97
Branches 12070 12084 +14
==========================================
- Hits 36951 36915 -36
+ Misses 25985 25921 -64
- Partials 3008 3011 +3
Flags with carried forward coverage won't be shown. Click here to find out more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quick check only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a proposal to a local branch, using pattern matching declarations where possible and find the code much more easy to read
GitUI/CommandsDialogs/FormCommit.cs
Outdated
Task<GitSubmoduleStatus?>? statusTask = item.GetSubmoduleStatusAsync(); | ||
Validates.NotNull(statusTask); | ||
if (!statusTask.IsCompleted) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm struggling with this - statusTask
can be null
, and in case when it is will it throw on line:1956 or line:1957?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rewrote most of the checks using pattern matching declarations, I find this much easier to read
GitUI/UserControls/FileStatusList.cs
Outdated
if (item.IsSubmodule | ||
&& item.GetSubmoduleStatusAsync() is Task<GitSubmoduleStatus> task | ||
&& task is not null | ||
&& !task.IsCompleted) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to remove this check to set status om L942
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the check in a separate push
c56caa6
to
de7ac35
Compare
Refactoring during annotation identified a potential issue here, but the change was not correct. This change allows the task itself to be null (an uncommon pattern) which indicates that `SetSubmoduleStatus` has not been called.
959eb9f
to
d4d094b
Compare
&& item.GetSubmoduleStatusAsync() is Task<GitSubmoduleStatus> task | ||
&& task is not null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gerhardol the type check is essentially a null check too.
&& item.GetSubmoduleStatusAsync() is Task<GitSubmoduleStatus> task | |
&& task is not null) | |
&& item.GetSubmoduleStatusAsync() is Task<GitSubmoduleStatus> task) |
I'm not a fan of this code though. It makes it look like a runtime type test is needed, which is not the case. This is just a null check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way of writing this is:
&& item.GetSubmoduleStatusAsync() is Task<GitSubmoduleStatus> task | |
&& task is not null) | |
&& item.GetSubmoduleStatusAsync() is { } task) |
But is that actually better than assigning the task to a local and doing an explicit is not null
test? The only downside is a bit of nesting, which is not the end of the world.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had this discussion before: This is a hard to read. One does not need to use every new C# syntax invention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The task is not null
checks in FileStatusList.cs are not needed.
I changed to that style as it is required in FormCommit
I prefer to have a minimal code why my preference is to just removing is not null where possible.
Fixes @gerhardol's comments on #8875
Proposed changes
Refactoring during annotation identified a potential issue here, but the change was not correct. This change allows the task itself to be null (an uncommon pattern) which indicates that
SetSubmoduleStatus
has not been called.Test methodology
To trigger the broken behaviour:
✒️ I contribute this code under The Developer Certificate of Origin.