Skip to content

Commit 92b9e20

Browse files
committed
Added Line struct and lists for addedlines and deletedlines in content changes
1 parent 79e11b9 commit 92b9e20

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

LibGit2Sharp/ContentChanges.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ protected ContentChanges()
2323

2424
internal unsafe ContentChanges(Repository repo, Blob oldBlob, Blob newBlob, GitDiffOptions options)
2525
{
26+
AddedLines = new List<Line>();
27+
DeletedLines = new List<Line>();
28+
2629
Proxy.git_diff_blobs(repo.Handle,
2730
oldBlob != null ? oldBlob.Id : null,
2831
newBlob != null ? newBlob.Id : null,
@@ -52,9 +55,9 @@ internal void AppendToPatch(string patch)
5255
/// </summary>
5356
public virtual int LinesDeleted { get; internal set; }
5457

55-
public IEnumerable<Line> AddedLines { get; internal set; }
58+
public List<Line> AddedLines { get; internal set; }
5659

57-
public IEnumerable<Line> DeletedLines { get; internal set; }
60+
public List<Line> DeletedLines { get; internal set; }
5861

5962

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

108112
case GitDiffLineOrigin.GIT_DIFF_LINE_DELETION:
113+
DeletedLines.Add(new Line(line.OldLineNo, decodedContent));
109114
LinesDeleted++;
110115
prefix = Encoding.ASCII.GetString(new[] { (byte)line.lineOrigin });
111116
break;

LibGit2Sharp/Core/Line.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace LibGit2Sharp.Core
66
{
7-
internal struct Line
7+
public struct Line
88
{
99
/// <summary>
1010
/// Points to the number of the original line in the blob

0 commit comments

Comments
 (0)