diff --git a/src/Commands/Branch.cs b/src/Commands/Branch.cs
index 7f640c4f..387892ba 100644
--- a/src/Commands/Branch.cs
+++ b/src/Commands/Branch.cs
@@ -21,7 +21,12 @@ namespace SourceGit.Commands {
}
public void SetUpstream(string upstream) {
- Args = $"branch {target} -u {upstream}";
+ Args = $"branch {target} ";
+ if (string.IsNullOrEmpty(upstream)) {
+ Args += "--unset-upstream";
+ } else {
+ Args += $"-u {upstream}";
+ }
Exec();
}
diff --git a/src/Resources/Locales/en_US.xaml b/src/Resources/Locales/en_US.xaml
index b70851d3..79cc9547 100644
--- a/src/Resources/Locales/en_US.xaml
+++ b/src/Resources/Locales/en_US.xaml
@@ -179,6 +179,7 @@
Delete '{0}'
Tracking ...
Copy Branch Name
+ Unset Upstream
Fetch '{0}'
Edit '{0}'
diff --git a/src/Resources/Locales/zh_CN.xaml b/src/Resources/Locales/zh_CN.xaml
index ae84d628..279e28c6 100644
--- a/src/Resources/Locales/zh_CN.xaml
+++ b/src/Resources/Locales/zh_CN.xaml
@@ -178,6 +178,7 @@
删除 '{0}'
切换上游分支...
复制分支名
+ 取消追踪
拉取 '{0}' 更新
编辑 '{0}'
diff --git a/src/Views/Popups/DeleteBranch.xaml.cs b/src/Views/Popups/DeleteBranch.xaml.cs
index 3577d63f..9a00045a 100644
--- a/src/Views/Popups/DeleteBranch.xaml.cs
+++ b/src/Views/Popups/DeleteBranch.xaml.cs
@@ -1,3 +1,4 @@
+using System;
using System.Threading.Tasks;
namespace SourceGit.Views.Popups {
@@ -8,6 +9,7 @@ namespace SourceGit.Views.Popups {
private string repo = null;
private string branch = null;
private string remote = null;
+ private Action finishHandler = null;
public DeleteBranch(string repo, string branch, string remote = null) {
this.repo = repo;
@@ -20,6 +22,11 @@ namespace SourceGit.Views.Popups {
else txtTarget.Text = $"{remote}/{branch}";
}
+ public DeleteBranch Then(Action handler) {
+ this.finishHandler = handler;
+ return this;
+ }
+
public override string GetTitle() {
return App.Text("DeleteBranch");
}
@@ -41,7 +48,8 @@ namespace SourceGit.Views.Popups {
if (exists != null && exists.Filters.Contains(full)) {
exists.Filters.Remove(full);
}
-
+
+ finishHandler?.Invoke();
Models.Watcher.SetEnabled(repo, true);
return true;
});
diff --git a/src/Views/Widgets/Dashboard.xaml.cs b/src/Views/Widgets/Dashboard.xaml.cs
index 4963a54b..8b40e2b8 100644
--- a/src/Views/Widgets/Dashboard.xaml.cs
+++ b/src/Views/Widgets/Dashboard.xaml.cs
@@ -58,7 +58,7 @@ namespace SourceGit.Views.Widgets {
var watcher = Models.Watcher.Get(repo.Path);
watcher.Navigate += NavigateTo;
- watcher.BranchChanged += UpdateBraches;
+ watcher.BranchChanged += UpdateBranches;
watcher.BranchChanged += UpdateCommits;
watcher.WorkingCopyChanged += UpdateWorkingCopy;
watcher.StashChanged += UpdateStashes;
@@ -94,7 +94,7 @@ namespace SourceGit.Views.Widgets {
#region DATA
public void Refresh() {
- UpdateBraches();
+ UpdateBranches();
UpdateWorkingCopy();
UpdateStashes();
UpdateTags();
@@ -190,7 +190,7 @@ namespace SourceGit.Views.Widgets {
foreach (var node in nodes) SortBranches(node.Children);
}
- private void UpdateBraches() {
+ private void UpdateBranches() {
if (!isFirstLoaded) return;
Task.Run(() => {
@@ -669,12 +669,22 @@ namespace SourceGit.Views.Widgets {
if (branch.Upstream == b.FullName) target.Icon = currentTrackingIcon;
target.Click += (o, e) => {
new Commands.Branch(repo.Path, branch.Name).SetUpstream(upstream);
- UpdateBraches();
+ UpdateBranches();
e.Handled = true;
};
tracking.Items.Add(target);
}
+ var unsetUpstream = new MenuItem();
+ unsetUpstream.Header = App.Text("BranchCM.UnsetUpstream");
+ unsetUpstream.Click += (_, e) => {
+ new Commands.Branch(repo.Path, branch.Name).SetUpstream(string.Empty);
+ UpdateBranches();
+ e.Handled = true;
+ };
+ tracking.Items.Add(new Separator());
+ tracking.Items.Add(unsetUpstream);
+
menu.Items.Add(tracking);
}
@@ -784,7 +794,12 @@ namespace SourceGit.Views.Widgets {
var delete = new MenuItem();
delete.Header = App.Text("BranchCM.Delete", branch.Name);
delete.Click += (o, e) => {
- new Popups.DeleteBranch(repo.Path, branch.Name, branch.Remote).Show();
+ new Popups.DeleteBranch(repo.Path, branch.Name, branch.Remote)
+ .Then(() => {
+ repo.Branches.FindAll(item => item.Upstream == branch.FullName).ForEach(item =>
+ new Commands.Branch(repo.Path, item.Name).SetUpstream(string.Empty));
+ })
+ .Show();
e.Handled = true;
};