What you need, the tree function is different , already exists in libgit2 , as defined in the tree.h header .
The git_tree_diff() function compares two Trees and calls a callback for each difference (add, update, and delete). The callback function is transferred by the git_tree_diff_data structure from the path to the file of the git_tree_diff_data in question, its status, the first and current file models, as well as the previous and current SHA.
From the point of view of LibGit2Sharp, it would be wiser to use the existing libgit2 function rather than repeating their implementation in C #. However, even if you can get inspiration from existing Interop definitions , things tend to quickly become tricky when trying to tame .Net / your own interaction layer.
From your point of view (since the contribution of LibGit2Sharp might not be your main goal;)), another option would be to put the C code in C # , drawing on existing LibGit2Sharp functions to go down the trees. git_tree_diff() (and its satellite functions) is a very clean piece of code, and although it does a fairly complex job, the comments are very clear and helpful.
Literature:
- The
git_tree_diff() function is implemented in src / tree.c - Tests that implement this feature are available here.
Note. . To bind git_tree_diff() , the problem must be opened in libgit2 tracker , requiring the method definition to be updated to be GIT_EXTERN 'd. Otherwise, it will not be accessible from .Net.
UPDATE
Release v0.9.0 LibGit2Sharp eventually brought the Tree to Tree function.
TreeChanges changes = repo.Diff.Compare(fromTree, newTree);
Public properties:
- Added / Modified Rows
- TreeEntry change collections for each kind of change (e.g., added, changed, ...)
- Patch diff
You can learn more about this function and how to use TreeChanges by looking at unit tests.
nulltoken
source share