libgit2sharp icon indicating copy to clipboard operation
libgit2sharp copied to clipboard

Expose Diff Hunks in API

Open Therzok opened this issue 10 years ago • 9 comments

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

Therzok avatar Jul 08 '15 18:07 Therzok

cc @nulltoken

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

Therzok avatar Jul 10 '15 19:07 Therzok

@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.

arialdomartini avatar Nov 03 '18 17:11 arialdomartini

Sounds good to me!

Therzok avatar Nov 03 '18 18:11 Therzok

Are there any news on this?

ransagy avatar Sep 18 '19 17:09 ransagy

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?

arialdomartini avatar Sep 22 '19 10:09 arialdomartini

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

rouke-broersma avatar Apr 24 '20 08:04 rouke-broersma

@Therzok @arialdomartini Is there any progress on this topic? Is there a low-level API or similar that we can hack to get the hunks? The use case I have is to show the original and the current file including the changes made to it.

todor-dk avatar Apr 23 '24 13:04 todor-dk

@todor-dk Sorry, I have completely moved to other topics. The same with @ale7canna I suppose. I hope someone working on this project may support your needs!

arialdomartini avatar Apr 23 '24 13:04 arialdomartini

I'm thinking of providing a patch for this as I also need the function. Would it make more sense to create wrapper objects around all the data objects or would it be preferable that I make the objects public (where they don't have ptr variables)? I was thinking to implement it in a way so that people can just extend the needed interfaces and then will be called by the lib after starting the call.

kammerjaeger avatar Apr 16 '25 20:04 kammerjaeger