I do not think LibGit2Sharp should start an external process. The goal of LibGit2Sharp is to provide an easy way to manage your git repository.
This means that you can use it to:
Get the difference between the files in workdir and the previous version (in the index). To do this, you can use the Repository.Diff.Compare(IEnumerable<string> paths, bool includeUntracked, ExplicitPathsOptions explicitPathsOptions) overload Repository.Diff.Compare(IEnumerable<string> paths, bool includeUntracked, ExplicitPathsOptions explicitPathsOptions) , which returns a TreeChanges object. From there, you can get the TreeEntryChanges object through the TreeEntryChanges indexer that matches the changes to the given file (use the .Patch property to get the actual contents of the patch).
Get the configured markup tool using the Repository.Config namespace (for example: repo.Config.Get<string>("diff.tool").Value , although you should also check if the value returned by the Get() method is zero, if the diff tool is not configured by the user). This way you can run the diff tool yourself.
Additional resources (v0.11.0):
Note : it seems that at some point you will need to know if the row has changed or not. I donβt think there is an easy way to do this right now (except for parsing the contents of the patch manually). However, opening a problem in the LibGit2Sharp problem tracking log may provoke some discussion around this (feel free to weigh what API you would like to have for this!).
Change Before starting the external comparison tool, you will need to copy the contents of the file located in the index to a temporary folder. You can find the blob file in the index by doing something like:
- var indexEntry = repo.Index [file_name];
- var blob = repo.Lookup (indexEntry.Id);
However ... filters are not applied when you receive blob content, so comparisons are likely to result in false positives due to crlf differences. An issue is currently open on libgit2 to offer an API for applying filters.
yorah source share