diff --git a/pkg/commands/git_commands/config.go b/pkg/commands/git_commands/config.go index 9771f01d3..5ea8f91d7 100644 --- a/pkg/commands/git_commands/config.go +++ b/pkg/commands/git_commands/config.go @@ -111,3 +111,7 @@ func (self *ConfigCommands) GetCoreCommentChar() byte { func (self *ConfigCommands) GetRebaseUpdateRefs() bool { return self.gitConfig.GetBool("rebase.updateRefs") } + +func (self *ConfigCommands) DropConfigCache() { + self.gitConfig.DropCache() +} diff --git a/pkg/commands/git_config/cached_git_config.go b/pkg/commands/git_config/cached_git_config.go index 9c12b45ee..256cd325b 100644 --- a/pkg/commands/git_config/cached_git_config.go +++ b/pkg/commands/git_config/cached_git_config.go @@ -15,6 +15,8 @@ type IGitConfig interface { GetGeneral(string) string // this is for when you want to pass 'mykey' and check if the result is truthy GetBool(string) bool + + DropCache() } type CachedGitConfig struct { @@ -93,3 +95,10 @@ func isTruthy(value string) bool { lcValue := strings.ToLower(value) return lcValue == "true" || lcValue == "1" || lcValue == "yes" || lcValue == "on" } + +func (self *CachedGitConfig) DropCache() { + self.mutex.Lock() + defer self.mutex.Unlock() + + self.cache = make(map[string]string) +} diff --git a/pkg/commands/git_config/fake_git_config.go b/pkg/commands/git_config/fake_git_config.go index 78ba62c54..e82efcd1b 100644 --- a/pkg/commands/git_config/fake_git_config.go +++ b/pkg/commands/git_config/fake_git_config.go @@ -27,3 +27,6 @@ func (self *FakeGitConfig) GetGeneral(args string) string { func (self *FakeGitConfig) GetBool(key string) bool { return isTruthy(self.Get(key)) } + +func (self *FakeGitConfig) DropCache() { +} diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index aa44aa92c..ff6b68748 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -331,6 +331,8 @@ func (gui *Gui) onNewRepo(startArgs appTypes.StartArgs, contextKey types.Context gui.g.SetFocusHandler(func(Focused bool) error { if Focused { + gui.git.Config.DropConfigCache() + oldConfig := gui.Config.GetUserConfig() reloadErr, didChange := gui.Config.ReloadChangedUserConfigFiles() if didChange && reloadErr == nil {