Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect pending changes in libgit2sharp?

In libgit2sharp https://github.com/libgit2/libgit2sharp/ how do you check for pending/uncommitted changes?

like image 743
Simon Avatar asked Oct 13 '12 13:10

Simon


2 Answers

The following works for me:

///DEPRECATED - see comment from @derptastic
public bool HasUncommittedChanges
{
    get
    {
        using (var repo = new Repository(repositoryRoot))
        {
            RepositoryStatus status = repo.RetrieveStatus();
            return status.IsDirty;
        }
    }
}

Thanks to @Derptastic for the link to LibGit2Sharp Wiki

like image 199
Valid Avatar answered Nov 20 '22 21:11

Valid


The following lines of code will provide the filename and the state of that file.

foreach (var item in repo1.RetrieveStatus())
{
  Console.WriteLine(item.FilePath);
  Console.WriteLine(item.State);
}    
like image 7
user5575670 Avatar answered Nov 20 '22 21:11

user5575670