From 382ea6b89a584379aba67ebf015b1374ca6a8baf Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 29 Sep 2020 10:53:49 +0800 Subject: [PATCH] fix: update filters for commits when branch changed or tag deleted --- src/Git/Repository.cs | 12 +++++++++++- src/Git/Tag.cs | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Git/Repository.cs b/src/Git/Repository.cs index 4a602d5f..7203b6b5 100644 --- a/src/Git/Repository.cs +++ b/src/Git/Repository.cs @@ -390,7 +390,17 @@ namespace SourceGit.Git { if (nextUpdateTree > 0 && now >= nextUpdateTree) { nextUpdateTree = 0; - Branches(true); + + var branches = Branches(true); + var badFilters = new List(); + foreach (var filter in LogFilters) { + if (filter.StartsWith("refs/heads/") || filter.StartsWith("refs/remotes/")) { + var idx = branches.FindIndex(b => b.FullName == filter); + if (idx < 0) badFilters.Add(filter); + } + } + foreach (var bad in badFilters) LogFilters.Remove(bad); + OnBranchChanged?.Invoke(); OnCommitsChanged?.Invoke(); } diff --git a/src/Git/Tag.cs b/src/Git/Tag.cs index f329c4d4..fbfbf432 100644 --- a/src/Git/Tag.cs +++ b/src/Git/Tag.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Text.RegularExpressions; @@ -101,6 +101,7 @@ namespace SourceGit.Git { } } + repo.LogFilters.Remove(name); repo.OnCommitsChanged?.Invoke(); }