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

added lines and deleted lines in content changes #1790

Conversation

Stijn-Rutten
Copy link
Contributor

This PR is related to issue #1789

@ethomson
Copy link
Member

This looks good to me, thanks @Stijn-Rutten. @bording any thoughts?

Copy link
Member

@bording bording left a comment

Choose a reason for hiding this comment

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

Overall looks good, but I have a few tweaks I'd like to see, and a couple of questions.

/// </summary>
public virtual List<Line> DeletedLines { get; internal set; }


Copy link
Member

Choose a reason for hiding this comment

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

Remove the extra line

Copy link
Member

Choose a reason for hiding this comment

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

Still need to clean up this extra line break.

LibGit2Sharp/Line.cs Outdated Show resolved Hide resolved
LibGit2Sharp/Line.cs Outdated Show resolved Hide resolved
@@ -68,6 +68,11 @@ private unsafe int PrintCallBack(git_diff_delta* delta, GitDiffHunk hunk, GitDif
PatchEntryChanges currentChange = this[filePath];
string prefix = string.Empty;

string decodedContent = LaxUtf8Marshaler.FromNative(line.content, (int)line.contentLen);
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this when this appears to be the same as the patchPart declaration on line 59?

Copy link
Member

Choose a reason for hiding this comment

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

This should able to be removed. You can just use the existing patchPart instead.

@@ -68,6 +68,11 @@ private unsafe int PrintCallBack(git_diff_delta* delta, GitDiffHunk hunk, GitDif
PatchEntryChanges currentChange = this[filePath];
string prefix = string.Empty;

string decodedContent = LaxUtf8Marshaler.FromNative(line.content, (int)line.contentLen);

currentChange.AddedLines = new List<Line>();
Copy link
Member

Choose a reason for hiding this comment

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

Why are these needed? Seems like this should be already handled in the ContentChanges constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added this in case the contructor that calls LineCallback on ContentChanges is not the constructor that is utilized by Patch. This way these values are always set. After fixing the declaration of the lists and adding tests. This does work. I would like to get your input on whether or not you think this is a viable option.

LibGit2Sharp/ContentChanges.cs Outdated Show resolved Hide resolved
LibGit2Sharp/ContentChanges.cs Outdated Show resolved Hide resolved
LibGit2Sharp/Line.cs Outdated Show resolved Hide resolved
LibGit2Sharp/Line.cs Outdated Show resolved Hide resolved
Stijn-Rutten and others added 4 commits May 27, 2020 20:35
…because linecallback isn't called in this case
Co-authored-by: Brandon Ording <bording@gmail.com>
Co-authored-by: Brandon Ording <bording@gmail.com>
Copy link
Member

@bording bording left a comment

Choose a reason for hiding this comment

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

There are a lot of unrelated formatting changes in the test files. It's a good practice to avoid those kind of unrelated changes in a PR, but in this case let's go ahead and keep them. I've made some specific comments about a couple changes I'd like to see undone, though.

LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs Outdated Show resolved Hide resolved
LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs Show resolved Hide resolved
LibGit2Sharp.Tests/DiffTreeToTargetFixture.cs Outdated Show resolved Hide resolved
LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs Outdated Show resolved Hide resolved
/// </summary>
public virtual List<Line> DeletedLines { get; internal set; }


Copy link
Member

Choose a reason for hiding this comment

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

Still need to clean up this extra line break.

LibGit2Sharp/ContentChanges.cs Outdated Show resolved Hide resolved
LibGit2Sharp/ContentChanges.cs Outdated Show resolved Hide resolved
LibGit2Sharp/ContentChanges.cs Outdated Show resolved Hide resolved
@@ -68,6 +68,11 @@ private unsafe int PrintCallBack(git_diff_delta* delta, GitDiffHunk hunk, GitDif
PatchEntryChanges currentChange = this[filePath];
string prefix = string.Empty;

string decodedContent = LaxUtf8Marshaler.FromNative(line.content, (int)line.contentLen);
Copy link
Member

Choose a reason for hiding this comment

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

This should able to be removed. You can just use the existing patchPart instead.

LibGit2Sharp/Patch.cs Outdated Show resolved Hide resolved
@Stijn-Rutten
Copy link
Contributor Author

Checks seem to be stuck, can someone force a restart?

@rouke-broersma
Copy link

@bording @ethomson @Stijn-Rutten How's this PR coming along? Looks like a lot was fixed since the last review

@Stijn-Rutten
Copy link
Contributor Author

@Mobrockers I processed @bording 's feedback and am waiting for a new review.

@Stijn-Rutten
Copy link
Contributor Author

@ethomson @bording @Mobrockers Could you take a look at this. We have been waiting for a while and could really use this feature.

@bording bording merged commit dbb17e7 into libgit2:master Nov 7, 2020
@rouke-broersma
Copy link

@bording 🎉🎉🎉🎉🎉🎉🎉🎉

@bording
Copy link
Member

bording commented Nov 23, 2020

FYI these changes are part of 0.27.0-preview-0096, which was just published.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants