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
RevDiff: FirstRevision is null for the initial commit #8086
RevDiff: FirstRevision is null for the initial commit #8086
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8086 +/- ##
==========================================
+ Coverage 49.54% 49.57% +0.02%
==========================================
Files 847 848 +1
Lines 60916 60957 +41
Branches 10924 10927 +3
==========================================
+ Hits 30182 30217 +35
- Misses 28497 28504 +7
+ Partials 2237 2236 -1
|
7cfe454
to
9d7acd0
Compare
I guess what happens for "Open with Diff tool" menu entries if the selected file's FirstRevision is null are going to be weird or broken. The only one enabled is "first -> selected" but p4 merge doesn't like "nul" as the second file name idk if thats bug or not. Trying "cherry picked changes" for the same file does nothing idk if it should or not. |
This PR handles firstRev==null as "--root", so in supported difftools is works OK
A specific problem in p4merge, similar to tortoisemerge but you get a popup |
Yes the original issue is fixed for me. |
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.
Tests for RevisionDiffInfoProvider
changes?
GitUI/CommandsDialogs/FormDiff.cs
Outdated
var parentIds = DiffFiles.SelectedItems | ||
.Where(i => i.FirstRevision != null) | ||
.Select(i => i.FirstRevision.ObjectId) | ||
.Distinct() |
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're executing this selector multiple times.
Have you considered creating a property on FileStatusList
(similar to SelectedGitItems
) to simply the call sites?
E.g. something like:
public sealed partial class FileStatusList : GitModuleControl
{
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Browsable(false)]
public IEnumerable<FileStatusItem> SelectedGitObjects
{
get => SelectedItems
.Where(i => i.FirstRevision != null)
.Select(i => i.FirstRevision.ObjectId)
.Distinct();
}
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.
It was a little like this before, with many access functions. These properties applies to Enumerate for the selected items. Similar could apply to all items etc,
But I do not know how to do this in the best way, I assumed that a static helper on FileStatusItem would not be accepted, so I let that be.
Similar for First, Second, GitStatus.
(I was not ready thinking about this very late with #7899 and did not want to do any more changes...)
SelectedGitItems should be removed too, but it appeared in a little too many places.
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 added extension methods, OK now?
Added tests as well as reordered arguments |
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.
👍
b539c7f
to
6d3a2ae
Compare
6d3a2ae
to
5568333
Compare
Taking into 3.4 |
Fixes #8085
Proposed changes
Refactor: Align FirstParentId name
Guid suffix is quite consistently used for the string representation of the hash, while Id suffix is used for ObjectId, this was therefore switched
Some parentGuids changed too, not changing treeGuid
Use "--root" for first revision if null
Handle GitRevision == null as the root commit, before the initial commit, i.e. compare to /dev/null
SemanticMerge and KDiff3 shows such a diff, Tortoise does not for some reason
(The alternative would be to not add null to the revisions to diff which will result in a argument popup which is OK to me.)
RevDiff: FirstRevision is null for the initial commit
Handle that FirstRevision is not set for the initial commit
All situations changed are not causing problems, but it is easier to handle FirstRevision consistently this way.
Should be merged with these three merges, separate PR for 3.4 when approved
Test methodology
Review if FirstRevision usage and Manual
The (meaningless) IRevisionDiffController do not cover arguments in RevisionDiffControl
✒️ I contribute this code under The Developer Certificate of Origin.