private unsafe int LineCallback(git_diff_delta *delta, GitDiffHunk hunk, GitDiffLine line, IntPtr payload) { string decodedContent = LaxUtf8Marshaler.FromNative(line.content, (int)line.contentLen); string prefix; 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; case GitDiffLineOrigin.GIT_DIFF_LINE_CONTEXT: prefix = Encoding.ASCII.GetString(new[] { (byte)line.lineOrigin }); break; default: prefix = string.Empty; break; } AppendToPatch(prefix); AppendToPatch(decodedContent); return(0); }
internal void AppendGitDiffLine(GitDiffLine line, string patch) { switch (line.lineOrigin) { case GitDiffLineOrigin.GIT_DIFF_LINE_ADDITION: AddedLines.Add(new Line(line.NewLineNo, patch)); LinesAdded++; lines.Add(new ContentChangeLine(line)); break; case GitDiffLineOrigin.GIT_DIFF_LINE_DELETION: DeletedLines.Add(new Line(line.OldLineNo, patch)); LinesDeleted++; lines.Add(new ContentChangeLine(line)); break; } }