public static string GetSelectedBranchFast(string repositoryPath)
{
if (string.IsNullOrEmpty(repositoryPath))
return string.Empty;
string head;
string headFileName = Path.Combine(GetGitDirectory(repositoryPath), "HEAD");
if (File.Exists(headFileName))
{
head = File.ReadAllText(headFileName, SystemEncoding);
if (!head.Contains("ref:"))
return DetachedBranch;
}
else
{
return string.Empty;
}
if (!string.IsNullOrEmpty(head))
{
return head.Replace("ref:", "").Replace("refs/heads/", string.Empty).Trim();
}
return string.Empty;
}