Reputation: 1245
I'm trying to implement my own feature request to the Visual Studio extension CommitFormatter, and I need the git diff patch for that. I could use libgit2sharp (which I expect to be easy), however, that will pull in an additional dependency. A burden I don't want to add on the extension, if it's not needed.
I expect that it's possible to get the same using one of the APIs of Team Explorer, but I'm a bit overwhelmed with the amount of libraries Microsoft.TeamExplorer.*.dll
libraries that Visual Studio contains, and cannot find any good MSDN pages for this.
What I want to achieve is to get the "diff patch" of the staging area, the output that git diff --cached
" from the command line gives you, but then using the Team Explorer API. Similar to what libgit2sharp
's repo.Diff.Compare<Patch>(repo.Head.Tip.Tree, DiffTargets.Index)
would give you.
Upvotes: 1
Views: 497
Reputation: 78703
There is no Microsoft.TeamExplorer
assembly that provides a git diff, public or private.
Depending on the version, Team Explorer either uses LibGit2Sharp to interact with the git repository (prior to VS 2017) or uses git
(VS 2017).
However, no version actually creates git diff files. The difference view takes the raw files out of the repository and calculates the differences and displays them itself, it does not use patch files as an input or as an intermediate step.
You should either use LibGit2Sharp or call git
to produce a diff.
Upvotes: 2