Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't think it should be the responsibility of LibGit2Sharp to launch an external process. LibGit2Sharp goal is to provide a way to manipulate a git repository easily.</p> <p>It means you can use it to:</p> <ul> <li><p>Get the diff between files in the workdir and the previous version (in the index). To do that you can use the <code>Repository.Diff.Compare(IEnumerable&lt;string&gt; paths, bool includeUntracked, ExplicitPathsOptions explicitPathsOptions)</code> overload, which returns a <code>TreeChanges</code> object. From there, you can get a <code>TreeEntryChanges</code> object through the indexer of the treeChanges, which corresponds to the changes of a given file (use the .Patch property to get the actual content of the patch).</p></li> <li><p>Get the configured diff tool by using the <code>Repository.Config</code> namespace (e.g.: <code>repo.Config.Get&lt;string&gt;("diff.tool").Value</code>, although you should also check if the value returned by the <code>Get()</code> method is null in case no diff tool has been configured by the user). That way, you can launch the diff tool by yourself.</p></li> </ul> <p>Additional resources (v0.11.0):</p> <ul> <li>Diff workdir to index <a href="https://github.com/libgit2/libgit2sharp/blob/v0.11.0/LibGit2Sharp.Tests/DiffWorkdirToIndexFixture.cs" rel="nofollow">tests</a></li> <li>An <a href="https://github.com/libgit2/libgit2sharp/blob/v0.11.0/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs#L47-L70" rel="nofollow">example</a> showing how to use the <code>TreeChanges</code> object</li> <li><a href="https://github.com/libgit2/libgit2sharp/blob/v0.11.0/LibGit2Sharp.Tests/ConfigurationFixture.cs" rel="nofollow">Configuration fixture</a>, pretty self-explanatory</li> </ul> <hr> <p><strong>Note</strong>: it seems that at some point, you will need to know if a line has changed or not. I don't think there is an easy way to do that right now (apart from parsing the patch content manually). However, opening an issue on the LibGit2Sharp <a href="https://github.com/libgit2/libgit2sharp/issues" rel="nofollow">issue tracker</a> might trigger some discussion around that (feel free to weigh in what kind of API you would like to have to do that!).</p> <hr> <p><strong>Edit</strong>: Before launching the external diff tool, you will need to copy the content of the file which is in the index in a temporary folder. You can lookup the blob of a file in the index by doing something like:</p> <ul> <li>var indexEntry = repo.Index[fileName];</li> <li>var blob = repo.Lookup(indexEntry.Id);</li> </ul> <p>However... no filters are currently applied when you get the blob content, so the comparison is likely to produce false positives due to crlf differences. There is currently an <a href="https://github.com/libgit2/libgit2/issues/1264" rel="nofollow">issue</a> opened on libgit2 in order to propose an API to allow applying filters.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload