8000 added lines and deleted lines in content changes by Stijn-Rutten · Pull Request #1790 · libgit2/libgit2sharp · GitHub
[go: up one dir, main page]

Skip to content

added lines and deleted lines in content changes #1790

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

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension 8000

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added Line struct and lists for addedlines and deletedlines in conten…
…t changes
  • Loading branch information
Stijn-Rutten committed Apr 30, 2020
commit 92b9e20edcb35da430ee698b20d3d12ce9ab87be
9 changes: 7 additions & 2 deletions LibGit2Sharp/ContentChanges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ protected ContentChanges()

internal unsafe ContentChanges(Repository repo, Blob oldBlob, Blob newBlob, GitDiffOptions options)
{
AddedLines = new List<Line>();
DeletedLines = new List<Line>();

Proxy.git_diff_blobs(repo.Handle,
oldBlob != null ? oldBlob.Id : null,
newBlob != null ? newBlob.Id : null,
Expand Down Expand Up @@ -52,9 +55,9 @@ internal void AppendToPatch(string patch)
/// </summary>
public virtual int LinesDeleted { get; internal set; }

public IEnumerable<Line> AddedLines { get; internal set; }
public List<Line> AddedLines { get; internal set; }

public IEnumerable<Line> DeletedLines { get; internal set; }
public 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.

/// <summary>
Expand Down Expand Up @@ -101,11 +104,13 @@ private unsafe int LineCallback(git_diff_delta* delta, GitDiffHunk hunk, GitDiff
switch (line.lineOrigin)
{
case GitDiffLineOrigin.GIT_DIFF_LINE_ADDITION:
AddedLines.Add(new Line(line.NewLineNo, decodedContent));
LinesAdded++;
prefix = Encoding.ASCII.GetString(new[] { (byte)line.lineOrigin });
break;

case GitDiffLineOrigin.GIT_DIFF_LINE_DELETION:
DeletedLines.Add(new Line(line.OldLineNo, decodedContent));
LinesDeleted++;
prefix = Encoding.ASCII.GetString(new[] { (byte)line.lineOrigin });
break;
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/Core/Line.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace LibGit2Sharp.Core
{
internal struct Line
public struct Line
{
/// <summary>
/// Points to the number of the original line in the blob
Expand Down
0