diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go index 8f1201ccb..610973399 100644 --- a/pkg/gui/commit_files_panel.go +++ b/pkg/gui/commit_files_panel.go @@ -84,7 +84,7 @@ func (gui *Gui) handleDiscardOldFileChange() error { HandleConfirm: func() error { return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error { gui.c.LogAction(gui.c.Tr.Actions.DiscardOldFileChange) - if err := gui.git.Rebase.DiscardOldFileChanges(gui.State.Model.Commits, gui.State.Contexts.BranchCommits.GetSelectedLineIdx(), fileName); err != nil { + if err := gui.git.Rebase.DiscardOldFileChanges(gui.State.Model.Commits, gui.State.Contexts.LocalCommits.GetSelectedLineIdx(), fileName); err != nil { if err := gui.helpers.MergeAndRebase.CheckMergeOrRebase(err); err != nil { return err } @@ -98,7 +98,7 @@ func (gui *Gui) handleDiscardOldFileChange() error { func (gui *Gui) refreshCommitFilesView() error { currentSideContext := gui.currentSideContext() - if currentSideContext.GetKey() == context.COMMIT_FILES_CONTEXT_KEY || currentSideContext.GetKey() == context.BRANCH_COMMITS_CONTEXT_KEY { + if currentSideContext.GetKey() == context.COMMIT_FILES_CONTEXT_KEY || currentSideContext.GetKey() == context.LOCAL_COMMITS_CONTEXT_KEY { if err := gui.handleRefreshPatchBuildingPanel(-1); err != nil { return err } diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index bed39a05a..126fac3a7 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -11,11 +11,11 @@ const COMMIT_THRESHOLD = 200 // list panel functions func (gui *Gui) getSelectedLocalCommit() *models.Commit { - return gui.State.Contexts.BranchCommits.GetSelected() + return gui.State.Contexts.LocalCommits.GetSelected() } func (gui *Gui) onCommitFocus() error { - context := gui.State.Contexts.BranchCommits + context := gui.State.Contexts.LocalCommits if context.GetSelectedLineIdx() > COMMIT_THRESHOLD && context.GetLimitCommits() { context.SetLimitCommits(false) go utils.Safe(func() { @@ -32,7 +32,7 @@ func (gui *Gui) onCommitFocus() error { func (gui *Gui) branchCommitsRenderToMain() error { var task updateTask - commit := gui.State.Contexts.BranchCommits.GetSelected() + commit := gui.State.Contexts.LocalCommits.GetSelected() if commit == nil { task = NewRenderStringTask(gui.c.Tr.NoCommitsThisBranch) } else { diff --git a/pkg/gui/context.go b/pkg/gui/context.go index 79f9acd94..748354c3d 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -336,7 +336,7 @@ func (gui *Gui) currentStaticContext() types.Context { func (gui *Gui) defaultSideContext() types.Context { if gui.State.Modes.Filtering.Active() { - return gui.State.Contexts.BranchCommits + return gui.State.Contexts.LocalCommits } else { return gui.State.Contexts.Files } diff --git a/pkg/gui/context/context.go b/pkg/gui/context/context.go index e33a6c253..f57cb507d 100644 --- a/pkg/gui/context/context.go +++ b/pkg/gui/context/context.go @@ -14,7 +14,7 @@ const ( REMOTES_CONTEXT_KEY types.ContextKey = "remotes" REMOTE_BRANCHES_CONTEXT_KEY types.ContextKey = "remoteBranches" TAGS_CONTEXT_KEY types.ContextKey = "tags" - BRANCH_COMMITS_CONTEXT_KEY types.ContextKey = "commits" + LOCAL_COMMITS_CONTEXT_KEY types.ContextKey = "commits" REFLOG_COMMITS_CONTEXT_KEY types.ContextKey = "reflogCommits" SUB_COMMITS_CONTEXT_KEY types.ContextKey = "subCommits" COMMIT_FILES_CONTEXT_KEY types.ContextKey = "commitFiles" @@ -41,7 +41,7 @@ var AllContextKeys = []types.ContextKey{ REMOTES_CONTEXT_KEY, REMOTE_BRANCHES_CONTEXT_KEY, TAGS_CONTEXT_KEY, - BRANCH_COMMITS_CONTEXT_KEY, + LOCAL_COMMITS_CONTEXT_KEY, REFLOG_COMMITS_CONTEXT_KEY, SUB_COMMITS_CONTEXT_KEY, COMMIT_FILES_CONTEXT_KEY, @@ -67,7 +67,7 @@ type ContextTree struct { Menu *MenuContext Branches *BranchesContext Tags *TagsContext - BranchCommits *LocalCommitsContext + LocalCommits *LocalCommitsContext CommitFiles *CommitFilesContext Remotes *RemotesContext Submodules *SubmodulesContext @@ -97,7 +97,7 @@ func (self *ContextTree) Flatten() []types.Context { self.Remotes, self.RemoteBranches, self.Tags, - self.BranchCommits, + self.LocalCommits, self.CommitFiles, self.ReflogCommits, self.Stash, @@ -170,7 +170,7 @@ func (tree ContextTree) InitialViewTabContextMap() map[string][]TabContext { "commits": { { Tab: "Commits", - Contexts: []types.Context{tree.BranchCommits}, + Contexts: []types.Context{tree.LocalCommits}, }, { Tab: "Reflog", diff --git a/pkg/gui/context/local_commits_context.go b/pkg/gui/context/local_commits_context.go index 9da4721e3..408a906ba 100644 --- a/pkg/gui/context/local_commits_context.go +++ b/pkg/gui/context/local_commits_context.go @@ -34,7 +34,7 @@ func NewLocalCommitsContext( Context: NewSimpleContext(NewBaseContext(NewBaseContextOpts{ ViewName: "commits", WindowName: "commits", - Key: BRANCH_COMMITS_CONTEXT_KEY, + Key: LOCAL_COMMITS_CONTEXT_KEY, Kind: types.SIDE_CONTEXT, Focusable: true, }), ContextCallbackOpts{ diff --git a/pkg/gui/context_config.go b/pkg/gui/context_config.go index c8e9aa0fa..348c5b21b 100644 --- a/pkg/gui/context_config.go +++ b/pkg/gui/context_config.go @@ -36,7 +36,7 @@ func (gui *Gui) contextTree() *context.ContextTree { Menu: gui.menuListContext(), Remotes: gui.remotesListContext(), RemoteBranches: gui.remoteBranchesListContext(), - BranchCommits: gui.branchCommitsListContext(), + LocalCommits: gui.branchCommitsListContext(), CommitFiles: gui.commitFilesListContext(), ReflogCommits: gui.reflogCommitsListContext(), SubCommits: gui.subCommitsListContext(), diff --git a/pkg/gui/controllers/bisect_controller.go b/pkg/gui/controllers/bisect_controller.go index addcd8d80..5dae02a38 100644 --- a/pkg/gui/controllers/bisect_controller.go +++ b/pkg/gui/controllers/bisect_controller.go @@ -239,5 +239,5 @@ func (self *BisectController) Context() types.Context { } func (self *BisectController) context() *context.LocalCommitsContext { - return self.contexts.BranchCommits + return self.contexts.LocalCommits } diff --git a/pkg/gui/controllers/helpers/cherry_pick_helper.go b/pkg/gui/controllers/helpers/cherry_pick_helper.go index a0fd4ebca..badbf0dfe 100644 --- a/pkg/gui/controllers/helpers/cherry_pick_helper.go +++ b/pkg/gui/controllers/helpers/cherry_pick_helper.go @@ -143,7 +143,7 @@ func (self *CherryPickHelper) resetIfNecessary(context types.Context) error { func (self *CherryPickHelper) rerender() error { for _, context := range []types.Context{ - self.contexts.BranchCommits, + self.contexts.LocalCommits, self.contexts.ReflogCommits, self.contexts.SubCommits, } { diff --git a/pkg/gui/controllers/helpers/refs_helper.go b/pkg/gui/controllers/helpers/refs_helper.go index 3b132a32f..e3e050117 100644 --- a/pkg/gui/controllers/helpers/refs_helper.go +++ b/pkg/gui/controllers/helpers/refs_helper.go @@ -55,9 +55,9 @@ func (self *RefsHelper) CheckoutRef(ref string, options types.CheckoutRefOptions onSuccess := func() { self.contexts.Branches.SetSelectedLineIdx(0) self.contexts.ReflogCommits.SetSelectedLineIdx(0) - self.contexts.BranchCommits.SetSelectedLineIdx(0) + self.contexts.LocalCommits.SetSelectedLineIdx(0) // loading a heap of commits is slow so we limit them whenever doing a reset - self.contexts.BranchCommits.SetLimitCommits(true) + self.contexts.LocalCommits.SetLimitCommits(true) } return self.c.WithWaitingStatus(waitingStatus, func() error { @@ -117,12 +117,12 @@ func (self *RefsHelper) ResetToRef(ref string, strength string, envVars []string return self.c.Error(err) } - self.contexts.BranchCommits.SetSelectedLineIdx(0) + self.contexts.LocalCommits.SetSelectedLineIdx(0) self.contexts.ReflogCommits.SetSelectedLineIdx(0) // loading a heap of commits is slow so we limit them whenever doing a reset - self.contexts.BranchCommits.SetLimitCommits(true) + self.contexts.LocalCommits.SetLimitCommits(true) - if err := self.c.PushContext(self.contexts.BranchCommits); err != nil { + if err := self.c.PushContext(self.contexts.LocalCommits); err != nil { return err } @@ -179,7 +179,7 @@ func (self *RefsHelper) NewBranch(from string, fromFormattedName string, suggest } } - self.contexts.BranchCommits.SetSelectedLineIdx(0) + self.contexts.LocalCommits.SetSelectedLineIdx(0) self.contexts.Branches.SetSelectedLineIdx(0) return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC}) diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index 0a7d51ae6..fa2df887e 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -746,7 +746,7 @@ func (self *LocalCommitsController) Context() types.Context { } func (self *LocalCommitsController) context() *context.LocalCommitsContext { - return self.contexts.BranchCommits + return self.contexts.LocalCommits } func (self *LocalCommitsController) newBranch(commit *models.Commit) error { diff --git a/pkg/gui/custom_commands.go b/pkg/gui/custom_commands.go index 6bd659bd7..01a37adce 100644 --- a/pkg/gui/custom_commands.go +++ b/pkg/gui/custom_commands.go @@ -44,7 +44,7 @@ func (gui *Gui) resolveTemplate(templateStr string, promptResponses []string) (s objects := CustomCommandObjects{ SelectedFile: gui.getSelectedFile(), SelectedPath: gui.getSelectedPath(), - SelectedLocalCommit: gui.State.Contexts.BranchCommits.GetSelected(), + SelectedLocalCommit: gui.State.Contexts.LocalCommits.GetSelected(), SelectedReflogCommit: gui.State.Contexts.ReflogCommits.GetSelected(), SelectedLocalBranch: gui.State.Contexts.Branches.GetSelected(), SelectedRemoteBranch: gui.State.Contexts.RemoteBranches.GetSelected(), diff --git a/pkg/gui/diff_context_size.go b/pkg/gui/diff_context_size.go index e16b26852..96ec29ee2 100644 --- a/pkg/gui/diff_context_size.go +++ b/pkg/gui/diff_context_size.go @@ -11,7 +11,7 @@ var CONTEXT_KEYS_SHOWING_DIFFS = []types.ContextKey{ context.FILES_CONTEXT_KEY, context.COMMIT_FILES_CONTEXT_KEY, context.STASH_CONTEXT_KEY, - context.BRANCH_COMMITS_CONTEXT_KEY, + context.LOCAL_COMMITS_CONTEXT_KEY, context.SUB_COMMITS_CONTEXT_KEY, context.MAIN_STAGING_CONTEXT_KEY, context.MAIN_PATCH_BUILDING_CONTEXT_KEY, diff --git a/pkg/gui/filtering.go b/pkg/gui/filtering.go index 4780387c9..ac365e3a7 100644 --- a/pkg/gui/filtering.go +++ b/pkg/gui/filtering.go @@ -46,11 +46,11 @@ func (gui *Gui) setFiltering(path string) error { gui.State.ScreenMode = SCREEN_HALF } - if err := gui.c.PushContext(gui.State.Contexts.BranchCommits); err != nil { + if err := gui.c.PushContext(gui.State.Contexts.LocalCommits); err != nil { return err } return gui.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}, Then: func() { - gui.State.Contexts.BranchCommits.SetSelectedLineIdx(0) + gui.State.Contexts.LocalCommits.SetSelectedLineIdx(0) }}) } diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 84203c9e5..8b5cef4c4 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -278,7 +278,7 @@ type guiMutexes struct { RefreshingFilesMutex *sync.Mutex RefreshingStatusMutex *sync.Mutex SyncMutex *sync.Mutex - BranchCommitsMutex *sync.Mutex + LocalCommitsMutex *sync.Mutex LineByLinePanelMutex *sync.Mutex SubprocessMutex *sync.Mutex } @@ -337,7 +337,7 @@ func (gui *Gui) resetState(filterPath string, reuseState bool) { var initialContext types.IListContext = contextTree.Files if filterPath != "" { screenMode = SCREEN_HALF - initialContext = contextTree.BranchCommits + initialContext = contextTree.LocalCommits } viewContextMap := context.NewViewContextMap() @@ -397,7 +397,7 @@ func initialViewContextMapping(contextTree *context.ContextTree) map[string]type "status": contextTree.Status, "files": contextTree.Files, "branches": contextTree.Branches, - "commits": contextTree.BranchCommits, + "commits": contextTree.LocalCommits, "commitFiles": contextTree.CommitFiles, "stash": contextTree.Stash, "menu": contextTree.Menu, @@ -440,7 +440,7 @@ func NewGui( RefreshingFilesMutex: &sync.Mutex{}, RefreshingStatusMutex: &sync.Mutex{}, SyncMutex: &sync.Mutex{}, - BranchCommitsMutex: &sync.Mutex{}, + LocalCommitsMutex: &sync.Mutex{}, LineByLinePanelMutex: &sync.Mutex{}, SubprocessMutex: &sync.Mutex{}, }, @@ -579,7 +579,7 @@ func (gui *Gui) resetControllers() { controllers.AttachControllers(gui.State.Contexts.Files, gui.Controllers.Files) controllers.AttachControllers(gui.State.Contexts.Tags, gui.Controllers.Tags) controllers.AttachControllers(gui.State.Contexts.Submodules, gui.Controllers.Submodules) - controllers.AttachControllers(gui.State.Contexts.BranchCommits, gui.Controllers.LocalCommits, bisectController) + controllers.AttachControllers(gui.State.Contexts.LocalCommits, gui.Controllers.LocalCommits, bisectController) controllers.AttachControllers(gui.State.Contexts.Remotes, gui.Controllers.Remotes) controllers.AttachControllers(gui.State.Contexts.Menu, gui.Controllers.Menu) controllers.AttachControllers(gui.State.Contexts.Global, gui.Controllers.Sync, gui.Controllers.Undo, gui.Controllers.Global) diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index a2dd7a419..662d8a327 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -412,14 +412,14 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi }, { ViewName: "commits", - Contexts: []string{string(context.BRANCH_COMMITS_CONTEXT_KEY)}, + Contexts: []string{string(context.LOCAL_COMMITS_CONTEXT_KEY)}, Key: opts.GetKey(opts.Config.Universal.CopyToClipboard), Handler: self.handleCopySelectedSideContextItemToClipboard, Description: self.c.Tr.LcCopyCommitShaToClipboard, }, { ViewName: "commits", - Contexts: []string{string(context.BRANCH_COMMITS_CONTEXT_KEY)}, + Contexts: []string{string(context.LOCAL_COMMITS_CONTEXT_KEY)}, Key: opts.GetKey(opts.Config.Commits.ResetCherryPick), Handler: self.helpers.CherryPick.Reset, Description: self.c.Tr.LcResetCherryPick, diff --git a/pkg/gui/list_context_config.go b/pkg/gui/list_context_config.go index b8609e9b7..397e38bd9 100644 --- a/pkg/gui/list_context_config.go +++ b/pkg/gui/list_context_config.go @@ -114,8 +114,8 @@ func (gui *Gui) branchCommitsListContext() *context.LocalCommitsContext { gui.Views.Commits, func(startIdx int, length int) [][]string { selectedCommitSha := "" - if gui.currentContext().GetKey() == context.BRANCH_COMMITS_CONTEXT_KEY { - selectedCommit := gui.State.Contexts.BranchCommits.GetSelected() + if gui.currentContext().GetKey() == context.LOCAL_COMMITS_CONTEXT_KEY { + selectedCommit := gui.State.Contexts.LocalCommits.GetSelected() if selectedCommit != nil { selectedCommitSha = selectedCommit.Sha } @@ -266,7 +266,7 @@ func (gui *Gui) submodulesListContext() *context.SubmodulesContext { func (gui *Gui) suggestionsListContext() *context.SuggestionsContext { return context.NewSuggestionsContext( func() []*types.Suggestion { return gui.State.Suggestions }, - gui.Views.Files, + gui.Views.Suggestions, func(startIdx int, length int) [][]string { return presentation.GetSuggestionListDisplayStrings(gui.State.Suggestions) }, @@ -285,7 +285,7 @@ func (gui *Gui) getListContexts() []types.IListContext { gui.State.Contexts.Remotes, gui.State.Contexts.RemoteBranches, gui.State.Contexts.Tags, - gui.State.Contexts.BranchCommits, + gui.State.Contexts.LocalCommits, gui.State.Contexts.ReflogCommits, gui.State.Contexts.SubCommits, gui.State.Contexts.Stash, diff --git a/pkg/gui/patch_options_panel.go b/pkg/gui/patch_options_panel.go index 81d232da2..14de524a5 100644 --- a/pkg/gui/patch_options_panel.go +++ b/pkg/gui/patch_options_panel.go @@ -44,7 +44,7 @@ func (gui *Gui) handleCreatePatchOptionsMenu() error { }, }...) - if gui.currentContext().GetKey() == gui.State.Contexts.BranchCommits.GetKey() { + if gui.currentContext().GetKey() == gui.State.Contexts.LocalCommits.GetKey() { selectedCommit := gui.getSelectedLocalCommit() if selectedCommit != nil && gui.git.Patch.PatchManager.To != selectedCommit.Sha { // adding this option to index 1 @@ -118,7 +118,7 @@ func (gui *Gui) handleMovePatchToSelectedCommit() error { return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error { commitIndex := gui.getPatchCommitIndex() gui.c.LogAction(gui.c.Tr.Actions.MovePatchToSelectedCommit) - err := gui.git.Patch.MovePatchToSelectedCommit(gui.State.Model.Commits, commitIndex, gui.State.Contexts.BranchCommits.GetSelectedLineIdx()) + err := gui.git.Patch.MovePatchToSelectedCommit(gui.State.Model.Commits, commitIndex, gui.State.Contexts.LocalCommits.GetSelectedLineIdx()) return gui.helpers.MergeAndRebase.CheckMergeOrRebase(err) }) } diff --git a/pkg/gui/refresh.go b/pkg/gui/refresh.go index 215028609..d9d661cff 100644 --- a/pkg/gui/refresh.go +++ b/pkg/gui/refresh.go @@ -186,7 +186,7 @@ func (gui *Gui) refreshCommits() { go utils.Safe(func() { _ = gui.refreshCommitsWithLimit() ctx, ok := gui.State.Contexts.CommitFiles.GetParentContext() - if ok && ctx.GetKey() == context.BRANCH_COMMITS_CONTEXT_KEY { + if ok && ctx.GetKey() == context.LOCAL_COMMITS_CONTEXT_KEY { // This makes sense when we've e.g. just amended a commit, meaning we get a new commit SHA at the same position. // However if we've just added a brand new commit, it pushes the list down by one and so we would end up // showing the contents of a different commit than the one we initially entered. @@ -206,16 +206,16 @@ func (gui *Gui) refreshCommits() { } func (gui *Gui) refreshCommitsWithLimit() error { - gui.Mutexes.BranchCommitsMutex.Lock() - defer gui.Mutexes.BranchCommitsMutex.Unlock() + gui.Mutexes.LocalCommitsMutex.Lock() + defer gui.Mutexes.LocalCommitsMutex.Unlock() commits, err := gui.git.Loaders.Commits.GetCommits( loaders.GetCommitsOptions{ - Limit: gui.State.Contexts.BranchCommits.GetLimitCommits(), + Limit: gui.State.Contexts.LocalCommits.GetLimitCommits(), FilterPath: gui.State.Modes.Filtering.GetPath(), IncludeRebaseCommits: true, RefName: gui.refForLog(), - All: gui.State.Contexts.BranchCommits.GetShowWholeGitGraph(), + All: gui.State.Contexts.LocalCommits.GetShowWholeGitGraph(), }, ) if err != nil { @@ -223,12 +223,12 @@ func (gui *Gui) refreshCommitsWithLimit() error { } gui.State.Model.Commits = commits - return gui.c.PostRefreshUpdate(gui.State.Contexts.BranchCommits) + return gui.c.PostRefreshUpdate(gui.State.Contexts.LocalCommits) } func (gui *Gui) refreshRebaseCommits() error { - gui.Mutexes.BranchCommitsMutex.Lock() - defer gui.Mutexes.BranchCommitsMutex.Unlock() + gui.Mutexes.LocalCommitsMutex.Lock() + defer gui.Mutexes.LocalCommitsMutex.Unlock() updatedCommits, err := gui.git.Loaders.Commits.MergeRebasingCommits(gui.State.Model.Commits) if err != nil { @@ -236,7 +236,7 @@ func (gui *Gui) refreshRebaseCommits() error { } gui.State.Model.Commits = updatedCommits - return gui.c.PostRefreshUpdate(gui.State.Contexts.BranchCommits) + return gui.c.PostRefreshUpdate(gui.State.Contexts.LocalCommits) } func (self *Gui) refreshTags() error {