Skip to content

Commit ed2d327

Browse files
committed
enhance: create branch on detached HEAD (#344)
1 parent c596427 commit ed2d327

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

src/Commands/QueryBranches.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected override void OnReadline(string line)
3939

4040
if (refName.StartsWith(PREFIX_DETACHED, StringComparison.Ordinal))
4141
{
42-
branch.IsHead = true;
42+
branch.IsDetachedHead = true;
4343
}
4444

4545
if (refName.StartsWith(PREFIX_LOCAL, StringComparison.Ordinal))

src/Models/Branch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ public class Branch
2828
public string Head { get; set; }
2929
public bool IsLocal { get; set; }
3030
public bool IsCurrent { get; set; }
31+
public bool IsDetachedHead { get; set; }
3132
public string Upstream { get; set; }
3233
public BranchTrackStatus TrackStatus { get; set; }
3334
public string Remote { get; set; }
34-
public bool IsHead { get; set; }
3535

3636
public string FriendlyName => IsLocal ? Name : $"{Remote}/{Name}";
3737
}

src/ViewModels/BranchTreeNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ private void SortNodes(List<BranchTreeNode> nodes)
189189
{
190190
nodes.Sort((l, r) =>
191191
{
192-
if (l.Backend is Models.Branch { IsHead: true })
192+
if (l.Backend is Models.Branch { IsDetachedHead: true })
193193
return -1;
194194

195195
if (l.Backend is Models.Branch)

src/ViewModels/CreateBranch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public bool CheckoutAfterCreated
3535
public CreateBranch(Repository repo, Models.Branch branch)
3636
{
3737
_repo = repo;
38-
_baseOnRevision = branch.FullName;
38+
_baseOnRevision = branch.IsDetachedHead ? branch.Head : branch.FullName;
3939

4040
if (!branch.IsLocal && repo.Branches.Find(x => x.IsLocal && x.Name == branch.Name) == null)
4141
{

src/ViewModels/Repository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ public void RefreshCommits()
746746
}
747747
else
748748
{
749-
limits += "--branches --remotes --tags";
749+
limits += "--exclude=refs/stash --all";
750750
}
751751

752752
var commits = new Commands.QueryCommits(_fullpath, limits).Result();

0 commit comments

Comments
 (0)