1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-20 05:19:24 +02:00

avoid deadlock

This commit is contained in:
Jesse Duffield 2022-01-29 11:22:35 +11:00
parent cb0d3a480a
commit 1a74ed3214
3 changed files with 6 additions and 15 deletions

View File

@ -1,8 +1,6 @@
package controllers
import (
"sync"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/commands/models"
@ -21,7 +19,6 @@ type RemotesController struct {
getSelectedRemote func() *models.Remote
setRemoteBranches func([]*models.RemoteBranch)
getContexts func() context.ContextTree
fetchMutex *sync.Mutex
}
var _ types.IController = &RemotesController{}
@ -33,7 +30,6 @@ func NewRemotesController(
getContexts func() context.ContextTree,
getSelectedRemote func() *models.Remote,
setRemoteBranches func([]*models.RemoteBranch),
fetchMutex *sync.Mutex,
) *RemotesController {
return &RemotesController{
c: c,
@ -42,7 +38,6 @@ func NewRemotesController(
getContext: getContext,
getSelectedRemote: getSelectedRemote,
setRemoteBranches: setRemoteBranches,
fetchMutex: fetchMutex,
}
}
@ -176,9 +171,6 @@ func (self *RemotesController) edit(remote *models.Remote) error {
func (self *RemotesController) fetch(remote *models.Remote) error {
return self.c.WithWaitingStatus(self.c.Tr.FetchingRemoteStatus, func() error {
self.fetchMutex.Lock()
defer self.fetchMutex.Unlock()
err := self.git.Sync.FetchRemote(remote.Name)
if err != nil {
_ = self.c.Error(err)

View File

@ -397,7 +397,7 @@ type Modes struct {
type guiMutexes struct {
RefreshingFilesMutex *sync.Mutex
RefreshingStatusMutex *sync.Mutex
FetchMutex *sync.Mutex
SyncMutex *sync.Mutex
BranchCommitsMutex *sync.Mutex
LineByLinePanelMutex *sync.Mutex
SubprocessMutex *sync.Mutex
@ -514,7 +514,7 @@ func NewGui(
Mutexes: guiMutexes{
RefreshingFilesMutex: &sync.Mutex{},
RefreshingStatusMutex: &sync.Mutex{},
FetchMutex: &sync.Mutex{},
SyncMutex: &sync.Mutex{},
BranchCommitsMutex: &sync.Mutex{},
LineByLinePanelMutex: &sync.Mutex{},
SubprocessMutex: &sync.Mutex{},
@ -537,7 +537,7 @@ func NewGui(
cmn,
osCommand,
gitConfig,
gui.Mutexes.FetchMutex,
gui.Mutexes.SyncMutex,
)
if err != nil {
return nil, err
@ -666,7 +666,6 @@ func (gui *Gui) setControllers() {
getContexts,
gui.getSelectedRemote,
func(branches []*models.RemoteBranch) { gui.State.RemoteBranches = branches },
gui.Mutexes.FetchMutex,
),
Menu: controllers.NewMenuController(
controllerCommon,

View File

@ -75,7 +75,7 @@ func (gui *Gui) dispatchSwitchToRepo(path string, reuse bool) error {
gui.Common,
gui.OSCommand,
git_config.NewStdCachedGitConfig(gui.Log),
gui.Mutexes.FetchMutex,
gui.Mutexes.SyncMutex,
)
if err != nil {
return err
@ -84,8 +84,8 @@ func (gui *Gui) dispatchSwitchToRepo(path string, reuse bool) error {
// these two mutexes are used by our background goroutines (triggered via `gui.goEvery`. We don't want to
// switch to a repo while one of these goroutines is in the process of updating something
gui.Mutexes.FetchMutex.Lock()
defer gui.Mutexes.FetchMutex.Unlock()
gui.Mutexes.SyncMutex.Lock()
defer gui.Mutexes.SyncMutex.Unlock()
gui.Mutexes.RefreshingFilesMutex.Lock()
defer gui.Mutexes.RefreshingFilesMutex.Unlock()