mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-08 23:56:15 +02:00
do not put mutexes on state else we might unlock an unlocked mutex
This commit is contained in:
parent
79e59d5460
commit
795e4da8b8
@ -110,8 +110,8 @@ func (gui *Gui) refreshCommits() error {
|
||||
}
|
||||
|
||||
func (gui *Gui) refreshCommitsWithLimit() error {
|
||||
gui.State.Mutexes.BranchCommitsMutex.Lock()
|
||||
defer gui.State.Mutexes.BranchCommitsMutex.Unlock()
|
||||
gui.Mutexes.BranchCommitsMutex.Lock()
|
||||
defer gui.Mutexes.BranchCommitsMutex.Unlock()
|
||||
|
||||
builder := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr)
|
||||
|
||||
@ -132,8 +132,8 @@ func (gui *Gui) refreshCommitsWithLimit() error {
|
||||
}
|
||||
|
||||
func (gui *Gui) refreshRebaseCommits() error {
|
||||
gui.State.Mutexes.BranchCommitsMutex.Lock()
|
||||
defer gui.State.Mutexes.BranchCommitsMutex.Unlock()
|
||||
gui.Mutexes.BranchCommitsMutex.Lock()
|
||||
defer gui.Mutexes.BranchCommitsMutex.Unlock()
|
||||
|
||||
builder := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr)
|
||||
|
||||
|
@ -81,11 +81,11 @@ func (gui *Gui) selectFile(alreadySelected bool) error {
|
||||
}
|
||||
|
||||
func (gui *Gui) refreshFilesAndSubmodules() error {
|
||||
gui.State.Mutexes.RefreshingFilesMutex.Lock()
|
||||
gui.Mutexes.RefreshingFilesMutex.Lock()
|
||||
gui.State.IsRefreshingFiles = true
|
||||
defer func() {
|
||||
gui.State.IsRefreshingFiles = false
|
||||
gui.State.Mutexes.RefreshingFilesMutex.Unlock()
|
||||
gui.Mutexes.RefreshingFilesMutex.Unlock()
|
||||
}()
|
||||
|
||||
selectedFile := gui.getSelectedFile()
|
||||
@ -517,8 +517,8 @@ func (gui *Gui) pullFiles(opts PullFilesOptions) error {
|
||||
}
|
||||
|
||||
func (gui *Gui) pullWithMode(mode string, opts PullFilesOptions) error {
|
||||
gui.State.Mutexes.FetchMutex.Lock()
|
||||
defer gui.State.Mutexes.FetchMutex.Unlock()
|
||||
gui.Mutexes.FetchMutex.Lock()
|
||||
defer gui.Mutexes.FetchMutex.Unlock()
|
||||
|
||||
err := gui.GitCommand.Fetch(
|
||||
commands.FetchOptions{
|
||||
|
@ -164,8 +164,8 @@ func (gui *Gui) handleInfoClick(g *gocui.Gui, v *gocui.View) error {
|
||||
}
|
||||
|
||||
func (gui *Gui) fetch(canPromptForCredentials bool) (err error) {
|
||||
gui.State.Mutexes.FetchMutex.Lock()
|
||||
defer gui.State.Mutexes.FetchMutex.Unlock()
|
||||
gui.Mutexes.FetchMutex.Lock()
|
||||
defer gui.Mutexes.FetchMutex.Unlock()
|
||||
|
||||
fetchOpts := commands.FetchOptions{}
|
||||
if canPromptForCredentials {
|
||||
|
@ -113,6 +113,8 @@ type Gui struct {
|
||||
// or the events we've recorded in a prior session
|
||||
RecordedEvents []RecordedEvent
|
||||
StartTime time.Time
|
||||
|
||||
Mutexes guiStateMutexes
|
||||
}
|
||||
|
||||
type RecordedEvent struct {
|
||||
@ -318,7 +320,6 @@ type guiState struct {
|
||||
SplitMainPanel bool
|
||||
RetainOriginalDir bool
|
||||
IsRefreshingFiles bool
|
||||
Mutexes guiStateMutexes
|
||||
Searching searchingState
|
||||
ScreenMode int
|
||||
SideView *gocui.View
|
||||
|
@ -25,8 +25,8 @@ const (
|
||||
// returns whether the patch is empty so caller can escape if necessary
|
||||
// both diffs should be non-coloured because we'll parse them and colour them here
|
||||
func (gui *Gui) refreshLineByLinePanel(diff string, secondaryDiff string, secondaryFocused bool, selectedLineIdx int) (bool, error) {
|
||||
gui.State.Mutexes.LineByLinePanelMutex.Lock()
|
||||
defer gui.State.Mutexes.LineByLinePanelMutex.Unlock()
|
||||
gui.Mutexes.LineByLinePanelMutex.Lock()
|
||||
defer gui.Mutexes.LineByLinePanelMutex.Unlock()
|
||||
|
||||
state := gui.State.Panels.LineByLine
|
||||
|
||||
@ -418,8 +418,8 @@ func (gui *Gui) lineByLineNavigateTo(selectedLineIdx int) error {
|
||||
}
|
||||
|
||||
func (gui *Gui) withLBLActiveCheck(f func(*lineByLinePanelState) error) error {
|
||||
gui.State.Mutexes.LineByLinePanelMutex.Lock()
|
||||
defer gui.State.Mutexes.LineByLinePanelMutex.Unlock()
|
||||
gui.Mutexes.LineByLinePanelMutex.Lock()
|
||||
defer gui.Mutexes.LineByLinePanelMutex.Unlock()
|
||||
|
||||
state := gui.State.Panels.LineByLine
|
||||
if state == nil {
|
||||
|
@ -158,8 +158,8 @@ func (gui *Gui) handleFetchRemote(g *gocui.Gui, v *gocui.View) error {
|
||||
}
|
||||
|
||||
return gui.WithWaitingStatus(gui.Tr.FetchingRemoteStatus, func() error {
|
||||
gui.State.Mutexes.FetchMutex.Lock()
|
||||
defer gui.State.Mutexes.FetchMutex.Unlock()
|
||||
gui.Mutexes.FetchMutex.Lock()
|
||||
defer gui.Mutexes.FetchMutex.Unlock()
|
||||
|
||||
// TODO: test this
|
||||
err := gui.GitCommand.FetchRemote(remote.Name, gui.promptUserForCredential)
|
||||
|
@ -12,8 +12,8 @@ import (
|
||||
|
||||
// never call this on its own, it should only be called from within refreshCommits()
|
||||
func (gui *Gui) refreshStatus() {
|
||||
gui.State.Mutexes.RefreshingStatusMutex.Lock()
|
||||
defer gui.State.Mutexes.RefreshingStatusMutex.Unlock()
|
||||
gui.Mutexes.RefreshingStatusMutex.Lock()
|
||||
defer gui.Mutexes.RefreshingStatusMutex.Unlock()
|
||||
|
||||
currentBranch := gui.currentBranch()
|
||||
if currentBranch == nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user