Libgit2sharp: How to get lines modified in a commit

Created on 8 Sep 2017  路  3Comments  路  Source: libgit2/libgit2sharp

My question is as stated in the title - I want to get the specific line numbers that were changed in a commit. I've been looking at Repository.Diff.Compare<Patch> but the info I need isn't there...

Most helpful comment

@tylercamp, @ale7canna and I are working on one, and will propose a PR soon.
So far, I'm relying on the regex

 @"@@\s\-(?<oldFrom>\d+),(?<oldLength>\d+)\s\+(?<newFrom>\d+),(?<newLength>\d+).*\s@@";

which can extract the information you are looking for from the patch itself. In our PR we aim to provide libgit2sharp with a more convenient, native C# API.

All 3 comments

Hi @tylercamp.
@ale7canna and I are trying to get the same information. So far, the only option I see is to parse the string Patch property of PatchEntryChanges. Chances are in the meanwhile you found a more convenient way...

Also, this seems a duplicate of #1142

@arialdomartini Sadly we didn't find a solution, and efforts were directed elsewhere.

@tylercamp, @ale7canna and I are working on one, and will propose a PR soon.
So far, I'm relying on the regex

 @"@@\s\-(?<oldFrom>\d+),(?<oldLength>\d+)\s\+(?<newFrom>\d+),(?<newLength>\d+).*\s@@";

which can extract the information you are looking for from the patch itself. In our PR we aim to provide libgit2sharp with a more convenient, native C# API.

Was this page helpful?
0 / 5 - 0 ratings