mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-06 23:46:13 +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 {
|
func (gui *Gui) refreshCommitsWithLimit() error {
|
||||||
gui.State.Mutexes.BranchCommitsMutex.Lock()
|
gui.Mutexes.BranchCommitsMutex.Lock()
|
||||||
defer gui.State.Mutexes.BranchCommitsMutex.Unlock()
|
defer gui.Mutexes.BranchCommitsMutex.Unlock()
|
||||||
|
|
||||||
builder := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr)
|
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 {
|
func (gui *Gui) refreshRebaseCommits() error {
|
||||||
gui.State.Mutexes.BranchCommitsMutex.Lock()
|
gui.Mutexes.BranchCommitsMutex.Lock()
|
||||||
defer gui.State.Mutexes.BranchCommitsMutex.Unlock()
|
defer gui.Mutexes.BranchCommitsMutex.Unlock()
|
||||||
|
|
||||||
builder := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr)
|
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 {
|
func (gui *Gui) refreshFilesAndSubmodules() error {
|
||||||
gui.State.Mutexes.RefreshingFilesMutex.Lock()
|
gui.Mutexes.RefreshingFilesMutex.Lock()
|
||||||
gui.State.IsRefreshingFiles = true
|
gui.State.IsRefreshingFiles = true
|
||||||
defer func() {
|
defer func() {
|
||||||
gui.State.IsRefreshingFiles = false
|
gui.State.IsRefreshingFiles = false
|
||||||
gui.State.Mutexes.RefreshingFilesMutex.Unlock()
|
gui.Mutexes.RefreshingFilesMutex.Unlock()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
selectedFile := gui.getSelectedFile()
|
selectedFile := gui.getSelectedFile()
|
||||||
@ -517,8 +517,8 @@ func (gui *Gui) pullFiles(opts PullFilesOptions) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) pullWithMode(mode string, opts PullFilesOptions) error {
|
func (gui *Gui) pullWithMode(mode string, opts PullFilesOptions) error {
|
||||||
gui.State.Mutexes.FetchMutex.Lock()
|
gui.Mutexes.FetchMutex.Lock()
|
||||||
defer gui.State.Mutexes.FetchMutex.Unlock()
|
defer gui.Mutexes.FetchMutex.Unlock()
|
||||||
|
|
||||||
err := gui.GitCommand.Fetch(
|
err := gui.GitCommand.Fetch(
|
||||||
commands.FetchOptions{
|
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) {
|
func (gui *Gui) fetch(canPromptForCredentials bool) (err error) {
|
||||||
gui.State.Mutexes.FetchMutex.Lock()
|
gui.Mutexes.FetchMutex.Lock()
|
||||||
defer gui.State.Mutexes.FetchMutex.Unlock()
|
defer gui.Mutexes.FetchMutex.Unlock()
|
||||||
|
|
||||||
fetchOpts := commands.FetchOptions{}
|
fetchOpts := commands.FetchOptions{}
|
||||||
if canPromptForCredentials {
|
if canPromptForCredentials {
|
||||||
|
@ -113,6 +113,8 @@ type Gui struct {
|
|||||||
// or the events we've recorded in a prior session
|
// or the events we've recorded in a prior session
|
||||||
RecordedEvents []RecordedEvent
|
RecordedEvents []RecordedEvent
|
||||||
StartTime time.Time
|
StartTime time.Time
|
||||||
|
|
||||||
|
Mutexes guiStateMutexes
|
||||||
}
|
}
|
||||||
|
|
||||||
type RecordedEvent struct {
|
type RecordedEvent struct {
|
||||||
@ -318,7 +320,6 @@ type guiState struct {
|
|||||||
SplitMainPanel bool
|
SplitMainPanel bool
|
||||||
RetainOriginalDir bool
|
RetainOriginalDir bool
|
||||||
IsRefreshingFiles bool
|
IsRefreshingFiles bool
|
||||||
Mutexes guiStateMutexes
|
|
||||||
Searching searchingState
|
Searching searchingState
|
||||||
ScreenMode int
|
ScreenMode int
|
||||||
SideView *gocui.View
|
SideView *gocui.View
|
||||||
|
@ -25,8 +25,8 @@ const (
|
|||||||
// returns whether the patch is empty so caller can escape if necessary
|
// 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
|
// 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) {
|
func (gui *Gui) refreshLineByLinePanel(diff string, secondaryDiff string, secondaryFocused bool, selectedLineIdx int) (bool, error) {
|
||||||
gui.State.Mutexes.LineByLinePanelMutex.Lock()
|
gui.Mutexes.LineByLinePanelMutex.Lock()
|
||||||
defer gui.State.Mutexes.LineByLinePanelMutex.Unlock()
|
defer gui.Mutexes.LineByLinePanelMutex.Unlock()
|
||||||
|
|
||||||
state := gui.State.Panels.LineByLine
|
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 {
|
func (gui *Gui) withLBLActiveCheck(f func(*lineByLinePanelState) error) error {
|
||||||
gui.State.Mutexes.LineByLinePanelMutex.Lock()
|
gui.Mutexes.LineByLinePanelMutex.Lock()
|
||||||
defer gui.State.Mutexes.LineByLinePanelMutex.Unlock()
|
defer gui.Mutexes.LineByLinePanelMutex.Unlock()
|
||||||
|
|
||||||
state := gui.State.Panels.LineByLine
|
state := gui.State.Panels.LineByLine
|
||||||
if state == nil {
|
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 {
|
return gui.WithWaitingStatus(gui.Tr.FetchingRemoteStatus, func() error {
|
||||||
gui.State.Mutexes.FetchMutex.Lock()
|
gui.Mutexes.FetchMutex.Lock()
|
||||||
defer gui.State.Mutexes.FetchMutex.Unlock()
|
defer gui.Mutexes.FetchMutex.Unlock()
|
||||||
|
|
||||||
// TODO: test this
|
// TODO: test this
|
||||||
err := gui.GitCommand.FetchRemote(remote.Name, gui.promptUserForCredential)
|
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()
|
// never call this on its own, it should only be called from within refreshCommits()
|
||||||
func (gui *Gui) refreshStatus() {
|
func (gui *Gui) refreshStatus() {
|
||||||
gui.State.Mutexes.RefreshingStatusMutex.Lock()
|
gui.Mutexes.RefreshingStatusMutex.Lock()
|
||||||
defer gui.State.Mutexes.RefreshingStatusMutex.Unlock()
|
defer gui.Mutexes.RefreshingStatusMutex.Unlock()
|
||||||
|
|
||||||
currentBranch := gui.currentBranch()
|
currentBranch := gui.currentBranch()
|
||||||
if currentBranch == nil {
|
if currentBranch == nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user