GitCommands.GitModule.GetSelectedBranchFast C# (CSharp) Method

GetSelectedBranchFast() public static method

Dirty but fast. This sometimes fails.
public static GetSelectedBranchFast ( string repositoryPath ) : string
repositoryPath string
return string
        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;
        }
GitModule