Libgit2sharp: Expose Diff Hunks in API

Created on 8 Jul 2015  路  6Comments  路  Source: libgit2/libgit2sharp

Rather than doing string parsing, I'd prefer having diff hunks available to mess with.

Most helpful comment

@Therzok, I was wondering if ContentChanges, rather than PatchEntryChanges, could be a more convenient place.

I would try extending the HunkCallback, or LineCallBack: they receive the GitDiffHunk which already contains the line indexes:

    internal class GitDiffHunk
    {
        public int OldStart;
        public int OldLines;
        public int NewStart;
        public int NewLines;
        public UIntPtr HeaderLen;

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
        public byte[] Header;
}

So far, they only append the patch chunk to the string builder, and increment LinesAdded and LinesDeleted. They could also append the chunk beginning and ending line to a collection.

All 6 comments

cc @nulltoken

Should we expose the hunks themselves together with the text patch? Inside PatchEntryChanges or something similar?

@Therzok, I was wondering if ContentChanges, rather than PatchEntryChanges, could be a more convenient place.

I would try extending the HunkCallback, or LineCallBack: they receive the GitDiffHunk which already contains the line indexes:

    internal class GitDiffHunk
    {
        public int OldStart;
        public int OldLines;
        public int NewStart;
        public int NewLines;
        public UIntPtr HeaderLen;

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
        public byte[] Header;
}

So far, they only append the patch chunk to the string builder, and increment LinesAdded and LinesDeleted. They could also append the chunk beginning and ending line to a collection.

Sounds good to me!

Are there any news on this?

Sorry, @ransagy, I completely moved to other topics. But right, I should complete what I promised. @ale7canna, would you like to help me with this?

Is there any progress on this? We need this for a new feature we're building at https://github.com/stryker-mutator/stryker-net

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tylercamp picture tylercamp  路  3Comments

wwwlicious picture wwwlicious  路  11Comments

roederja2 picture roederja2  路  15Comments

rerime picture rerime  路  8Comments

gitfool picture gitfool  路  4Comments