diff --git a/src/ViewModels/Checkout.cs b/src/ViewModels/Checkout.cs index 713c260f..71b01bcb 100644 --- a/src/ViewModels/Checkout.cs +++ b/src/ViewModels/Checkout.cs @@ -65,8 +65,14 @@ namespace SourceGit.ViewModels { var b = _repo.Branches.Find(x => x.IsLocal && x.Name == Branch); if (b != null && _repo.HistoriesFilterMode == Models.FilterMode.Included) + { + _repo.Settings.HistoriesFilters.Clear(); _repo.Settings.UpdateHistoriesFilter(b.FullName, Models.FilterType.LocalBranch, Models.FilterMode.Included); + if (!string.IsNullOrEmpty(b.Upstream)) + _repo.Settings.UpdateHistoriesFilter(b.Upstream, Models.FilterType.LocalBranch, Models.FilterMode.Included); + } + _repo.MarkBranchesDirtyManually(); _repo.SetWatcherEnabled(true); }); diff --git a/src/ViewModels/CreateBranch.cs b/src/ViewModels/CreateBranch.cs index 653d2db8..62d785f3 100644 --- a/src/ViewModels/CreateBranch.cs +++ b/src/ViewModels/CreateBranch.cs @@ -83,6 +83,7 @@ namespace SourceGit.ViewModels _repo.SetWatcherEnabled(false); return Task.Run(() => { + var succ = false; if (CheckoutAfterCreated) { var changes = new Commands.CountLocalChangesWithoutUntracked(_repo.FullPath).Result(); @@ -92,7 +93,7 @@ namespace SourceGit.ViewModels if (PreAction == Models.DealWithLocalChanges.StashAndReaply) { SetProgressDescription("Stash local changes"); - var succ = new Commands.Stash(_repo.FullPath).Push("CREATE_BRANCH_AUTO_STASH"); + succ = new Commands.Stash(_repo.FullPath).Push("CREATE_BRANCH_AUTO_STASH"); if (!succ) { CallUIThread(() => _repo.SetWatcherEnabled(true)); @@ -109,7 +110,7 @@ namespace SourceGit.ViewModels } SetProgressDescription($"Create new branch '{_name}'"); - new Commands.Checkout(_repo.FullPath).Branch(_name, _baseOnRevision, SetProgressDescription); + succ = new Commands.Checkout(_repo.FullPath).Branch(_name, _baseOnRevision, SetProgressDescription); if (needPopStash) { @@ -120,17 +121,24 @@ namespace SourceGit.ViewModels else { SetProgressDescription($"Create new branch '{_name}'"); - Commands.Branch.Create(_repo.FullPath, _name, _baseOnRevision); + succ = Commands.Branch.Create(_repo.FullPath, _name, _baseOnRevision); } CallUIThread(() => { - if (CheckoutAfterCreated && _repo.HistoriesFilterMode == Models.FilterMode.Included) + if (succ && CheckoutAfterCreated && _repo.HistoriesFilterMode == Models.FilterMode.Included) + { + _repo.Settings.HistoriesFilters.Clear(); _repo.Settings.UpdateHistoriesFilter($"refs/heads/{_name}", Models.FilterType.LocalBranch, Models.FilterMode.Included); + if (BasedOn is Models.Branch b && !b.IsLocal) + _repo.Settings.UpdateHistoriesFilter(b.FullName, Models.FilterType.LocalBranch, Models.FilterMode.Included); + } + _repo.MarkBranchesDirtyManually(); _repo.SetWatcherEnabled(true); }); + return true; }); }