Skip to content

Commit e05264e

Browse files
committed
fix: can not create branch when detached head has extra commits (#344)
1 parent ed2d327 commit e05264e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Commands/QueryBranches.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ public class QueryBranches : Command
77
{
88
private const string PREFIX_LOCAL = "refs/heads/";
99
private const string PREFIX_REMOTE = "refs/remotes/";
10-
private const string PREFIX_DETACHED = "(HEAD detached at";
10+
private const string PREFIX_DETACHED_AT = "(HEAD detached at";
11+
private const string PREFIX_DETACHED_FROM = "(HEAD detached from";
1112

1213
public QueryBranches(string repo)
1314
{
@@ -37,7 +38,7 @@ protected override void OnReadline(string line)
3738
if (refName.EndsWith("/HEAD", StringComparison.Ordinal))
3839
return;
3940

40-
if (refName.StartsWith(PREFIX_DETACHED, StringComparison.Ordinal))
41+
if (refName.StartsWith(PREFIX_DETACHED_AT, StringComparison.Ordinal) || refName.StartsWith(PREFIX_DETACHED_FROM, StringComparison.Ordinal))
4142
{
4243
branch.IsDetachedHead = true;
4344
}

0 commit comments

Comments
 (0)