GitScc.GitRepository.GetUnmodifiedFileByRelativePath C# (CSharp) Method

GetUnmodifiedFileByRelativePath() public method

public GetUnmodifiedFileByRelativePath ( string relativePath, string sha = null ) : string
relativePath string
sha string
return string
        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;
            }
        }