From 728b4dd879c890ffc2367928e7c35f7eea1c97a6 Mon Sep 17 00:00:00 2001 From: ZCShou <72115@163.com> Date: Wed, 29 Jul 2020 20:57:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(dashboard.xaml.cs):=20=E5=AF=B9=E4=BA=8E=20?= =?UTF-8?q?SUBMODULE=20=EF=BC=8C=E5=A6=82=E6=9E=9C=E5=8F=91=E7=8E=B0=20HEA?= =?UTF-8?q?D=20=E5=87=BA=E4=BA=8E=E6=B8=B8=E7=A6=BB=E7=8A=B6=E6=80=81?= =?UTF-8?q?=EF=BC=8C=E8=BF=99=E8=87=AA=E5=8A=A8=E5=88=87=E6=8D=A2=E5=88=B0?= =?UTF-8?q?=E6=89=BE=E7=9A=84=E7=AC=AC=E4=B8=80=E4=B8=AA=E6=9C=89=E6=95=88?= =?UTF-8?q?=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SourceGit/Git/Repository.cs | 2 +- SourceGit/UI/Dashboard.xaml.cs | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/SourceGit/Git/Repository.cs b/SourceGit/Git/Repository.cs index ab607f4e..a50bbfb7 100644 --- a/SourceGit/Git/Repository.cs +++ b/SourceGit/Git/Repository.cs @@ -927,7 +927,7 @@ namespace SourceGit.Git { public void UpdateSubmodule() { isWatcherDisabled = true; - var errs = RunCommand("submodule update", null); + var errs = RunCommand("submodule update --rebase --remote", null); if (errs != null) { App.RaiseError(errs); } else { diff --git a/SourceGit/UI/Dashboard.xaml.cs b/SourceGit/UI/Dashboard.xaml.cs index c260b654..4dc7d982 100644 --- a/SourceGit/UI/Dashboard.xaml.cs +++ b/SourceGit/UI/Dashboard.xaml.cs @@ -204,6 +204,8 @@ namespace SourceGit.UI { } private void UpdateBranches(bool force = true) { + bool IsDetached = false; + Git.Branch branch = null; Task.Run(() => { var branches = repo.Branches(force); var remotes = repo.Remotes(true); @@ -222,7 +224,8 @@ namespace SourceGit.UI { foreach (var b in branches) { if (b.IsLocal) { - MakeBranchNode(b, localBranchNodes, folders, states, "locals"); + MakeBranchNode(b, localBranchNodes, folders, states, "locals"); + branch = b; } else if (!string.IsNullOrEmpty(b.Remote)) { RemoteNode remote = null; @@ -240,6 +243,10 @@ namespace SourceGit.UI { } MakeBranchNode(b, remote.Children, folders, states, "remotes"); + } else { + /// 对于 SUBMODULE HEAD 出于游离状态(detached on commit id) + /// 此时,分支既不是 本地分支,也不是远程分支 + IsDetached = b.IsCurrent; } } @@ -264,6 +271,8 @@ namespace SourceGit.UI { localBranchTree.ItemsSource = localBranchNodes; remoteBranchTree.ItemsSource = remoteNodes; }); + + if (IsDetached && branch != null) repo.Checkout(branch.Name); }); }