8000 Set deleted and added lines in patch printcallback · dotdevelop/libgit2sharp@3c777dc · GitHub
[go: up one dir, main page]

Skip to content

Commit 3c777dc

Browse files
committed
Set deleted and added lines in patch printcallback
1 parent 70b6bd7 commit 3c777dc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

LibGit2Sharp/Patch.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ private unsafe int PrintCallBack(git_diff_delta* delta, GitDiffHunk hunk, GitDif
6868
PatchEntryChanges currentChange = this[filePath];
6969
string prefix = string.Empty;
7070

71+
string decodedContent = LaxUtf8Marshaler.FromNative(line.content, (int)line.contentLen);
72+
73+
currentChange.AddedLines = new List<Line>();
74+
currentChange.DeletedLines = new List<Line>();
75+
7176
switch (line.lineOrigin)
7277
{
7378
case GitDiffLineOrigin.GIT_DIFF_LINE_CONTEXT:
@@ -77,12 +82,14 @@ private unsafe int PrintCallBack(git_diff_delta* delta, GitDiffHunk hunk, GitDif
7782
case GitDiffLineOrigin.GIT_DIFF_LINE_ADDITION:
7883
linesAdded++;
7984
currentChange.LinesAdded++;
85+
currentChange.AddedLines.Add(new Line(line.NewLineNo, decodedContent));
8086
prefix = "+";
8187
break;
8288

8389
case GitDiffLineOrigin.GIT_DIFF_LINE_DELETION:
8490
linesDeleted++;
8591
currentChange.LinesDeleted++;
92+
currentChange.DeletedLines.Add(new Line(line.OldLineNo, decodedContent));
8693
prefix = "-";
8794
break;
8895
}

0 commit comments

Comments
 (0)
0