diff --git a/src/ViewModels/Push.cs b/src/ViewModels/Push.cs index 0ca4f9de..863ef873 100644 --- a/src/ViewModels/Push.cs +++ b/src/ViewModels/Push.cs @@ -19,25 +19,7 @@ namespace SourceGit.ViewModels set { if (SetProperty(ref _selectedLocalBranch, value)) - { - // If selected local branch has upstream branch. Try to find it's remote. - if (!string.IsNullOrEmpty(value.Upstream)) - { - var branch = _repo.Branches.Find(x => x.FullName == value.Upstream); - if (branch != null) - { - var remote = _repo.Remotes.Find(x => x.Name == branch.Remote); - if (remote != null && remote != _selectedRemote) - { - SelectedRemote = remote; - return; - } - } - } - - // Re-generate remote branches and auto-select remote branches. AutoSelectBranchByRemote(); - } } } @@ -73,7 +55,11 @@ namespace SourceGit.ViewModels public Models.Branch SelectedRemoteBranch { get => _selectedRemoteBranch; - set => SetProperty(ref _selectedRemoteBranch, value); + set + { + if (SetProperty(ref _selectedRemoteBranch, value)) + IsSetTrackOptionVisible = value != null && _selectedLocalBranch.Upstream != value.FullName; + } } public bool PushAllTags @@ -82,6 +68,12 @@ namespace SourceGit.ViewModels set; } + public bool IsSetTrackOptionVisible + { + get => _isSetTrackOptionVisible; + private set => SetProperty(ref _isSetTrackOptionVisible, value); + } + public bool Tracking { get; @@ -160,7 +152,7 @@ namespace SourceGit.ViewModels remoteBranchName, PushAllTags, ForcePush, - Tracking, + _isSetTrackOptionVisible && Tracking, SetProgressDescription).Exec(); CallUIThread(() => _repo.SetWatcherEnabled(true)); return succ; @@ -218,5 +210,6 @@ namespace SourceGit.ViewModels private Models.Remote _selectedRemote = null; private List _remoteBranches = new List(); private Models.Branch _selectedRemoteBranch = null; + private bool _isSetTrackOptionVisible = false; } } diff --git a/src/Views/Push.axaml b/src/Views/Push.axaml index 00cdafbf..043910c2 100644 --- a/src/Views/Push.axaml +++ b/src/Views/Push.axaml @@ -13,7 +13,7 @@ Classes="bold" Text="{DynamicResource Text.Push.Title}"/> - + + IsChecked="{Binding Tracking, Mode=TwoWay}" + IsVisible="{Binding IsSetTrackOptionVisible}"/>