LibGit2Sharp get repository changes after pull

578 views Asked by At

How can i get the following information after a git-pull with libgit2sharp:

  1. Which files has been moved
  2. Which files has been created
  3. Which files has been deleted

The git-pull request it self works perfectly:

var result = repo.Network.Pull(new LibGit2Sharp.Signature("admin", "[email protected]", new DateTimeOffset(DateTime.Now)), options);

I already looked at the result of the Pull-Method, but this seems not to contain the needed information.

Thank you very much!

1

There are 1 answers

0
nulltoken On BEST ANSWER

The MergeResult type exposes a Commit property which is not null when the merge was successful.

In order to find out what files have changed, one just have to leverage the repo.Diff.Compare() method to compare this Commit with its first parent.