public string GetUnmodifiedFileByRelativePath(string relativePath, string sha = null)
{
Blob oldBlob = null;
using (var repository = GetRepository())
{
try
{
if (!String.IsNullOrWhiteSpace(sha))
{
var commit = repository.Lookup<LibGit2Sharp.Commit>(sha);
var treeEntry = commit[relativePath];
oldBlob = (Blob)treeEntry.Target;
}
else
{
var indexEntry = repository.Index[relativePath];
if (indexEntry != null)
{
oldBlob = repository.Lookup<Blob>(indexEntry.Id);
}
}
}
catch (Exception)
{
}
return oldBlob != null ? oldBlob.GetContentText(new FilteringOptions(relativePath)) : string.Empty;
}
}