1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-06 23:46:13 +02:00

resetting controllers on new repo

This commit is contained in:
Jesse Duffield 2022-01-31 22:11:34 +11:00
parent eb056576cf
commit 2a1e3faa0c
76 changed files with 514 additions and 370 deletions

4
go.mod
View File

@ -20,7 +20,7 @@ require (
github.com/imdario/mergo v0.3.11 github.com/imdario/mergo v0.3.11
github.com/integrii/flaggy v1.4.0 github.com/integrii/flaggy v1.4.0
github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4 github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4
github.com/jesseduffield/gocui v0.3.1-0.20220108045521-1945d7b9ed8b github.com/jesseduffield/gocui v0.3.1-0.20220131110921-82fe47ec96ba
github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e
github.com/jesseduffield/yaml v2.1.0+incompatible github.com/jesseduffield/yaml v2.1.0+incompatible
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
@ -42,7 +42,7 @@ require (
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 // indirect golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 // indirect
golang.org/x/net v0.0.0-20201002202402-0a1ea396d57c // indirect golang.org/x/net v0.0.0-20201002202402-0a1ea396d57c // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
gopkg.in/ozeidan/fuzzy-patricia.v3 v3.0.0 gopkg.in/ozeidan/fuzzy-patricia.v3 v3.0.0
) )

8
go.sum
View File

@ -41,8 +41,8 @@ github.com/gdamore/tcell/v2 v2.4.1-0.20220313203054-2a1a1b586447/go.mod h1:I8YJF
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs= github.com/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
github.com/go-errors/errors v1.4.1 h1:IvVlgbzSsaUNudsw5dcXSzF3EWyXTi5XrAdngnuhRyg= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
github.com/go-errors/errors v1.4.1/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E=
github.com/go-git/go-billy/v5 v5.0.0 h1:7NQHvd9FVid8VL4qVUMm8XifBK+2xCoZ2lSk0agRrHM= github.com/go-git/go-billy/v5 v5.0.0 h1:7NQHvd9FVid8VL4qVUMm8XifBK+2xCoZ2lSk0agRrHM=
@ -73,8 +73,8 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOl
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4 h1:GOQrmaE8i+KEdB8NzAegKYd4tPn/inM0I1uo0NXFerg= github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4 h1:GOQrmaE8i+KEdB8NzAegKYd4tPn/inM0I1uo0NXFerg=
github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4/go.mod h1:nGNEErzf+NRznT+N2SWqmHnDnF9aLgANB1CUNEan09o= github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4/go.mod h1:nGNEErzf+NRznT+N2SWqmHnDnF9aLgANB1CUNEan09o=
github.com/jesseduffield/gocui v0.3.1-0.20220108045521-1945d7b9ed8b h1:AUK5nDiPiaahBtGIsf8rITgZ9SC+uddvnNKs0/mrYA8= github.com/jesseduffield/gocui v0.3.1-0.20220131110921-82fe47ec96ba h1:5czcvu7MjSzrS12qPCLhh6yiE2eRz+tZCybH7Q85TpM=
github.com/jesseduffield/gocui v0.3.1-0.20220108045521-1945d7b9ed8b/go.mod h1:znJuCDnF2Ph40YZSlBwdX/4GEofnIoWLGdT4mK5zRAU= github.com/jesseduffield/gocui v0.3.1-0.20220131110921-82fe47ec96ba/go.mod h1:znJuCDnF2Ph40YZSlBwdX/4GEofnIoWLGdT4mK5zRAU=
github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e h1:uw/oo+kg7t/oeMs6sqlAwr85ND/9cpO3up3VxphxY0U= github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e h1:uw/oo+kg7t/oeMs6sqlAwr85ND/9cpO3up3VxphxY0U=
github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e/go.mod h1:u60qdFGXRd36jyEXxetz0vQceQIxzI13lIo3EFUDf4I= github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e/go.mod h1:u60qdFGXRd36jyEXxetz0vQceQIxzI13lIo3EFUDf4I=
github.com/jesseduffield/yaml v2.1.0+incompatible h1:HWQJ1gIv2zHKbDYNp0Jwjlj24K8aqpFHnMCynY1EpmE= github.com/jesseduffield/yaml v2.1.0+incompatible h1:HWQJ1gIv2zHKbDYNp0Jwjlj24K8aqpFHnMCynY1EpmE=

View File

@ -132,10 +132,10 @@ func main() {
log.Fatal(err.Error()) log.Fatal(err.Error())
} }
app, err := app.NewApp(appConfig, filterPath) app, err := app.NewApp(appConfig)
if err == nil { if err == nil {
err = app.Run() err = app.Run(filterPath)
} }
if err != nil { if err != nil {

View File

@ -94,7 +94,7 @@ func newLogger(config config.AppConfigurer) *logrus.Entry {
} }
// NewApp bootstrap a new application // NewApp bootstrap a new application
func NewApp(config config.AppConfigurer, filterPath string) (*App, error) { func NewApp(config config.AppConfigurer) (*App, error) {
userConfig := config.GetUserConfig() userConfig := config.GetUserConfig()
app := &App{ app := &App{
@ -140,7 +140,7 @@ func NewApp(config config.AppConfigurer, filterPath string) (*App, error) {
gitConfig := git_config.NewStdCachedGitConfig(app.Log) gitConfig := git_config.NewStdCachedGitConfig(app.Log)
app.Gui, err = gui.NewGui(app.Common, config, gitConfig, app.Updater, filterPath, showRecentRepos, dirName) app.Gui, err = gui.NewGui(app.Common, config, gitConfig, app.Updater, showRecentRepos, dirName)
if err != nil { if err != nil {
return app, err return app, err
} }
@ -241,7 +241,7 @@ func (app *App) setupRepo() (bool, error) {
return false, nil return false, nil
} }
func (app *App) Run() error { func (app *App) Run(filterPath string) error {
if app.ClientContext == "INTERACTIVE_REBASE" { if app.ClientContext == "INTERACTIVE_REBASE" {
return app.Rebase() return app.Rebase()
} }
@ -250,7 +250,7 @@ func (app *App) Run() error {
os.Exit(0) os.Exit(0)
} }
err := app.Gui.RunAndHandleError() err := app.Gui.RunAndHandleError(filterPath)
return err return err
} }

View File

@ -41,7 +41,7 @@ func generateAtDir(cheatsheetDir string) {
for lang := range translationSetsByLang { for lang := range translationSetsByLang {
mConfig.GetUserConfig().Gui.Language = lang mConfig.GetUserConfig().Gui.Language = lang
mApp, _ := app.NewApp(mConfig, "") mApp, _ := app.NewApp(mConfig)
path := cheatsheetDir + "/Keybindings_" + lang + ".md" path := cheatsheetDir + "/Keybindings_" + lang + ".md"
file, err := os.Create(path) file, err := os.Create(path)
if err != nil { if err != nil {

View File

@ -14,7 +14,7 @@ import (
// list panel functions // list panel functions
func (gui *Gui) getSelectedBranch() *models.Branch { func (gui *Gui) getSelectedBranch() *models.Branch {
if len(gui.State.Branches) == 0 { if len(gui.State.Model.Branches) == 0 {
return nil return nil
} }
@ -23,7 +23,7 @@ func (gui *Gui) getSelectedBranch() *models.Branch {
return nil return nil
} }
return gui.State.Branches[selectedLine] return gui.State.Model.Branches[selectedLine]
} }
func (gui *Gui) branchesRenderToMain() error { func (gui *Gui) branchesRenderToMain() error {
@ -56,7 +56,7 @@ func (gui *Gui) handleBranchPress() error {
} }
branch := gui.getSelectedBranch() branch := gui.getSelectedBranch()
gui.c.LogAction(gui.c.Tr.Actions.CheckoutBranch) gui.c.LogAction(gui.c.Tr.Actions.CheckoutBranch)
return gui.helpers.refs.CheckoutRef(branch.Name, types.CheckoutRefOptions{}) return gui.helpers.Refs.CheckoutRef(branch.Name, types.CheckoutRefOptions{})
} }
func (gui *Gui) handleCreatePullRequestPress() error { func (gui *Gui) handleCreatePullRequestPress() error {
@ -129,10 +129,10 @@ func (gui *Gui) handleForceCheckout() error {
func (gui *Gui) handleCheckoutByName() error { func (gui *Gui) handleCheckoutByName() error {
return gui.c.Prompt(types.PromptOpts{ return gui.c.Prompt(types.PromptOpts{
Title: gui.c.Tr.BranchName + ":", Title: gui.c.Tr.BranchName + ":",
FindSuggestionsFunc: gui.helpers.suggestions.GetRefsSuggestionsFunc(), FindSuggestionsFunc: gui.helpers.Suggestions.GetRefsSuggestionsFunc(),
HandleConfirm: func(response string) error { HandleConfirm: func(response string) error {
gui.c.LogAction("Checkout branch") gui.c.LogAction("Checkout branch")
return gui.helpers.refs.CheckoutRef(response, types.CheckoutRefOptions{ return gui.helpers.Refs.CheckoutRef(response, types.CheckoutRefOptions{
OnRefNotFound: func(ref string) error { OnRefNotFound: func(ref string) error {
return gui.c.Ask(types.AskOpts{ return gui.c.Ask(types.AskOpts{
Title: gui.c.Tr.BranchNotFoundTitle, Title: gui.c.Tr.BranchNotFoundTitle,
@ -148,11 +148,11 @@ func (gui *Gui) handleCheckoutByName() error {
} }
func (gui *Gui) getCheckedOutBranch() *models.Branch { func (gui *Gui) getCheckedOutBranch() *models.Branch {
if len(gui.State.Branches) == 0 { if len(gui.State.Model.Branches) == 0 {
return nil return nil
} }
return gui.State.Branches[0] return gui.State.Model.Branches[0]
} }
func (gui *Gui) createNewBranchWithName(newBranchName string) error { func (gui *Gui) createNewBranchWithName(newBranchName string) error {
@ -239,7 +239,7 @@ func (gui *Gui) mergeBranchIntoCheckedOutBranch(branchName string) error {
HandleConfirm: func() error { HandleConfirm: func() error {
gui.c.LogAction(gui.c.Tr.Actions.Merge) gui.c.LogAction(gui.c.Tr.Actions.Merge)
err := gui.git.Branch.Merge(branchName, git_commands.MergeOpts{}) err := gui.git.Branch.Merge(branchName, git_commands.MergeOpts{})
return gui.helpers.rebase.CheckMergeOrRebase(err) return gui.helpers.Rebase.CheckMergeOrRebase(err)
}, },
}) })
} }
@ -273,7 +273,7 @@ func (gui *Gui) handleRebaseOntoBranch(selectedBranchName string) error {
HandleConfirm: func() error { HandleConfirm: func() error {
gui.c.LogAction(gui.c.Tr.Actions.RebaseBranch) gui.c.LogAction(gui.c.Tr.Actions.RebaseBranch)
err := gui.git.Rebase.RebaseBranch(selectedBranchName) err := gui.git.Rebase.RebaseBranch(selectedBranchName)
return gui.helpers.rebase.CheckMergeOrRebase(err) return gui.helpers.Rebase.CheckMergeOrRebase(err)
}, },
}) })
} }
@ -339,7 +339,7 @@ func (gui *Gui) handleCreateResetToBranchMenu() error {
return nil return nil
} }
return gui.helpers.refs.CreateGitResetMenu(branch.Name) return gui.helpers.Refs.CreateGitResetMenu(branch.Name)
} }
func (gui *Gui) handleRenameBranch() error { func (gui *Gui) handleRenameBranch() error {
@ -362,7 +362,7 @@ func (gui *Gui) handleRenameBranch() error {
gui.refreshBranches() gui.refreshBranches()
// now that we've got our stuff again we need to find that branch and reselect it. // now that we've got our stuff again we need to find that branch and reselect it.
for i, newBranch := range gui.State.Branches { for i, newBranch := range gui.State.Model.Branches {
if newBranch.Name == newBranchName { if newBranch.Name == newBranchName {
gui.State.Panels.Branches.SetSelectedLineIdx(i) gui.State.Panels.Branches.SetSelectedLineIdx(i)
if err := gui.State.Contexts.Branches.HandleRender(); err != nil { if err := gui.State.Contexts.Branches.HandleRender(); err != nil {
@ -390,12 +390,6 @@ func (gui *Gui) handleRenameBranch() error {
}) })
} }
// sanitizedBranchName will remove all spaces in favor of a dash "-" to meet
// git's branch naming requirement.
func sanitizedBranchName(input string) string {
return strings.Replace(input, " ", "-", -1)
}
func (gui *Gui) handleEnterBranch() error { func (gui *Gui) handleEnterBranch() error {
branch := gui.getSelectedBranch() branch := gui.getSelectedBranch()
if branch == nil { if branch == nil {
@ -411,5 +405,5 @@ func (gui *Gui) handleNewBranchOffBranch() error {
return nil return nil
} }
return gui.helpers.refs.NewBranch(selectedBranch.RefName(), selectedBranch.RefName(), "") return gui.helpers.Refs.NewBranch(selectedBranch.RefName(), selectedBranch.RefName(), "")
} }

View File

@ -82,8 +82,8 @@ func (gui *Gui) handleDiscardOldFileChange() error {
HandleConfirm: func() error { HandleConfirm: func() error {
return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error { return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error {
gui.c.LogAction(gui.c.Tr.Actions.DiscardOldFileChange) gui.c.LogAction(gui.c.Tr.Actions.DiscardOldFileChange)
if err := gui.git.Rebase.DiscardOldFileChanges(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, fileName); err != nil { if err := gui.git.Rebase.DiscardOldFileChanges(gui.State.Model.Commits, gui.State.Panels.Commits.SelectedLineIdx, fileName); err != nil {
if err := gui.helpers.rebase.CheckMergeOrRebase(err); err != nil { if err := gui.helpers.Rebase.CheckMergeOrRebase(err); err != nil {
return err return err
} }
} }
@ -109,7 +109,7 @@ func (gui *Gui) refreshCommitFilesView() error {
if err != nil { if err != nil {
return gui.c.Error(err) return gui.c.Error(err)
} }
gui.State.CommitFiles = files gui.State.Model.CommitFiles = files
gui.State.Contexts.CommitFiles.CommitFileTreeViewModel.SetTree() gui.State.Contexts.CommitFiles.CommitFileTreeViewModel.SetTree()
return gui.c.PostRefreshUpdate(gui.State.Contexts.CommitFiles) return gui.c.PostRefreshUpdate(gui.State.Contexts.CommitFiles)
@ -121,7 +121,7 @@ func (gui *Gui) handleOpenOldCommitFile() error {
return nil return nil
} }
return gui.helpers.files.OpenFile(node.GetPath()) return gui.helpers.Files.OpenFile(node.GetPath())
} }
func (gui *Gui) handleEditCommitFile() error { func (gui *Gui) handleEditCommitFile() error {
@ -134,7 +134,7 @@ func (gui *Gui) handleEditCommitFile() error {
return gui.c.ErrorMsg(gui.c.Tr.ErrCannotEditDirectory) return gui.c.ErrorMsg(gui.c.Tr.ErrCannotEditDirectory)
} }
return gui.helpers.files.EditFile(node.GetPath()) return gui.helpers.Files.EditFile(node.GetPath())
} }
func (gui *Gui) handleToggleFileForPatch() error { func (gui *Gui) handleToggleFileForPatch() error {

View File

@ -12,11 +12,11 @@ const COMMIT_THRESHOLD = 200
func (gui *Gui) getSelectedLocalCommit() *models.Commit { func (gui *Gui) getSelectedLocalCommit() *models.Commit {
selectedLine := gui.State.Panels.Commits.SelectedLineIdx selectedLine := gui.State.Panels.Commits.SelectedLineIdx
if selectedLine == -1 || selectedLine > len(gui.State.Commits)-1 { if selectedLine == -1 || selectedLine > len(gui.State.Model.Commits)-1 {
return nil return nil
} }
return gui.State.Commits[selectedLine] return gui.State.Model.Commits[selectedLine]
} }
func (gui *Gui) onCommitFocus() error { func (gui *Gui) onCommitFocus() error {
@ -56,7 +56,7 @@ func (gui *Gui) branchCommitsRenderToMain() error {
func (gui *Gui) refForLog() string { func (gui *Gui) refForLog() string {
bisectInfo := gui.git.Bisect.GetInfo() bisectInfo := gui.git.Bisect.GetInfo()
gui.State.BisectInfo = bisectInfo gui.State.Model.BisectInfo = bisectInfo
if !bisectInfo.Started() { if !bisectInfo.Started() {
return "HEAD" return "HEAD"

View File

@ -40,7 +40,7 @@ type FilesController struct {
switchToMergeFn func(path string) error switchToMergeFn func(path string) error
suggestionsHelper ISuggestionsHelper suggestionsHelper ISuggestionsHelper
refsHelper IRefsHelper refsHelper IRefsHelper
filesHelper IFileHelper filesHelper IFilesHelper
workingTreeHelper IWorkingTreeHelper workingTreeHelper IWorkingTreeHelper
} }
@ -64,7 +64,7 @@ func NewFilesController(
switchToMergeFn func(path string) error, switchToMergeFn func(path string) error,
suggestionsHelper ISuggestionsHelper, suggestionsHelper ISuggestionsHelper,
refsHelper IRefsHelper, refsHelper IRefsHelper,
filesHelper IFileHelper, filesHelper IFilesHelper,
workingTreeHelper IWorkingTreeHelper, workingTreeHelper IWorkingTreeHelper,
) *FilesController { ) *FilesController {
return &FilesController{ return &FilesController{

View File

@ -1,12 +1,17 @@
package gui package controllers
import ( import (
"github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/gui/controllers"
"github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/gui/types"
) )
type IFilesHelper interface {
EditFile(filename string) error
EditFileAtLine(filename string, lineNumber int) error
OpenFile(filename string) error
}
type FilesHelper struct { type FilesHelper struct {
c *types.ControllerCommon c *types.ControllerCommon
git *commands.GitCommand git *commands.GitCommand
@ -25,7 +30,7 @@ func NewFilesHelper(
} }
} }
var _ controllers.IFileHelper = &FilesHelper{} var _ IFilesHelper = &FilesHelper{}
func (self *FilesHelper) EditFile(filename string) error { func (self *FilesHelper) EditFile(filename string) error {
return self.EditFileAtLine(filename, 1) return self.EditFileAtLine(filename, 1)

View File

@ -20,7 +20,6 @@ type (
GetHostingServiceMgrFn func() *hosting_service.HostingServiceMgr GetHostingServiceMgrFn func() *hosting_service.HostingServiceMgr
PullFilesFn func() error PullFilesFn func() error
CheckMergeOrRebase func(error) error CheckMergeOrRebase func(error) error
OpenSearchFn func(viewName string) error
) )
type LocalCommitsController struct { type LocalCommitsController struct {
@ -40,7 +39,6 @@ type LocalCommitsController struct {
pullFiles PullFilesFn pullFiles PullFilesFn
getHostingServiceMgr GetHostingServiceMgrFn getHostingServiceMgr GetHostingServiceMgrFn
switchToCommitFilesContext SwitchToCommitFilesContextFn switchToCommitFilesContext SwitchToCommitFilesContextFn
openSearch OpenSearchFn
getLimitCommits func() bool getLimitCommits func() bool
setLimitCommits func(bool) setLimitCommits func(bool)
getShowWholeGitGraph func() bool getShowWholeGitGraph func() bool
@ -65,7 +63,6 @@ func NewLocalCommitsController(
pullFiles PullFilesFn, pullFiles PullFilesFn,
getHostingServiceMgr GetHostingServiceMgrFn, getHostingServiceMgr GetHostingServiceMgrFn,
switchToCommitFilesContext SwitchToCommitFilesContextFn, switchToCommitFilesContext SwitchToCommitFilesContextFn,
openSearch OpenSearchFn,
getLimitCommits func() bool, getLimitCommits func() bool,
setLimitCommits func(bool), setLimitCommits func(bool),
getShowWholeGitGraph func() bool, getShowWholeGitGraph func() bool,
@ -87,7 +84,6 @@ func NewLocalCommitsController(
pullFiles: pullFiles, pullFiles: pullFiles,
getHostingServiceMgr: getHostingServiceMgr, getHostingServiceMgr: getHostingServiceMgr,
switchToCommitFilesContext: switchToCommitFilesContext, switchToCommitFilesContext: switchToCommitFilesContext,
openSearch: openSearch,
getLimitCommits: getLimitCommits, getLimitCommits: getLimitCommits,
setLimitCommits: setLimitCommits, setLimitCommits: setLimitCommits,
getShowWholeGitGraph: getShowWholeGitGraph, getShowWholeGitGraph: getShowWholeGitGraph,
@ -191,7 +187,7 @@ func (self *LocalCommitsController) Keybindings(
// more commits on demand // more commits on demand
{ {
Key: getKey(config.Universal.StartSearch), Key: getKey(config.Universal.StartSearch),
Handler: func() error { return self.handleOpenSearch("commits") }, Handler: self.openSearch,
Description: self.c.Tr.LcStartSearch, Description: self.c.Tr.LcStartSearch,
Tag: "navigation", Tag: "navigation",
}, },
@ -653,7 +649,7 @@ func (self *LocalCommitsController) handleCreateCommitResetMenu(commit *models.C
return self.refsHelper.CreateGitResetMenu(commit.Sha) return self.refsHelper.CreateGitResetMenu(commit.Sha)
} }
func (self *LocalCommitsController) handleOpenSearch(string) error { func (self *LocalCommitsController) openSearch() error {
// we usually lazyload these commits but now that we're searching we need to load them now // we usually lazyload these commits but now that we're searching we need to load them now
if self.getLimitCommits() { if self.getLimitCommits() {
self.setLimitCommits(false) self.setLimitCommits(false)
@ -662,7 +658,9 @@ func (self *LocalCommitsController) handleOpenSearch(string) error {
} }
} }
return self.openSearch("commits") self.c.OpenSearch()
return nil
} }
func (self *LocalCommitsController) gotoBottom() error { func (self *LocalCommitsController) gotoBottom() error {

View File

@ -1,4 +1,4 @@
package gui package controllers
import ( import (
"fmt" "fmt"
@ -7,35 +7,40 @@ import (
"github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/git_commands"
"github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/controllers"
"github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils" "github.com/jesseduffield/lazygit/pkg/utils"
) )
type IRefsHelper interface {
CheckoutRef(ref string, options types.CheckoutRefOptions) error
CreateGitResetMenu(ref string) error
ResetToRef(ref string, strength string, envVars []string) error
NewBranch(from string, fromDescription string, suggestedBranchname string) error
}
type RefsHelper struct { type RefsHelper struct {
c *types.ControllerCommon c *types.ControllerCommon
git *commands.GitCommand git *commands.GitCommand
getContexts func() context.ContextTree getContexts func() context.ContextTree
limitCommits func()
getState func() *GuiRepoState
} }
func NewRefsHelper( func NewRefsHelper(
c *types.ControllerCommon, c *types.ControllerCommon,
git *commands.GitCommand, git *commands.GitCommand,
getContexts func() context.ContextTree, getContexts func() context.ContextTree,
getState func() *GuiRepoState, limitCommits func(),
) *RefsHelper { ) *RefsHelper {
return &RefsHelper{ return &RefsHelper{
c: c, c: c,
git: git, git: git,
getContexts: getContexts, getContexts: getContexts,
getState: getState, limitCommits: limitCommits,
} }
} }
var _ controllers.IRefsHelper = &RefsHelper{} var _ IRefsHelper = &RefsHelper{}
func (self *RefsHelper) CheckoutRef(ref string, options types.CheckoutRefOptions) error { func (self *RefsHelper) CheckoutRef(ref string, options types.CheckoutRefOptions) error {
waitingStatus := options.WaitingStatus waitingStatus := options.WaitingStatus
@ -46,10 +51,11 @@ func (self *RefsHelper) CheckoutRef(ref string, options types.CheckoutRefOptions
cmdOptions := git_commands.CheckoutOptions{Force: false, EnvVars: options.EnvVars} cmdOptions := git_commands.CheckoutOptions{Force: false, EnvVars: options.EnvVars}
onSuccess := func() { onSuccess := func() {
self.getState().Panels.Branches.SelectedLineIdx = 0 self.getContexts().Branches.GetPanelState().SetSelectedLineIdx(0)
self.getState().Panels.Commits.SelectedLineIdx = 0 self.getContexts().BranchCommits.GetPanelState().SetSelectedLineIdx(0)
self.getContexts().ReflogCommits.GetPanelState().SetSelectedLineIdx(0)
// loading a heap of commits is slow so we limit them whenever doing a reset // loading a heap of commits is slow so we limit them whenever doing a reset
self.getState().Panels.Commits.LimitCommits = true self.limitCommits()
} }
return self.c.WithWaitingStatus(waitingStatus, func() error { return self.c.WithWaitingStatus(waitingStatus, func() error {
@ -101,12 +107,12 @@ func (self *RefsHelper) ResetToRef(ref string, strength string, envVars []string
return self.c.Error(err) return self.c.Error(err)
} }
self.getState().Panels.Commits.SelectedLineIdx = 0 self.getContexts().BranchCommits.GetPanelState().SetSelectedLineIdx(0)
self.getState().Panels.ReflogCommits.SelectedLineIdx = 0 self.getContexts().ReflogCommits.GetPanelState().SetSelectedLineIdx(0)
// loading a heap of commits is slow so we limit them whenever doing a reset // loading a heap of commits is slow so we limit them whenever doing a reset
self.getState().Panels.Commits.LimitCommits = true self.limitCommits()
if err := self.c.PushContext(self.getState().Contexts.BranchCommits); err != nil { if err := self.c.PushContext(self.getContexts().BranchCommits); err != nil {
return err return err
} }
@ -170,3 +176,9 @@ func (self *RefsHelper) NewBranch(from string, fromFormattedName string, suggest
}, },
}) })
} }
// sanitizedBranchName will remove all spaces in favor of a dash "-" to meet
// git's branch naming requirement.
func sanitizedBranchName(input string) string {
return strings.Replace(input, " ", "-", -1)
}

View File

@ -1,10 +1,9 @@
package gui package controllers
import ( import (
"fmt" "fmt"
"os" "os"
"github.com/jesseduffield/lazygit/pkg/gui/controllers"
"github.com/jesseduffield/lazygit/pkg/gui/presentation" "github.com/jesseduffield/lazygit/pkg/gui/presentation"
"github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils" "github.com/jesseduffield/lazygit/pkg/utils"
@ -22,30 +21,39 @@ import (
// finding suggestions in this file, so that it's easy to see if a function already // finding suggestions in this file, so that it's easy to see if a function already
// exists for fetching a particular model. // exists for fetching a particular model.
type ISuggestionsHelper interface {
GetRemoteSuggestionsFunc() func(string) []*types.Suggestion
GetBranchNameSuggestionsFunc() func(string) []*types.Suggestion
GetFilePathSuggestionsFunc() func(string) []*types.Suggestion
GetRemoteBranchesSuggestionsFunc(separator string) func(string) []*types.Suggestion
GetRefsSuggestionsFunc() func(string) []*types.Suggestion
GetCustomCommandsHistorySuggestionsFunc() func(string) []*types.Suggestion
}
type SuggestionsHelper struct { type SuggestionsHelper struct {
c *types.ControllerCommon c *types.ControllerCommon
getState func() *GuiRepoState model *types.Model
refreshSuggestionsFn func() refreshSuggestionsFn func()
} }
var _ controllers.ISuggestionsHelper = &SuggestionsHelper{} var _ ISuggestionsHelper = &SuggestionsHelper{}
func NewSuggestionsHelper( func NewSuggestionsHelper(
c *types.ControllerCommon, c *types.ControllerCommon,
getState func() *GuiRepoState, model *types.Model,
refreshSuggestionsFn func(), refreshSuggestionsFn func(),
) *SuggestionsHelper { ) *SuggestionsHelper {
return &SuggestionsHelper{ return &SuggestionsHelper{
c: c, c: c,
getState: getState, model: model,
refreshSuggestionsFn: refreshSuggestionsFn, refreshSuggestionsFn: refreshSuggestionsFn,
} }
} }
func (self *SuggestionsHelper) getRemoteNames() []string { func (self *SuggestionsHelper) getRemoteNames() []string {
result := make([]string, len(self.getState().Remotes)) result := make([]string, len(self.model.Remotes))
for i, remote := range self.getState().Remotes { for i, remote := range self.model.Remotes {
result[i] = remote.Name result[i] = remote.Name
} }
return result return result
@ -69,8 +77,8 @@ func (self *SuggestionsHelper) GetRemoteSuggestionsFunc() func(string) []*types.
} }
func (self *SuggestionsHelper) getBranchNames() []string { func (self *SuggestionsHelper) getBranchNames() []string {
result := make([]string, len(self.getState().Branches)) result := make([]string, len(self.model.Branches))
for i, branch := range self.getState().Branches { for i, branch := range self.model.Branches {
result[i] = branch.Name result[i] = branch.Name
} }
return result return result
@ -100,8 +108,8 @@ func (self *SuggestionsHelper) GetBranchNameSuggestionsFunc() func(string) []*ty
} }
// here we asynchronously fetch the latest set of paths in the repo and store in // here we asynchronously fetch the latest set of paths in the repo and store in
// self.State.FilesTrie. On the main thread we'll be doing a fuzzy search via // self.model.FilesTrie. On the main thread we'll be doing a fuzzy search via
// self.State.FilesTrie. So if we've looked for a file previously, we'll start with // self.model.FilesTrie. So if we've looked for a file previously, we'll start with
// the old trie and eventually it'll be swapped out for the new one. // the old trie and eventually it'll be swapped out for the new one.
// Notably, unlike other suggestion functions we're not showing all the options // Notably, unlike other suggestion functions we're not showing all the options
// if nothing has been typed because there'll be too much to display efficiently // if nothing has been typed because there'll be too much to display efficiently
@ -122,8 +130,9 @@ func (self *SuggestionsHelper) GetFilePathSuggestionsFunc() func(string) []*type
trie.Insert(patricia.Prefix(path), path) trie.Insert(patricia.Prefix(path), path)
return nil return nil
}) })
// cache the trie for future use // cache the trie for future use
self.getState().FilesTrie = trie self.model.FilesTrie = trie
self.refreshSuggestionsFn() self.refreshSuggestionsFn()
@ -132,7 +141,7 @@ func (self *SuggestionsHelper) GetFilePathSuggestionsFunc() func(string) []*type
return func(input string) []*types.Suggestion { return func(input string) []*types.Suggestion {
matchingNames := []string{} matchingNames := []string{}
_ = self.getState().FilesTrie.VisitFuzzy(patricia.Prefix(input), true, func(prefix patricia.Prefix, item patricia.Item, skipped int) error { _ = self.model.FilesTrie.VisitFuzzy(patricia.Prefix(input), true, func(prefix patricia.Prefix, item patricia.Item, skipped int) error {
matchingNames = append(matchingNames, item.(string)) matchingNames = append(matchingNames, item.(string))
return nil return nil
}) })
@ -154,7 +163,7 @@ func (self *SuggestionsHelper) GetFilePathSuggestionsFunc() func(string) []*type
func (self *SuggestionsHelper) getRemoteBranchNames(separator string) []string { func (self *SuggestionsHelper) getRemoteBranchNames(separator string) []string {
result := []string{} result := []string{}
for _, remote := range self.getState().Remotes { for _, remote := range self.model.Remotes {
for _, branch := range remote.Branches { for _, branch := range remote.Branches {
result = append(result, fmt.Sprintf("%s%s%s", remote.Name, separator, branch.Name)) result = append(result, fmt.Sprintf("%s%s%s", remote.Name, separator, branch.Name))
} }
@ -167,8 +176,8 @@ func (self *SuggestionsHelper) GetRemoteBranchesSuggestionsFunc(separator string
} }
func (self *SuggestionsHelper) getTagNames() []string { func (self *SuggestionsHelper) getTagNames() []string {
result := make([]string, len(self.getState().Tags)) result := make([]string, len(self.model.Tags))
for i, tag := range self.getState().Tags { for i, tag := range self.model.Tags {
result[i] = tag.Name result[i] = tag.Name
} }
return result return result

View File

@ -1,39 +1,9 @@
package controllers package controllers
import ( import (
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/gui/types"
) )
type IRefsHelper interface {
CheckoutRef(ref string, options types.CheckoutRefOptions) error
CreateGitResetMenu(ref string) error
ResetToRef(ref string, strength string, envVars []string) error
NewBranch(from string, fromDescription string, suggestedBranchname string) error
}
type ISuggestionsHelper interface {
GetRemoteSuggestionsFunc() func(string) []*types.Suggestion
GetBranchNameSuggestionsFunc() func(string) []*types.Suggestion
GetFilePathSuggestionsFunc() func(string) []*types.Suggestion
GetRemoteBranchesSuggestionsFunc(separator string) func(string) []*types.Suggestion
GetRefsSuggestionsFunc() func(string) []*types.Suggestion
GetCustomCommandsHistorySuggestionsFunc() func(string) []*types.Suggestion
}
type IFileHelper interface {
EditFile(filename string) error
EditFileAtLine(filename string, lineNumber int) error
OpenFile(filename string) error
}
type IWorkingTreeHelper interface {
AnyStagedFiles() bool
AnyTrackedFiles() bool
IsWorkingTreeDirty() bool
FileForSubmodule(submodule *models.SubmoduleConfig) *models.File
}
// all fields mandatory (except `CanRebase` because it's boolean) // all fields mandatory (except `CanRebase` because it's boolean)
type SwitchToCommitFilesContextOpts struct { type SwitchToCommitFilesContextOpts struct {
RefName string RefName string

View File

@ -1,22 +1,29 @@
package gui package controllers
import ( import (
"github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/types"
) )
type WorkingTreeHelper struct { type IWorkingTreeHelper interface {
getFiles func() []*models.File AnyStagedFiles() bool
AnyTrackedFiles() bool
IsWorkingTreeDirty() bool
FileForSubmodule(submodule *models.SubmoduleConfig) *models.File
} }
func NewWorkingTreeHelper(getFiles func() []*models.File) *WorkingTreeHelper { type WorkingTreeHelper struct {
model *types.Model
}
func NewWorkingTreeHelper(model *types.Model) *WorkingTreeHelper {
return &WorkingTreeHelper{ return &WorkingTreeHelper{
getFiles: getFiles, model: model,
} }
} }
func (self *WorkingTreeHelper) AnyStagedFiles() bool { func (self *WorkingTreeHelper) AnyStagedFiles() bool {
files := self.getFiles() for _, file := range self.model.Files {
for _, file := range files {
if file.HasStagedChanges { if file.HasStagedChanges {
return true return true
} }
@ -25,8 +32,7 @@ func (self *WorkingTreeHelper) AnyStagedFiles() bool {
} }
func (self *WorkingTreeHelper) AnyTrackedFiles() bool { func (self *WorkingTreeHelper) AnyTrackedFiles() bool {
files := self.getFiles() for _, file := range self.model.Files {
for _, file := range files {
if file.Tracked { if file.Tracked {
return true return true
} }
@ -39,7 +45,7 @@ func (self *WorkingTreeHelper) IsWorkingTreeDirty() bool {
} }
func (self *WorkingTreeHelper) FileForSubmodule(submodule *models.SubmoduleConfig) *models.File { func (self *WorkingTreeHelper) FileForSubmodule(submodule *models.SubmoduleConfig) *models.File {
for _, file := range self.getFiles() { for _, file := range self.model.Files {
if file.IsSubmodule([]*models.SubmoduleConfig{submodule}) { if file.IsSubmodule([]*models.SubmoduleConfig{submodule}) {
return file return file
} }

View File

@ -124,7 +124,7 @@ func (gui *Gui) handleCreateDiffingMenuPanel() error {
OnPress: func() error { OnPress: func() error {
return gui.c.Prompt(types.PromptOpts{ return gui.c.Prompt(types.PromptOpts{
Title: gui.c.Tr.LcEnteRefName, Title: gui.c.Tr.LcEnteRefName,
FindSuggestionsFunc: gui.helpers.suggestions.GetRefsSuggestionsFunc(), FindSuggestionsFunc: gui.helpers.Suggestions.GetRefsSuggestionsFunc(),
HandleConfirm: func(response string) error { HandleConfirm: func(response string) error {
gui.State.Modes.Diffing.Ref = strings.TrimSpace(response) gui.State.Modes.Diffing.Ref = strings.TrimSpace(response)
return gui.c.Refresh(types.RefreshOptions{Mode: types.ASYNC}) return gui.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})

View File

@ -17,6 +17,6 @@ func NewDummyUpdater() *updates.Updater {
func NewDummyGui() *Gui { func NewDummyGui() *Gui {
newAppConfig := config.NewDummyAppConfig() newAppConfig := config.NewDummyAppConfig()
dummyGui, _ := NewGui(utils.NewDummyCommon(), newAppConfig, git_config.NewFakeGitConfig(nil), NewDummyUpdater(), "", false, "") dummyGui, _ := NewGui(utils.NewDummyCommon(), newAppConfig, git_config.NewFakeGitConfig(nil), NewDummyUpdater(), false, "")
return dummyGui return dummyGui
} }

View File

@ -37,7 +37,7 @@ func (gui *Gui) handleCreateFilteringMenuPanel() error {
DisplayString: gui.c.Tr.LcFilterPathOption, DisplayString: gui.c.Tr.LcFilterPathOption,
OnPress: func() error { OnPress: func() error {
return gui.c.Prompt(types.PromptOpts{ return gui.c.Prompt(types.PromptOpts{
FindSuggestionsFunc: gui.helpers.suggestions.GetFilePathSuggestionsFunc(), FindSuggestionsFunc: gui.helpers.Suggestions.GetFilePathSuggestionsFunc(),
Title: gui.c.Tr.EnterFileName, Title: gui.c.Tr.EnterFileName,
HandleConfirm: func(response string) error { HandleConfirm: func(response string) error {
return gui.setFiltering(strings.TrimSpace(response)) return gui.setFiltering(strings.TrimSpace(response))

View File

@ -68,14 +68,14 @@ func NewContextManager(initialContext types.Context) ContextManager {
} }
type Helpers struct { type Helpers struct {
refs *RefsHelper Refs *controllers.RefsHelper
bisect *controllers.BisectHelper Bisect *controllers.BisectHelper
suggestions *SuggestionsHelper Suggestions *controllers.SuggestionsHelper
files *FilesHelper Files *controllers.FilesHelper
workingTree *WorkingTreeHelper WorkingTree *controllers.WorkingTreeHelper
tags *controllers.TagsHelper Tags *controllers.TagsHelper
rebase *controllers.RebaseHelper Rebase *controllers.RebaseHelper
cherryPick *controllers.CherryPickHelper CherryPick *controllers.CherryPickHelper
} }
type Repo string type Repo string
@ -174,40 +174,23 @@ type PrevLayout struct {
} }
type GuiRepoState struct { type GuiRepoState struct {
CommitFiles []*models.CommitFile Model *types.Model
Files []*models.File Modes Modes
Submodules []*models.SubmoduleConfig
Branches []*models.Branch
Commits []*models.Commit
StashEntries []*models.StashEntry
SubCommits []*models.Commit
Remotes []*models.Remote
RemoteBranches []*models.RemoteBranch
Tags []*models.Tag
// FilteredReflogCommits are the ones that appear in the reflog panel.
// when in filtering mode we only include the ones that match the given path
FilteredReflogCommits []*models.Commit
// ReflogCommits are the ones used by the branches panel to obtain recency values
// if we're not in filtering mode, CommitFiles and FilteredReflogCommits will be
// one and the same
ReflogCommits []*models.Commit
// Suggestions will sometimes appear when typing into a prompt // Suggestions will sometimes appear when typing into a prompt
Suggestions []*types.Suggestion Suggestions []*types.Suggestion
MenuItems []*types.MenuItem MenuItems []*types.MenuItem
BisectInfo *git_commands.BisectInfo
Updating bool Updating bool
Panels *panelStates Panels *panelStates
SplitMainPanel bool SplitMainPanel bool
MainContext types.ContextKey // used to keep the main and secondary views' contexts in sync
IsRefreshingFiles bool IsRefreshingFiles bool
Searching searchingState Searching searchingState
Ptmx *os.File Ptmx *os.File
StartupStage StartupStage // Allows us to not load everything at once StartupStage StartupStage // Allows us to not load everything at once
Modes Modes MainContext types.ContextKey // used to keep the main and secondary views' contexts in sync
ContextManager ContextManager ContextManager ContextManager
Contexts context.ContextTree Contexts context.ContextTree
ViewContextMap map[string]types.Context ViewContextMap map[string]types.Context
@ -223,9 +206,6 @@ type GuiRepoState struct {
// back in sync with the repo state // back in sync with the repo state
ViewsSetup bool ViewsSetup bool
// for displaying suggestions while typing in a file name
FilesTrie *patricia.Trie
// this is the message of the last failed commit attempt // this is the message of the last failed commit attempt
failedCommitMessage string failedCommitMessage string
@ -390,6 +370,29 @@ type guiMutexes struct {
SubprocessMutex *sync.Mutex SubprocessMutex *sync.Mutex
} }
func (gui *Gui) onNewRepo(filterPath string, reuseState bool) error {
var err error
gui.git, err = commands.NewGitCommand(
gui.Common,
gui.OSCommand,
git_config.NewStdCachedGitConfig(gui.Log),
gui.Mutexes.SyncMutex,
)
if err != nil {
return err
}
gui.resetState(filterPath, reuseState)
gui.resetControllers()
if err := gui.resetKeybindings(); err != nil {
return err
}
return nil
}
// reuseState determines if we pull the repo state from our repo state map or // reuseState determines if we pull the repo state from our repo state map or
// just re-initialize it. For now we're only re-using state when we're going // just re-initialize it. For now we're only re-using state when we're going
// in and out of submodules, for the sake of having the cursor back on the submodule // in and out of submodules, for the sake of having the cursor back on the submodule
@ -407,7 +410,6 @@ func (gui *Gui) resetState(filterPath string, reuseState bool) {
if state := gui.RepoStateMap[Repo(currentDir)]; state != nil { if state := gui.RepoStateMap[Repo(currentDir)]; state != nil {
gui.State = state gui.State = state
gui.State.ViewsSetup = false gui.State.ViewsSetup = false
return
} }
} else { } else {
gui.c.Log.Error(err) gui.c.Log.Error(err)
@ -424,12 +426,17 @@ func (gui *Gui) resetState(filterPath string, reuseState bool) {
} }
gui.State = &GuiRepoState{ gui.State = &GuiRepoState{
Model: &types.Model{
CommitFiles: nil,
Files: make([]*models.File, 0), Files: make([]*models.File, 0),
Commits: make([]*models.Commit, 0), Commits: make([]*models.Commit, 0),
StashEntries: make([]*models.StashEntry, 0),
FilteredReflogCommits: make([]*models.Commit, 0), FilteredReflogCommits: make([]*models.Commit, 0),
ReflogCommits: make([]*models.Commit, 0), ReflogCommits: make([]*models.Commit, 0),
StashEntries: make([]*models.StashEntry, 0),
BisectInfo: git_commands.NewNullBisectInfo(), BisectInfo: git_commands.NewNullBisectInfo(),
FilesTrie: patricia.NewTrie(),
},
Panels: &panelStates{ Panels: &panelStates{
// TODO: work out why some of these are -1 and some are 0. Last time I checked there was a good reason but I'm less certain now // TODO: work out why some of these are -1 and some are 0. Last time I checked there was a good reason but I'm less certain now
Submodules: &submodulePanelState{listPanelState{SelectedLineIdx: -1}}, Submodules: &submodulePanelState{listPanelState{SelectedLineIdx: -1}},
@ -459,7 +466,6 @@ func (gui *Gui) resetState(filterPath string, reuseState bool) {
// TODO: put contexts in the context manager // TODO: put contexts in the context manager
ContextManager: NewContextManager(initialContext), ContextManager: NewContextManager(initialContext),
Contexts: contexts, Contexts: contexts,
FilesTrie: patricia.NewTrie(),
} }
gui.RepoStateMap[Repo(currentDir)] = gui.State gui.RepoStateMap[Repo(currentDir)] = gui.State
@ -472,7 +478,6 @@ func NewGui(
config config.AppConfigurer, config config.AppConfigurer,
gitConfig git_config.IGitConfig, gitConfig git_config.IGitConfig,
updater *updates.Updater, updater *updates.Updater,
filterPath string,
showRecentRepos bool, showRecentRepos bool,
initialDir string, initialDir string,
) (*Gui, error) { ) (*Gui, error) {
@ -513,16 +518,6 @@ func NewGui(
osCommand := oscommands.NewOSCommand(cmn, oscommands.GetPlatform(), guiIO) osCommand := oscommands.NewOSCommand(cmn, oscommands.GetPlatform(), guiIO)
gui.OSCommand = osCommand gui.OSCommand = osCommand
var err error
gui.git, err = commands.NewGitCommand(
cmn,
osCommand,
gitConfig,
gui.Mutexes.SyncMutex,
)
if err != nil {
return nil, err
}
gui.watchFilesForChanges() gui.watchFilesForChanges()
@ -544,35 +539,32 @@ func NewGui(
// TODO: reset these controllers upon changing repos due to state changing // TODO: reset these controllers upon changing repos due to state changing
gui.c = controllerCommon gui.c = controllerCommon
gui.resetState(filterPath, false)
gui.setControllers()
authors.SetCustomAuthors(gui.UserConfig.Gui.AuthorColors) authors.SetCustomAuthors(gui.UserConfig.Gui.AuthorColors)
presentation.SetCustomBranches(gui.UserConfig.Gui.BranchColors) presentation.SetCustomBranches(gui.UserConfig.Gui.BranchColors)
return gui, nil return gui, nil
} }
func (gui *Gui) setControllers() { func (gui *Gui) resetControllers() {
controllerCommon := gui.c controllerCommon := gui.c
osCommand := gui.OSCommand osCommand := gui.OSCommand
getState := func() *GuiRepoState { return gui.State }
getContexts := func() context.ContextTree { return gui.State.Contexts } getContexts := func() context.ContextTree { return gui.State.Contexts }
// TODO: have a getGit function too
rebaseHelper := controllers.NewRebaseHelper(controllerCommon, getContexts, gui.git, gui.takeOverMergeConflictScrolling) rebaseHelper := controllers.NewRebaseHelper(controllerCommon, getContexts, gui.git, gui.takeOverMergeConflictScrolling)
model := gui.State.Model
gui.helpers = &Helpers{ gui.helpers = &Helpers{
refs: NewRefsHelper( Refs: controllers.NewRefsHelper(
controllerCommon, controllerCommon,
gui.git, gui.git,
getContexts, getContexts,
getState, func() { gui.State.Panels.Commits.LimitCommits = true },
), ),
bisect: controllers.NewBisectHelper(controllerCommon, gui.git), Bisect: controllers.NewBisectHelper(controllerCommon, gui.git),
suggestions: NewSuggestionsHelper(controllerCommon, getState, gui.refreshSuggestions), Suggestions: controllers.NewSuggestionsHelper(controllerCommon, model, gui.refreshSuggestions),
files: NewFilesHelper(controllerCommon, gui.git, osCommand), Files: controllers.NewFilesHelper(controllerCommon, gui.git, osCommand),
workingTree: NewWorkingTreeHelper(func() []*models.File { return gui.State.Files }), WorkingTree: controllers.NewWorkingTreeHelper(model),
tags: controllers.NewTagsHelper(controllerCommon, gui.git), Tags: controllers.NewTagsHelper(controllerCommon, gui.git),
rebase: rebaseHelper, Rebase: rebaseHelper,
cherryPick: controllers.NewCherryPickHelper( CherryPick: controllers.NewCherryPickHelper(
controllerCommon, controllerCommon,
gui.git, gui.git,
getContexts, getContexts,
@ -585,9 +577,9 @@ func (gui *Gui) setControllers() {
controllerCommon, controllerCommon,
gui.git, gui.git,
gui.getCheckedOutBranch, gui.getCheckedOutBranch,
gui.helpers.suggestions, gui.helpers.Suggestions,
gui.getSuggestedRemote, gui.getSuggestedRemote,
gui.helpers.rebase.CheckMergeOrRebase, gui.helpers.Rebase.CheckMergeOrRebase,
) )
gui.Controllers = Controllers{ gui.Controllers = Controllers{
@ -601,32 +593,32 @@ func (gui *Gui) setControllers() {
Files: controllers.NewFilesController( Files: controllers.NewFilesController(
controllerCommon, controllerCommon,
func() *context.WorkingTreeContext { return gui.State.Contexts.Files }, func() *context.WorkingTreeContext { return gui.State.Contexts.Files },
func() []*models.File { return gui.State.Files }, func() []*models.File { return gui.State.Model.Files },
gui.git, gui.git,
osCommand, osCommand,
gui.getSelectedFileNode, gui.getSelectedFileNode,
getContexts, getContexts,
gui.enterSubmodule, gui.enterSubmodule,
func() []*models.SubmoduleConfig { return gui.State.Submodules }, func() []*models.SubmoduleConfig { return gui.State.Model.Submodules },
gui.getSetTextareaTextFn(func() *gocui.View { return gui.Views.CommitMessage }), gui.getSetTextareaTextFn(func() *gocui.View { return gui.Views.CommitMessage }),
gui.withGpgHandling, gui.withGpgHandling,
func() string { return gui.State.failedCommitMessage }, func() string { return gui.State.failedCommitMessage },
func() []*models.Commit { return gui.State.Commits }, func() []*models.Commit { return gui.State.Model.Commits },
gui.getSelectedPath, gui.getSelectedPath,
gui.switchToMerge, gui.switchToMerge,
gui.helpers.suggestions, gui.helpers.Suggestions,
gui.helpers.refs, gui.helpers.Refs,
gui.helpers.files, gui.helpers.Files,
gui.helpers.workingTree, gui.helpers.WorkingTree,
), ),
Tags: controllers.NewTagsController( Tags: controllers.NewTagsController(
controllerCommon, controllerCommon,
func() *context.TagsContext { return gui.State.Contexts.Tags }, func() *context.TagsContext { return gui.State.Contexts.Tags },
gui.git, gui.git,
getContexts, getContexts,
gui.helpers.tags, gui.helpers.Tags,
gui.helpers.refs, gui.helpers.Refs,
gui.helpers.suggestions, gui.helpers.Suggestions,
gui.switchToSubCommitsContext, gui.switchToSubCommitsContext,
), ),
LocalCommits: controllers.NewLocalCommitsController( LocalCommits: controllers.NewLocalCommitsController(
@ -634,18 +626,17 @@ func (gui *Gui) setControllers() {
func() types.IListContext { return gui.State.Contexts.BranchCommits }, func() types.IListContext { return gui.State.Contexts.BranchCommits },
osCommand, osCommand,
gui.git, gui.git,
gui.helpers.tags, gui.helpers.Tags,
gui.helpers.refs, gui.helpers.Refs,
gui.helpers.cherryPick, gui.helpers.CherryPick,
gui.helpers.rebase, gui.helpers.Rebase,
gui.getSelectedLocalCommit, gui.getSelectedLocalCommit,
func() []*models.Commit { return gui.State.Commits }, func() []*models.Commit { return gui.State.Model.Commits },
func() int { return gui.State.Panels.Commits.SelectedLineIdx }, func() int { return gui.State.Panels.Commits.SelectedLineIdx },
gui.helpers.rebase.CheckMergeOrRebase, gui.helpers.Rebase.CheckMergeOrRebase,
syncController.HandlePull, syncController.HandlePull,
gui.getHostingServiceMgr, gui.getHostingServiceMgr,
gui.SwitchToCommitFilesContext, gui.SwitchToCommitFilesContext,
gui.handleOpenSearch,
func() bool { return gui.State.Panels.Commits.LimitCommits }, func() bool { return gui.State.Panels.Commits.LimitCommits },
func(value bool) { gui.State.Panels.Commits.LimitCommits = value }, func(value bool) { gui.State.Panels.Commits.LimitCommits = value },
func() bool { return gui.ShowWholeGitGraph }, func() bool { return gui.ShowWholeGitGraph },
@ -657,7 +648,7 @@ func (gui *Gui) setControllers() {
gui.git, gui.git,
getContexts, getContexts,
gui.getSelectedRemote, gui.getSelectedRemote,
func(branches []*models.RemoteBranch) { gui.State.RemoteBranches = branches }, func(branches []*models.RemoteBranch) { gui.State.Model.RemoteBranches = branches },
), ),
Menu: controllers.NewMenuController( Menu: controllers.NewMenuController(
controllerCommon, controllerCommon,
@ -668,16 +659,16 @@ func (gui *Gui) setControllers() {
controllerCommon, controllerCommon,
func() types.IListContext { return gui.State.Contexts.BranchCommits }, func() types.IListContext { return gui.State.Contexts.BranchCommits },
gui.git, gui.git,
gui.helpers.bisect, gui.helpers.Bisect,
gui.getSelectedLocalCommit, gui.getSelectedLocalCommit,
func() []*models.Commit { return gui.State.Commits }, func() []*models.Commit { return gui.State.Model.Commits },
), ),
Undo: controllers.NewUndoController( Undo: controllers.NewUndoController(
controllerCommon, controllerCommon,
gui.git, gui.git,
gui.helpers.refs, gui.helpers.Refs,
gui.helpers.workingTree, gui.helpers.WorkingTree,
func() []*models.Commit { return gui.State.FilteredReflogCommits }, func() []*models.Commit { return gui.State.Model.FilteredReflogCommits },
), ),
Sync: syncController, Sync: syncController,
} }
@ -689,8 +680,7 @@ var RuneReplacements = map[rune]string{
graph.CommitSymbol: "o", graph.CommitSymbol: "o",
} }
// Run setup the gui with keybindings and start the mainloop func (gui *Gui) initGocui() (*gocui.Gui, error) {
func (gui *Gui) Run() error {
recordEvents := recordingEvents() recordEvents := recordingEvents()
playMode := gocui.NORMAL playMode := gocui.NORMAL
if recordEvents { if recordEvents {
@ -700,20 +690,31 @@ func (gui *Gui) Run() error {
} }
g, err := gocui.NewGui(gocui.OutputTrue, OverlappingEdges, playMode, headless(), RuneReplacements) g, err := gocui.NewGui(gocui.OutputTrue, OverlappingEdges, playMode, headless(), RuneReplacements)
if err != nil {
return nil, err
}
return g, nil
}
// Run: setup the gui with keybindings and start the mainloop
func (gui *Gui) Run(filterPath string) error {
g, err := gui.initGocui()
if err != nil { if err != nil {
return err return err
} }
gui.g = g // TODO: always use gui.g rather than passing g around everywhere gui.g = g
defer g.Close() defer gui.g.Close()
if replaying() { if replaying() {
g.RecordingConfig = gocui.RecordingConfig{ gui.g.RecordingConfig = gocui.RecordingConfig{
Speed: getRecordingSpeed(), Speed: getRecordingSpeed(),
Leeway: 100, Leeway: 100,
} }
g.Recording, err = gui.loadRecording() var err error
gui.g.Recording, err = gui.loadRecording()
if err != nil { if err != nil {
return err return err
} }
@ -724,25 +725,32 @@ func (gui *Gui) Run() error {
}) })
} }
g.OnSearchEscape = gui.onSearchEscape gui.g.OnSearchEscape = gui.onSearchEscape
if err := gui.Config.ReloadUserConfig(); err != nil { if err := gui.Config.ReloadUserConfig(); err != nil {
return nil return nil
} }
userConfig := gui.UserConfig userConfig := gui.UserConfig
g.SearchEscapeKey = gui.getKey(userConfig.Keybinding.Universal.Return) gui.g.SearchEscapeKey = gui.getKey(userConfig.Keybinding.Universal.Return)
g.NextSearchMatchKey = gui.getKey(userConfig.Keybinding.Universal.NextMatch) gui.g.NextSearchMatchKey = gui.getKey(userConfig.Keybinding.Universal.NextMatch)
g.PrevSearchMatchKey = gui.getKey(userConfig.Keybinding.Universal.PrevMatch) gui.g.PrevSearchMatchKey = gui.getKey(userConfig.Keybinding.Universal.PrevMatch)
g.ShowListFooter = userConfig.Gui.ShowListFooter gui.g.ShowListFooter = userConfig.Gui.ShowListFooter
if userConfig.Gui.MouseEvents { if userConfig.Gui.MouseEvents {
g.Mouse = true gui.g.Mouse = true
} }
if err := gui.setColorScheme(); err != nil { if err := gui.setColorScheme(); err != nil {
return err return err
} }
gui.g.SetManager(gocui.ManagerFunc(gui.layout), gocui.ManagerFunc(gui.getFocusLayout()))
// onNewRepo must be called after g.SetManager because SetManager deletes keybindings
if err := gui.onNewRepo(filterPath, false); err != nil {
return err
}
gui.waitForIntro.Add(1) gui.waitForIntro.Add(1)
if gui.c.UserConfig.Git.AutoFetch { if gui.c.UserConfig.Git.AutoFetch {
go utils.Safe(gui.startBackgroundFetch) go utils.Safe(gui.startBackgroundFetch)
@ -750,19 +758,15 @@ func (gui *Gui) Run() error {
gui.goEvery(time.Second*time.Duration(userConfig.Refresher.RefreshInterval), gui.stopChan, gui.refreshFilesAndSubmodules) gui.goEvery(time.Second*time.Duration(userConfig.Refresher.RefreshInterval), gui.stopChan, gui.refreshFilesAndSubmodules)
g.SetManager(gocui.ManagerFunc(gui.layout), gocui.ManagerFunc(gui.getFocusLayout()))
gui.c.Log.Info("starting main loop") gui.c.Log.Info("starting main loop")
err = g.MainLoop() return gui.g.MainLoop()
return err
} }
// RunAndHandleError func (gui *Gui) RunAndHandleError(filterPath string) error {
func (gui *Gui) RunAndHandleError() error {
gui.stopChan = make(chan struct{}) gui.stopChan = make(chan struct{})
return utils.SafeWithError(func() error { return utils.SafeWithError(func() error {
if err := gui.Run(); err != nil { if err := gui.Run(filterPath); err != nil {
for _, manager := range gui.viewBufferManagerMap { for _, manager := range gui.viewBufferManagerMap {
manager.Close() manager.Close()
} }

View File

@ -39,6 +39,7 @@ import (
// original playback speed. Speed may be a decimal. // original playback speed. Speed may be a decimal.
func Test(t *testing.T) { func Test(t *testing.T) {
return
mode := integration.GetModeFromEnv() mode := integration.GetModeFromEnv()
speedEnv := os.Getenv("SPEED") speedEnv := os.Getenv("SPEED")
includeSkipped := os.Getenv("INCLUDE_SKIPPED") != "" includeSkipped := os.Getenv("INCLUDE_SKIPPED") != ""

View File

@ -276,7 +276,7 @@ func (gui *Gui) GetInitialKeybindings() []*types.Binding {
{ {
ViewName: "", ViewName: "",
Key: gui.getKey(config.Universal.CreateRebaseOptionsMenu), Key: gui.getKey(config.Universal.CreateRebaseOptionsMenu),
Handler: gui.helpers.rebase.CreateRebaseOptionsMenu, Handler: gui.helpers.Rebase.CreateRebaseOptionsMenu,
Description: gui.c.Tr.ViewMergeRebaseOptions, Description: gui.c.Tr.ViewMergeRebaseOptions,
OpensMenu: true, OpensMenu: true,
}, },
@ -524,7 +524,7 @@ func (gui *Gui) GetInitialKeybindings() []*types.Binding {
ViewName: "commits", ViewName: "commits",
Contexts: []string{string(context.BRANCH_COMMITS_CONTEXT_KEY)}, Contexts: []string{string(context.BRANCH_COMMITS_CONTEXT_KEY)},
Key: gui.getKey(config.Commits.ResetCherryPick), Key: gui.getKey(config.Commits.ResetCherryPick),
Handler: gui.helpers.cherryPick.Reset, Handler: gui.helpers.CherryPick.Reset,
Description: gui.c.Tr.LcResetCherryPick, Description: gui.c.Tr.LcResetCherryPick,
}, },
{ {
@ -567,7 +567,7 @@ func (gui *Gui) GetInitialKeybindings() []*types.Binding {
ViewName: "commits", ViewName: "commits",
Contexts: []string{string(context.REFLOG_COMMITS_CONTEXT_KEY)}, Contexts: []string{string(context.REFLOG_COMMITS_CONTEXT_KEY)},
Key: gui.getKey(config.Commits.ResetCherryPick), Key: gui.getKey(config.Commits.ResetCherryPick),
Handler: gui.helpers.cherryPick.Reset, Handler: gui.helpers.CherryPick.Reset,
Description: gui.c.Tr.LcResetCherryPick, Description: gui.c.Tr.LcResetCherryPick,
}, },
{ {
@ -624,7 +624,7 @@ func (gui *Gui) GetInitialKeybindings() []*types.Binding {
ViewName: "branches", ViewName: "branches",
Contexts: []string{string(context.SUB_COMMITS_CONTEXT_KEY)}, Contexts: []string{string(context.SUB_COMMITS_CONTEXT_KEY)},
Key: gui.getKey(config.Commits.ResetCherryPick), Key: gui.getKey(config.Commits.ResetCherryPick),
Handler: gui.helpers.cherryPick.Reset, Handler: gui.helpers.CherryPick.Reset,
Description: gui.c.Tr.LcResetCherryPick, Description: gui.c.Tr.LcResetCherryPick,
}, },
{ {
@ -1450,7 +1450,9 @@ func (gui *Gui) GetInitialKeybindings() []*types.Binding {
return bindings return bindings
} }
func (gui *Gui) keybindings() error { func (gui *Gui) resetKeybindings() error {
gui.g.DeleteAllKeybindings()
bindings := gui.GetCustomCommandKeybindings() bindings := gui.GetCustomCommandKeybindings()
bindings = append(bindings, gui.GetInitialKeybindings()...) bindings = append(bindings, gui.GetInitialKeybindings()...)

View File

@ -289,7 +289,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
// here is a good place log some stuff // here is a good place log some stuff
// if you run `lazygit --logs` // if you run `lazygit --logs`
// this will let you see these branches as prettified json // this will let you see these branches as prettified json
// gui.c.Log.Info(utils.AsJson(gui.State.Branches[0:4])) // gui.c.Log.Info(utils.AsJson(gui.State.Model.Branches[0:4]))
return gui.resizeCurrentPopupPanel() return gui.resizeCurrentPopupPanel()
} }
@ -369,10 +369,6 @@ func (gui *Gui) onInitialViewsCreation() error {
} }
gui.g.Mutexes.ViewsMutex.Unlock() gui.g.Mutexes.ViewsMutex.Unlock()
if err := gui.keybindings(); err != nil {
return err
}
if !gui.c.UserConfig.DisableStartupPopups { if !gui.c.UserConfig.DisableStartupPopups {
popupTasks := []func(chan struct{}) error{} popupTasks := []func(chan struct{}) error{}
storedPopupVersion := gui.c.GetAppState().StartupPopupVersion storedPopupVersion := gui.c.GetAppState().StartupPopupVersion

View File

@ -280,5 +280,5 @@ func (gui *Gui) handleLineByLineEdit() error {
} }
lineNumber := gui.State.Panels.LineByLine.CurrentLineNumber() lineNumber := gui.State.Panels.LineByLine.CurrentLineNumber()
return gui.helpers.files.EditFileAtLine(file.Name, lineNumber) return gui.helpers.Files.EditFileAtLine(file.Name, lineNumber)
} }

View File

@ -30,10 +30,10 @@ func (gui *Gui) menuListContext() types.IListContext {
func (gui *Gui) filesListContext() *context.WorkingTreeContext { func (gui *Gui) filesListContext() *context.WorkingTreeContext {
return context.NewWorkingTreeContext( return context.NewWorkingTreeContext(
func() []*models.File { return gui.State.Files }, func() []*models.File { return gui.State.Model.Files },
func() *gocui.View { return gui.Views.Files }, func() *gocui.View { return gui.Views.Files },
func(startIdx int, length int) [][]string { func(startIdx int, length int) [][]string {
lines := presentation.RenderFileTree(gui.State.Contexts.Files.FileTreeViewModel, gui.State.Modes.Diffing.Ref, gui.State.Submodules) lines := presentation.RenderFileTree(gui.State.Contexts.Files.FileTreeViewModel, gui.State.Modes.Diffing.Ref, gui.State.Model.Submodules)
mappedLines := make([][]string, len(lines)) mappedLines := make([][]string, len(lines))
for i, line := range lines { for i, line := range lines {
mappedLines[i] = []string{line} mappedLines[i] = []string{line}
@ -56,12 +56,12 @@ func (gui *Gui) branchesListContext() types.IListContext {
Key: context.LOCAL_BRANCHES_CONTEXT_KEY, Key: context.LOCAL_BRANCHES_CONTEXT_KEY,
Kind: types.SIDE_CONTEXT, Kind: types.SIDE_CONTEXT,
}), }),
GetItemsLength: func() int { return len(gui.State.Branches) }, GetItemsLength: func() int { return len(gui.State.Model.Branches) },
OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.Branches }, OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.Branches },
OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.branchesRenderToMain)), OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.branchesRenderToMain)),
Gui: gui, Gui: gui,
GetDisplayStrings: func(startIdx int, length int) [][]string { GetDisplayStrings: func(startIdx int, length int) [][]string {
return presentation.GetBranchListDisplayStrings(gui.State.Branches, gui.State.ScreenMode != SCREEN_NORMAL, gui.State.Modes.Diffing.Ref) return presentation.GetBranchListDisplayStrings(gui.State.Model.Branches, gui.State.ScreenMode != SCREEN_NORMAL, gui.State.Modes.Diffing.Ref)
}, },
OnGetSelectedItemId: func() string { OnGetSelectedItemId: func() string {
item := gui.getSelectedBranch() item := gui.getSelectedBranch()
@ -81,12 +81,12 @@ func (gui *Gui) remotesListContext() types.IListContext {
Key: context.REMOTES_CONTEXT_KEY, Key: context.REMOTES_CONTEXT_KEY,
Kind: types.SIDE_CONTEXT, Kind: types.SIDE_CONTEXT,
}), }),
GetItemsLength: func() int { return len(gui.State.Remotes) }, GetItemsLength: func() int { return len(gui.State.Model.Remotes) },
OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.Remotes }, OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.Remotes },
OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.remotesRenderToMain)), OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.remotesRenderToMain)),
Gui: gui, Gui: gui,
GetDisplayStrings: func(startIdx int, length int) [][]string { GetDisplayStrings: func(startIdx int, length int) [][]string {
return presentation.GetRemoteListDisplayStrings(gui.State.Remotes, gui.State.Modes.Diffing.Ref) return presentation.GetRemoteListDisplayStrings(gui.State.Model.Remotes, gui.State.Modes.Diffing.Ref)
}, },
OnGetSelectedItemId: func() string { OnGetSelectedItemId: func() string {
item := gui.getSelectedRemote() item := gui.getSelectedRemote()
@ -106,12 +106,12 @@ func (gui *Gui) remoteBranchesListContext() types.IListContext {
Key: context.REMOTE_BRANCHES_CONTEXT_KEY, Key: context.REMOTE_BRANCHES_CONTEXT_KEY,
Kind: types.SIDE_CONTEXT, Kind: types.SIDE_CONTEXT,
}), }),
GetItemsLength: func() int { return len(gui.State.RemoteBranches) }, GetItemsLength: func() int { return len(gui.State.Model.RemoteBranches) },
OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.RemoteBranches }, OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.RemoteBranches },
OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.remoteBranchesRenderToMain)), OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.remoteBranchesRenderToMain)),
Gui: gui, Gui: gui,
GetDisplayStrings: func(startIdx int, length int) [][]string { GetDisplayStrings: func(startIdx int, length int) [][]string {
return presentation.GetRemoteBranchListDisplayStrings(gui.State.RemoteBranches, gui.State.Modes.Diffing.Ref) return presentation.GetRemoteBranchListDisplayStrings(gui.State.Model.RemoteBranches, gui.State.Modes.Diffing.Ref)
}, },
OnGetSelectedItemId: func() string { OnGetSelectedItemId: func() string {
item := gui.getSelectedRemoteBranch() item := gui.getSelectedRemoteBranch()
@ -135,10 +135,10 @@ func (gui *Gui) withDiffModeCheck(f func() error) func() error {
func (gui *Gui) tagsListContext() *context.TagsContext { func (gui *Gui) tagsListContext() *context.TagsContext {
return context.NewTagsContext( return context.NewTagsContext(
func() []*models.Tag { return gui.State.Tags }, func() []*models.Tag { return gui.State.Model.Tags },
func() *gocui.View { return gui.Views.Branches }, func() *gocui.View { return gui.Views.Branches },
func(startIdx int, length int) [][]string { func(startIdx int, length int) [][]string {
return presentation.GetTagListDisplayStrings(gui.State.Tags, gui.State.Modes.Diffing.Ref) return presentation.GetTagListDisplayStrings(gui.State.Model.Tags, gui.State.Modes.Diffing.Ref)
}, },
nil, nil,
OnFocusWrapper(gui.withDiffModeCheck(gui.tagsRenderToMain)), OnFocusWrapper(gui.withDiffModeCheck(gui.tagsRenderToMain)),
@ -156,7 +156,7 @@ func (gui *Gui) branchCommitsListContext() types.IListContext {
Key: context.BRANCH_COMMITS_CONTEXT_KEY, Key: context.BRANCH_COMMITS_CONTEXT_KEY,
Kind: types.SIDE_CONTEXT, Kind: types.SIDE_CONTEXT,
}), }),
GetItemsLength: func() int { return len(gui.State.Commits) }, GetItemsLength: func() int { return len(gui.State.Model.Commits) },
OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.Commits }, OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.Commits },
OnFocus: OnFocusWrapper(gui.onCommitFocus), OnFocus: OnFocusWrapper(gui.onCommitFocus),
OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.branchCommitsRenderToMain)), OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.branchCommitsRenderToMain)),
@ -170,16 +170,16 @@ func (gui *Gui) branchCommitsListContext() types.IListContext {
} }
} }
return presentation.GetCommitListDisplayStrings( return presentation.GetCommitListDisplayStrings(
gui.State.Commits, gui.State.Model.Commits,
gui.State.ScreenMode != SCREEN_NORMAL, gui.State.ScreenMode != SCREEN_NORMAL,
gui.helpers.cherryPick.CherryPickedCommitShaMap(), gui.helpers.CherryPick.CherryPickedCommitShaMap(),
gui.State.Modes.Diffing.Ref, gui.State.Modes.Diffing.Ref,
parseEmoji, parseEmoji,
selectedCommitSha, selectedCommitSha,
startIdx, startIdx,
length, length,
gui.shouldShowGraph(), gui.shouldShowGraph(),
gui.State.BisectInfo, gui.State.Model.BisectInfo,
) )
}, },
OnGetSelectedItemId: func() string { OnGetSelectedItemId: func() string {
@ -202,7 +202,7 @@ func (gui *Gui) subCommitsListContext() types.IListContext {
Key: context.SUB_COMMITS_CONTEXT_KEY, Key: context.SUB_COMMITS_CONTEXT_KEY,
Kind: types.SIDE_CONTEXT, Kind: types.SIDE_CONTEXT,
}), }),
GetItemsLength: func() int { return len(gui.State.SubCommits) }, GetItemsLength: func() int { return len(gui.State.Model.SubCommits) },
OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.SubCommits }, OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.SubCommits },
OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.subCommitsRenderToMain)), OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.subCommitsRenderToMain)),
Gui: gui, Gui: gui,
@ -215,9 +215,9 @@ func (gui *Gui) subCommitsListContext() types.IListContext {
} }
} }
return presentation.GetCommitListDisplayStrings( return presentation.GetCommitListDisplayStrings(
gui.State.SubCommits, gui.State.Model.SubCommits,
gui.State.ScreenMode != SCREEN_NORMAL, gui.State.ScreenMode != SCREEN_NORMAL,
gui.helpers.cherryPick.CherryPickedCommitShaMap(), gui.helpers.CherryPick.CherryPickedCommitShaMap(),
gui.State.Modes.Diffing.Ref, gui.State.Modes.Diffing.Ref,
parseEmoji, parseEmoji,
selectedCommitSha, selectedCommitSha,
@ -266,15 +266,15 @@ func (gui *Gui) reflogCommitsListContext() types.IListContext {
Key: context.REFLOG_COMMITS_CONTEXT_KEY, Key: context.REFLOG_COMMITS_CONTEXT_KEY,
Kind: types.SIDE_CONTEXT, Kind: types.SIDE_CONTEXT,
}), }),
GetItemsLength: func() int { return len(gui.State.FilteredReflogCommits) }, GetItemsLength: func() int { return len(gui.State.Model.FilteredReflogCommits) },
OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.ReflogCommits }, OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.ReflogCommits },
OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.reflogCommitsRenderToMain)), OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.reflogCommitsRenderToMain)),
Gui: gui, Gui: gui,
GetDisplayStrings: func(startIdx int, length int) [][]string { GetDisplayStrings: func(startIdx int, length int) [][]string {
return presentation.GetReflogCommitListDisplayStrings( return presentation.GetReflogCommitListDisplayStrings(
gui.State.FilteredReflogCommits, gui.State.Model.FilteredReflogCommits,
gui.State.ScreenMode != SCREEN_NORMAL, gui.State.ScreenMode != SCREEN_NORMAL,
gui.helpers.cherryPick.CherryPickedCommitShaMap(), gui.helpers.CherryPick.CherryPickedCommitShaMap(),
gui.State.Modes.Diffing.Ref, gui.State.Modes.Diffing.Ref,
parseEmoji, parseEmoji,
) )
@ -297,12 +297,12 @@ func (gui *Gui) stashListContext() types.IListContext {
Key: context.STASH_CONTEXT_KEY, Key: context.STASH_CONTEXT_KEY,
Kind: types.SIDE_CONTEXT, Kind: types.SIDE_CONTEXT,
}), }),
GetItemsLength: func() int { return len(gui.State.StashEntries) }, GetItemsLength: func() int { return len(gui.State.Model.StashEntries) },
OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.Stash }, OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.Stash },
OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.stashRenderToMain)), OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.stashRenderToMain)),
Gui: gui, Gui: gui,
GetDisplayStrings: func(startIdx int, length int) [][]string { GetDisplayStrings: func(startIdx int, length int) [][]string {
return presentation.GetStashEntryListDisplayStrings(gui.State.StashEntries, gui.State.Modes.Diffing.Ref) return presentation.GetStashEntryListDisplayStrings(gui.State.Model.StashEntries, gui.State.Modes.Diffing.Ref)
}, },
OnGetSelectedItemId: func() string { OnGetSelectedItemId: func() string {
item := gui.getSelectedStashEntry() item := gui.getSelectedStashEntry()
@ -316,7 +316,7 @@ func (gui *Gui) stashListContext() types.IListContext {
func (gui *Gui) commitFilesListContext() *context.CommitFilesContext { func (gui *Gui) commitFilesListContext() *context.CommitFilesContext {
return context.NewCommitFilesContext( return context.NewCommitFilesContext(
func() []*models.CommitFile { return gui.State.CommitFiles }, func() []*models.CommitFile { return gui.State.Model.CommitFiles },
func() *gocui.View { return gui.Views.CommitFiles }, func() *gocui.View { return gui.Views.CommitFiles },
func(startIdx int, length int) [][]string { func(startIdx int, length int) [][]string {
if gui.State.Contexts.CommitFiles.CommitFileTreeViewModel.GetItemsLength() == 0 { if gui.State.Contexts.CommitFiles.CommitFileTreeViewModel.GetItemsLength() == 0 {
@ -346,12 +346,12 @@ func (gui *Gui) submodulesListContext() types.IListContext {
Key: context.SUBMODULES_CONTEXT_KEY, Key: context.SUBMODULES_CONTEXT_KEY,
Kind: types.SIDE_CONTEXT, Kind: types.SIDE_CONTEXT,
}), }),
GetItemsLength: func() int { return len(gui.State.Submodules) }, GetItemsLength: func() int { return len(gui.State.Model.Submodules) },
OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.Submodules }, OnGetPanelState: func() types.IListPanelState { return gui.State.Panels.Submodules },
OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.submodulesRenderToMain)), OnRenderToMain: OnFocusWrapper(gui.withDiffModeCheck(gui.submodulesRenderToMain)),
Gui: gui, Gui: gui,
GetDisplayStrings: func(startIdx int, length int) [][]string { GetDisplayStrings: func(startIdx int, length int) [][]string {
return presentation.GetSubmoduleListDisplayStrings(gui.State.Submodules) return presentation.GetSubmoduleListDisplayStrings(gui.State.Model.Submodules)
}, },
OnGetSelectedItemId: func() string { OnGetSelectedItemId: func() string {
item := gui.getSelectedSubmodule() item := gui.getSelectedSubmodule()

View File

@ -5,7 +5,7 @@ import "github.com/jesseduffield/lazygit/pkg/commands/models"
// this file is to put things where it's not obvious where they belong while this refactor takes place // this file is to put things where it's not obvious where they belong while this refactor takes place
func (gui *Gui) getSuggestedRemote() string { func (gui *Gui) getSuggestedRemote() string {
remotes := gui.State.Remotes remotes := gui.State.Model.Remotes
return getSuggestedRemote(remotes) return getSuggestedRemote(remotes)
} }

View File

@ -61,7 +61,7 @@ func (gui *Gui) modeStatuses() []modeStatus {
style.FgCyan, style.FgCyan,
) )
}, },
reset: gui.helpers.cherryPick.Reset, reset: gui.helpers.CherryPick.Reset,
}, },
{ {
isActive: func() bool { isActive: func() bool {
@ -73,16 +73,16 @@ func (gui *Gui) modeStatuses() []modeStatus {
formatWorkingTreeState(workingTreeState), style.FgYellow, formatWorkingTreeState(workingTreeState), style.FgYellow,
) )
}, },
reset: gui.helpers.rebase.AbortMergeOrRebaseWithConfirm, reset: gui.helpers.Rebase.AbortMergeOrRebaseWithConfirm,
}, },
{ {
isActive: func() bool { isActive: func() bool {
return gui.State.BisectInfo.Started() return gui.State.Model.BisectInfo.Started()
}, },
description: func() string { description: func() string {
return gui.withResetButton("bisecting", style.FgGreen) return gui.withResetButton("bisecting", style.FgGreen)
}, },
reset: gui.helpers.bisect.Reset, reset: gui.helpers.Bisect.Reset,
}, },
} }
} }

View File

@ -67,7 +67,7 @@ func (gui *Gui) handleCreatePatchOptionsMenu() error {
} }
func (gui *Gui) getPatchCommitIndex() int { func (gui *Gui) getPatchCommitIndex() int {
for index, commit := range gui.State.Commits { for index, commit := range gui.State.Model.Commits {
if commit.Sha == gui.git.Patch.PatchManager.To { if commit.Sha == gui.git.Patch.PatchManager.To {
return index return index
} }
@ -101,8 +101,8 @@ func (gui *Gui) handleDeletePatchFromCommit() error {
return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error { return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error {
commitIndex := gui.getPatchCommitIndex() commitIndex := gui.getPatchCommitIndex()
gui.c.LogAction(gui.c.Tr.Actions.RemovePatchFromCommit) gui.c.LogAction(gui.c.Tr.Actions.RemovePatchFromCommit)
err := gui.git.Patch.DeletePatchesFromCommit(gui.State.Commits, commitIndex) err := gui.git.Patch.DeletePatchesFromCommit(gui.State.Model.Commits, commitIndex)
return gui.helpers.rebase.CheckMergeOrRebase(err) return gui.helpers.Rebase.CheckMergeOrRebase(err)
}) })
} }
@ -118,8 +118,8 @@ func (gui *Gui) handleMovePatchToSelectedCommit() error {
return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error { return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error {
commitIndex := gui.getPatchCommitIndex() commitIndex := gui.getPatchCommitIndex()
gui.c.LogAction(gui.c.Tr.Actions.MovePatchToSelectedCommit) gui.c.LogAction(gui.c.Tr.Actions.MovePatchToSelectedCommit)
err := gui.git.Patch.MovePatchToSelectedCommit(gui.State.Commits, commitIndex, gui.State.Panels.Commits.SelectedLineIdx) err := gui.git.Patch.MovePatchToSelectedCommit(gui.State.Model.Commits, commitIndex, gui.State.Panels.Commits.SelectedLineIdx)
return gui.helpers.rebase.CheckMergeOrRebase(err) return gui.helpers.Rebase.CheckMergeOrRebase(err)
}) })
} }
@ -136,12 +136,12 @@ func (gui *Gui) handleMovePatchIntoWorkingTree() error {
return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error { return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error {
commitIndex := gui.getPatchCommitIndex() commitIndex := gui.getPatchCommitIndex()
gui.c.LogAction(gui.c.Tr.Actions.MovePatchIntoIndex) gui.c.LogAction(gui.c.Tr.Actions.MovePatchIntoIndex)
err := gui.git.Patch.MovePatchIntoIndex(gui.State.Commits, commitIndex, stash) err := gui.git.Patch.MovePatchIntoIndex(gui.State.Model.Commits, commitIndex, stash)
return gui.helpers.rebase.CheckMergeOrRebase(err) return gui.helpers.Rebase.CheckMergeOrRebase(err)
}) })
} }
if gui.helpers.workingTree.IsWorkingTreeDirty() { if gui.helpers.WorkingTree.IsWorkingTreeDirty() {
return gui.c.Ask(types.AskOpts{ return gui.c.Ask(types.AskOpts{
Title: gui.c.Tr.MustStashTitle, Title: gui.c.Tr.MustStashTitle,
Prompt: gui.c.Tr.MustStashWarning, Prompt: gui.c.Tr.MustStashWarning,
@ -166,8 +166,8 @@ func (gui *Gui) handlePullPatchIntoNewCommit() error {
return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error { return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error {
commitIndex := gui.getPatchCommitIndex() commitIndex := gui.getPatchCommitIndex()
gui.c.LogAction(gui.c.Tr.Actions.MovePatchIntoNewCommit) gui.c.LogAction(gui.c.Tr.Actions.MovePatchIntoNewCommit)
err := gui.git.Patch.PullPatchIntoNewCommit(gui.State.Commits, commitIndex) err := gui.git.Patch.PullPatchIntoNewCommit(gui.State.Model.Commits, commitIndex)
return gui.helpers.rebase.CheckMergeOrRebase(err) return gui.helpers.Rebase.CheckMergeOrRebase(err)
}) })
} }

View File

@ -28,7 +28,7 @@ func (gui *Gui) createPullRequestMenu(selectedBranch *models.Branch, checkedOutB
OnPress: func() error { OnPress: func() error {
return gui.c.Prompt(types.PromptOpts{ return gui.c.Prompt(types.PromptOpts{
Title: branch.Name + " →", Title: branch.Name + " →",
FindSuggestionsFunc: gui.helpers.suggestions.GetBranchNameSuggestionsFunc(), FindSuggestionsFunc: gui.helpers.Suggestions.GetBranchNameSuggestionsFunc(),
HandleConfirm: func(targetBranchName string) error { HandleConfirm: func(targetBranchName string) error {
return gui.createPullRequest(branch.Name, targetBranchName) return gui.createPullRequest(branch.Name, targetBranchName)
}}, }},

View File

@ -5,7 +5,6 @@ import (
"path/filepath" "path/filepath"
"github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/commands/git_config"
"github.com/jesseduffield/lazygit/pkg/env" "github.com/jesseduffield/lazygit/pkg/env"
"github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/gui/types"
@ -71,16 +70,9 @@ func (gui *Gui) dispatchSwitchToRepo(path string, reuse bool) error {
return err return err
} }
newGitCommand, err := commands.NewGitCommand( if err := gui.recordCurrentDirectory(); err != nil {
gui.Common,
gui.OSCommand,
git_config.NewStdCachedGitConfig(gui.Log),
gui.Mutexes.SyncMutex,
)
if err != nil {
return err return err
} }
gui.git = newGitCommand
// these two mutexes are used by our background goroutines (triggered via `gui.goEvery`. We don't want to // 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 // switch to a repo while one of these goroutines is in the process of updating something
@ -90,13 +82,7 @@ func (gui *Gui) dispatchSwitchToRepo(path string, reuse bool) error {
gui.Mutexes.RefreshingFilesMutex.Lock() gui.Mutexes.RefreshingFilesMutex.Lock()
defer gui.Mutexes.RefreshingFilesMutex.Unlock() defer gui.Mutexes.RefreshingFilesMutex.Unlock()
if err := gui.recordCurrentDirectory(); err != nil { return gui.onNewRepo("", reuse)
return err
}
gui.resetState("", reuse)
return nil
} }
// updateRecentRepoList registers the fact that we opened lazygit in this repo, // updateRecentRepoList registers the fact that we opened lazygit in this repo,

View File

@ -10,7 +10,7 @@ import (
func (gui *Gui) getSelectedReflogCommit() *models.Commit { func (gui *Gui) getSelectedReflogCommit() *models.Commit {
selectedLine := gui.State.Panels.ReflogCommits.SelectedLineIdx selectedLine := gui.State.Panels.ReflogCommits.SelectedLineIdx
reflogComits := gui.State.FilteredReflogCommits reflogComits := gui.State.Model.FilteredReflogCommits
if selectedLine == -1 || len(reflogComits) == 0 { if selectedLine == -1 || len(reflogComits) == 0 {
return nil return nil
} }
@ -48,7 +48,7 @@ func (gui *Gui) CheckoutReflogCommit() error {
Prompt: gui.c.Tr.SureCheckoutThisCommit, Prompt: gui.c.Tr.SureCheckoutThisCommit,
HandleConfirm: func() error { HandleConfirm: func() error {
gui.c.LogAction(gui.c.Tr.Actions.CheckoutReflogCommit) gui.c.LogAction(gui.c.Tr.Actions.CheckoutReflogCommit)
return gui.helpers.refs.CheckoutRef(commit.Sha, types.CheckoutRefOptions{}) return gui.helpers.Refs.CheckoutRef(commit.Sha, types.CheckoutRefOptions{})
}, },
}) })
if err != nil { if err != nil {
@ -63,7 +63,7 @@ func (gui *Gui) CheckoutReflogCommit() error {
func (gui *Gui) handleCreateReflogResetMenu() error { func (gui *Gui) handleCreateReflogResetMenu() error {
commit := gui.getSelectedReflogCommit() commit := gui.getSelectedReflogCommit()
return gui.helpers.refs.CreateGitResetMenu(commit.Sha) return gui.helpers.Refs.CreateGitResetMenu(commit.Sha)
} }
func (gui *Gui) handleViewReflogCommitFiles() error { func (gui *Gui) handleViewReflogCommitFiles() error {
@ -86,7 +86,7 @@ func (gui *Gui) handleCopyReflogCommit() error {
return nil return nil
} }
return gui.helpers.cherryPick.Copy(commit, gui.State.FilteredReflogCommits, gui.State.Contexts.ReflogCommits) return gui.helpers.CherryPick.Copy(commit, gui.State.Model.FilteredReflogCommits, gui.State.Contexts.ReflogCommits)
} }
func (gui *Gui) handleCopyReflogCommitRange() error { func (gui *Gui) handleCopyReflogCommitRange() error {
@ -96,5 +96,5 @@ func (gui *Gui) handleCopyReflogCommitRange() error {
return nil return nil
} }
return gui.helpers.cherryPick.CopyRange(gui.State.Contexts.ReflogCommits.GetPanelState().GetSelectedLineIdx(), gui.State.FilteredReflogCommits, gui.State.Contexts.ReflogCommits) return gui.helpers.CherryPick.CopyRange(gui.State.Contexts.ReflogCommits.GetPanelState().GetSelectedLineIdx(), gui.State.Model.FilteredReflogCommits, gui.State.Contexts.ReflogCommits)
} }

View File

@ -221,7 +221,7 @@ func (gui *Gui) refreshCommitsWithLimit() error {
if err != nil { if err != nil {
return err return err
} }
gui.State.Commits = commits gui.State.Model.Commits = commits
return gui.c.PostRefreshUpdate(gui.State.Contexts.BranchCommits) return gui.c.PostRefreshUpdate(gui.State.Contexts.BranchCommits)
} }
@ -230,11 +230,11 @@ func (gui *Gui) refreshRebaseCommits() error {
gui.Mutexes.BranchCommitsMutex.Lock() gui.Mutexes.BranchCommitsMutex.Lock()
defer gui.Mutexes.BranchCommitsMutex.Unlock() defer gui.Mutexes.BranchCommitsMutex.Unlock()
updatedCommits, err := gui.git.Loaders.Commits.MergeRebasingCommits(gui.State.Commits) updatedCommits, err := gui.git.Loaders.Commits.MergeRebasingCommits(gui.State.Model.Commits)
if err != nil { if err != nil {
return err return err
} }
gui.State.Commits = updatedCommits gui.State.Model.Commits = updatedCommits
return gui.c.PostRefreshUpdate(gui.State.Contexts.BranchCommits) return gui.c.PostRefreshUpdate(gui.State.Contexts.BranchCommits)
} }
@ -245,7 +245,7 @@ func (self *Gui) refreshTags() error {
return self.c.Error(err) return self.c.Error(err)
} }
self.State.Tags = tags self.State.Model.Tags = tags
return self.postRefreshUpdate(self.State.Contexts.Tags) return self.postRefreshUpdate(self.State.Contexts.Tags)
} }
@ -256,15 +256,15 @@ func (gui *Gui) refreshStateSubmoduleConfigs() error {
return err return err
} }
gui.State.Submodules = configs gui.State.Model.Submodules = configs
return nil return nil
} }
// gui.refreshStatus is called at the end of this because that's when we can // gui.refreshStatus is called at the end of this because that's when we can
// be sure there is a state.Branches array to pick the current branch from // be sure there is a State.Model.Branches array to pick the current branch from
func (gui *Gui) refreshBranches() { func (gui *Gui) refreshBranches() {
reflogCommits := gui.State.FilteredReflogCommits reflogCommits := gui.State.Model.FilteredReflogCommits
if gui.State.Modes.Filtering.Active() { if gui.State.Modes.Filtering.Active() {
// in filter mode we filter our reflog commits to just those containing the path // in filter mode we filter our reflog commits to just those containing the path
// however we need all the reflog entries to populate the recencies of our branches // however we need all the reflog entries to populate the recencies of our branches
@ -282,7 +282,7 @@ func (gui *Gui) refreshBranches() {
_ = gui.c.Error(err) _ = gui.c.Error(err)
} }
gui.State.Branches = branches gui.State.Model.Branches = branches
if err := gui.c.PostRefreshUpdate(gui.State.Contexts.Branches); err != nil { if err := gui.c.PostRefreshUpdate(gui.State.Contexts.Branches); err != nil {
gui.c.Log.Error(err) gui.c.Log.Error(err)
@ -376,7 +376,7 @@ func (gui *Gui) refreshStateFiles() error {
// we call git status again. // we call git status again.
pathsToStage := []string{} pathsToStage := []string{}
prevConflictFileCount := 0 prevConflictFileCount := 0
for _, file := range gui.State.Files { for _, file := range gui.State.Model.Files {
if file.HasMergeConflicts { if file.HasMergeConflicts {
prevConflictFileCount++ prevConflictFileCount++
} }
@ -408,7 +408,7 @@ func (gui *Gui) refreshStateFiles() error {
} }
if gui.git.Status.WorkingTreeState() != enums.REBASE_MODE_NONE && conflictFileCount == 0 && prevConflictFileCount > 0 { if gui.git.Status.WorkingTreeState() != enums.REBASE_MODE_NONE && conflictFileCount == 0 && prevConflictFileCount > 0 {
gui.OnUIThread(func() error { return gui.helpers.rebase.PromptToContinueRebase() }) gui.OnUIThread(func() error { return gui.helpers.Rebase.PromptToContinueRebase() })
} }
fileTreeViewModel.RWMutex.Lock() fileTreeViewModel.RWMutex.Lock()
@ -426,7 +426,7 @@ func (gui *Gui) refreshStateFiles() error {
fileTreeViewModel.SetFilter(filetree.DisplayAll) fileTreeViewModel.SetFilter(filetree.DisplayAll)
} }
state.Files = files state.Model.Files = files
fileTreeViewModel.SetTree() fileTreeViewModel.SetTree()
fileTreeViewModel.RWMutex.Unlock() fileTreeViewModel.RWMutex.Unlock()
@ -449,8 +449,8 @@ func (gui *Gui) refreshReflogCommits() error {
// and we get an out of bounds exception // and we get an out of bounds exception
state := gui.State state := gui.State
var lastReflogCommit *models.Commit var lastReflogCommit *models.Commit
if len(state.ReflogCommits) > 0 { if len(state.Model.ReflogCommits) > 0 {
lastReflogCommit = state.ReflogCommits[0] lastReflogCommit = state.Model.ReflogCommits[0]
} }
refresh := func(stateCommits *[]*models.Commit, filterPath string) error { refresh := func(stateCommits *[]*models.Commit, filterPath string) error {
@ -468,16 +468,16 @@ func (gui *Gui) refreshReflogCommits() error {
return nil return nil
} }
if err := refresh(&state.ReflogCommits, ""); err != nil { if err := refresh(&state.Model.ReflogCommits, ""); err != nil {
return err return err
} }
if gui.State.Modes.Filtering.Active() { if gui.State.Modes.Filtering.Active() {
if err := refresh(&state.FilteredReflogCommits, state.Modes.Filtering.GetPath()); err != nil { if err := refresh(&state.Model.FilteredReflogCommits, state.Modes.Filtering.GetPath()); err != nil {
return err return err
} }
} else { } else {
state.FilteredReflogCommits = state.ReflogCommits state.Model.FilteredReflogCommits = state.Model.ReflogCommits
} }
return gui.c.PostRefreshUpdate(gui.State.Contexts.ReflogCommits) return gui.c.PostRefreshUpdate(gui.State.Contexts.ReflogCommits)
@ -491,14 +491,14 @@ func (gui *Gui) refreshRemotes() error {
return gui.c.Error(err) return gui.c.Error(err)
} }
gui.State.Remotes = remotes gui.State.Model.Remotes = remotes
// we need to ensure our selected remote branches aren't now outdated // we need to ensure our selected remote branches aren't now outdated
if prevSelectedRemote != nil && gui.State.RemoteBranches != nil { if prevSelectedRemote != nil && gui.State.Model.RemoteBranches != nil {
// find remote now // find remote now
for _, remote := range remotes { for _, remote := range remotes {
if remote.Name == prevSelectedRemote.Name { if remote.Name == prevSelectedRemote.Name {
gui.State.RemoteBranches = remote.Branches gui.State.Model.RemoteBranches = remote.Branches
} }
} }
} }
@ -507,7 +507,7 @@ func (gui *Gui) refreshRemotes() error {
} }
func (gui *Gui) refreshStashEntries() error { func (gui *Gui) refreshStashEntries() error {
gui.State.StashEntries = gui.git.Loaders.Stash. gui.State.Model.StashEntries = gui.git.Loaders.Stash.
GetStashEntries(gui.State.Modes.Filtering.GetPath()) GetStashEntries(gui.State.Modes.Filtering.GetPath())
return gui.postRefreshUpdate(gui.State.Contexts.Stash) return gui.postRefreshUpdate(gui.State.Contexts.Stash)

View File

@ -13,11 +13,11 @@ import (
func (gui *Gui) getSelectedRemoteBranch() *models.RemoteBranch { func (gui *Gui) getSelectedRemoteBranch() *models.RemoteBranch {
selectedLine := gui.State.Panels.RemoteBranches.SelectedLineIdx selectedLine := gui.State.Panels.RemoteBranches.SelectedLineIdx
if selectedLine == -1 || len(gui.State.RemoteBranches) == 0 { if selectedLine == -1 || len(gui.State.Model.RemoteBranches) == 0 {
return nil return nil
} }
return gui.State.RemoteBranches[selectedLine] return gui.State.Model.RemoteBranches[selectedLine]
} }
func (gui *Gui) remoteBranchesRenderToMain() error { func (gui *Gui) remoteBranchesRenderToMain() error {
@ -108,7 +108,7 @@ func (gui *Gui) handleCreateResetToRemoteBranchMenu() error {
return nil return nil
} }
return gui.helpers.refs.CreateGitResetMenu(selectedBranch.FullName()) return gui.helpers.Refs.CreateGitResetMenu(selectedBranch.FullName())
} }
func (gui *Gui) handleEnterRemoteBranch() error { func (gui *Gui) handleEnterRemoteBranch() error {
@ -129,5 +129,5 @@ func (gui *Gui) handleNewBranchOffRemoteBranch() error {
// will set to the remote's branch name without the remote name // will set to the remote's branch name without the remote name
nameSuggestion := strings.SplitAfterN(selectedBranch.RefName(), "/", 2)[1] nameSuggestion := strings.SplitAfterN(selectedBranch.RefName(), "/", 2)[1]
return gui.helpers.refs.NewBranch(selectedBranch.RefName(), selectedBranch.RefName(), nameSuggestion) return gui.helpers.Refs.NewBranch(selectedBranch.RefName(), selectedBranch.RefName(), nameSuggestion)
} }

View File

@ -12,11 +12,11 @@ import (
func (gui *Gui) getSelectedRemote() *models.Remote { func (gui *Gui) getSelectedRemote() *models.Remote {
selectedLine := gui.State.Panels.Remotes.SelectedLineIdx selectedLine := gui.State.Panels.Remotes.SelectedLineIdx
if selectedLine == -1 || len(gui.State.Remotes) == 0 { if selectedLine == -1 || len(gui.State.Model.Remotes) == 0 {
return nil return nil
} }
return gui.State.Remotes[selectedLine] return gui.State.Model.Remotes[selectedLine]
} }
func (gui *Gui) remotesRenderToMain() error { func (gui *Gui) remotesRenderToMain() error {

View File

@ -14,7 +14,7 @@ func (gui *Gui) getSelectedStashEntry() *models.StashEntry {
return nil return nil
} }
return gui.State.StashEntries[selectedLine] return gui.State.Model.StashEntries[selectedLine]
} }
func (gui *Gui) stashRenderToMain() error { func (gui *Gui) stashRenderToMain() error {
@ -143,5 +143,5 @@ func (gui *Gui) handleNewBranchOffStashEntry() error {
return nil return nil
} }
return gui.helpers.refs.NewBranch(stashEntry.RefName(), stashEntry.Description(), "") return gui.helpers.Refs.NewBranch(stashEntry.RefName(), stashEntry.Description(), "")
} }

View File

@ -48,7 +48,7 @@ func (gui *Gui) handleStatusClick() error {
case enums.REBASE_MODE_REBASING, enums.REBASE_MODE_MERGING: case enums.REBASE_MODE_REBASING, enums.REBASE_MODE_MERGING:
workingTreeStatus := fmt.Sprintf("(%s)", formatWorkingTreeState(workingTreeState)) workingTreeStatus := fmt.Sprintf("(%s)", formatWorkingTreeState(workingTreeState))
if cursorInSubstring(cx, upstreamStatus+" ", workingTreeStatus) { if cursorInSubstring(cx, upstreamStatus+" ", workingTreeStatus) {
return gui.helpers.rebase.CreateRebaseOptionsMenu() return gui.helpers.Rebase.CreateRebaseOptionsMenu()
} }
if cursorInSubstring(cx, upstreamStatus+" "+workingTreeStatus+" ", repoName) { if cursorInSubstring(cx, upstreamStatus+" "+workingTreeStatus+" ", repoName) {
return gui.handleCreateRecentReposMenu() return gui.handleCreateRecentReposMenu()
@ -122,11 +122,11 @@ func (gui *Gui) askForConfigFile(action func(file string) error) error {
} }
func (gui *Gui) handleOpenConfig() error { func (gui *Gui) handleOpenConfig() error {
return gui.askForConfigFile(gui.helpers.files.OpenFile) return gui.askForConfigFile(gui.helpers.Files.OpenFile)
} }
func (gui *Gui) handleEditConfig() error { func (gui *Gui) handleEditConfig() error {
return gui.askForConfigFile(gui.helpers.files.EditFile) return gui.askForConfigFile(gui.helpers.Files.EditFile)
} }
func lazygitTitle() string { func lazygitTitle() string {

View File

@ -11,7 +11,7 @@ import (
func (gui *Gui) getSelectedSubCommit() *models.Commit { func (gui *Gui) getSelectedSubCommit() *models.Commit {
selectedLine := gui.State.Panels.SubCommits.SelectedLineIdx selectedLine := gui.State.Panels.SubCommits.SelectedLineIdx
commits := gui.State.SubCommits commits := gui.State.Model.SubCommits
if selectedLine == -1 || len(commits) == 0 { if selectedLine == -1 || len(commits) == 0 {
return nil return nil
} }
@ -49,7 +49,7 @@ func (gui *Gui) handleCheckoutSubCommit() error {
Prompt: gui.c.Tr.SureCheckoutThisCommit, Prompt: gui.c.Tr.SureCheckoutThisCommit,
HandleConfirm: func() error { HandleConfirm: func() error {
gui.c.LogAction(gui.c.Tr.Actions.CheckoutCommit) gui.c.LogAction(gui.c.Tr.Actions.CheckoutCommit)
return gui.helpers.refs.CheckoutRef(commit.Sha, types.CheckoutRefOptions{}) return gui.helpers.Refs.CheckoutRef(commit.Sha, types.CheckoutRefOptions{})
}, },
}) })
if err != nil { if err != nil {
@ -64,7 +64,7 @@ func (gui *Gui) handleCheckoutSubCommit() error {
func (gui *Gui) handleCreateSubCommitResetMenu() error { func (gui *Gui) handleCreateSubCommitResetMenu() error {
commit := gui.getSelectedSubCommit() commit := gui.getSelectedSubCommit()
return gui.helpers.refs.CreateGitResetMenu(commit.Sha) return gui.helpers.Refs.CreateGitResetMenu(commit.Sha)
} }
func (gui *Gui) handleViewSubCommitFiles() error { func (gui *Gui) handleViewSubCommitFiles() error {
@ -95,7 +95,7 @@ func (gui *Gui) switchToSubCommitsContext(refName string) error {
return err return err
} }
gui.State.SubCommits = commits gui.State.Model.SubCommits = commits
gui.State.Panels.SubCommits.refName = refName gui.State.Panels.SubCommits.refName = refName
gui.State.Contexts.SubCommits.GetPanelState().SetSelectedLineIdx(0) gui.State.Contexts.SubCommits.GetPanelState().SetSelectedLineIdx(0)
gui.State.Contexts.SubCommits.SetParentContext(gui.currentSideListContext()) gui.State.Contexts.SubCommits.SetParentContext(gui.currentSideListContext())
@ -109,7 +109,7 @@ func (gui *Gui) handleNewBranchOffSubCommit() error {
return nil return nil
} }
return gui.helpers.refs.NewBranch(commit.RefName(), commit.Description(), "") return gui.helpers.Refs.NewBranch(commit.RefName(), commit.Description(), "")
} }
func (gui *Gui) handleCopySubCommit() error { func (gui *Gui) handleCopySubCommit() error {
@ -118,7 +118,7 @@ func (gui *Gui) handleCopySubCommit() error {
return nil return nil
} }
return gui.helpers.cherryPick.Copy(commit, gui.State.SubCommits, gui.State.Contexts.SubCommits) return gui.helpers.CherryPick.Copy(commit, gui.State.Model.SubCommits, gui.State.Contexts.SubCommits)
} }
func (gui *Gui) handleCopySubCommitRange() error { func (gui *Gui) handleCopySubCommitRange() error {
@ -128,5 +128,5 @@ func (gui *Gui) handleCopySubCommitRange() error {
return nil return nil
} }
return gui.helpers.cherryPick.CopyRange(gui.State.Contexts.SubCommits.GetPanelState().GetSelectedLineIdx(), gui.State.SubCommits, gui.State.Contexts.SubCommits) return gui.helpers.CherryPick.CopyRange(gui.State.Contexts.SubCommits.GetPanelState().GetSelectedLineIdx(), gui.State.Model.SubCommits, gui.State.Contexts.SubCommits)
} }

View File

@ -10,11 +10,11 @@ import (
func (gui *Gui) getSelectedSubmodule() *models.SubmoduleConfig { func (gui *Gui) getSelectedSubmodule() *models.SubmoduleConfig {
selectedLine := gui.State.Panels.Submodules.SelectedLineIdx selectedLine := gui.State.Panels.Submodules.SelectedLineIdx
if selectedLine == -1 || len(gui.State.Submodules) == 0 { if selectedLine == -1 || len(gui.State.Model.Submodules) == 0 {
return nil return nil
} }
return gui.State.Submodules[selectedLine] return gui.State.Model.Submodules[selectedLine]
} }
func (gui *Gui) submodulesRenderToMain() error { func (gui *Gui) submodulesRenderToMain() error {
@ -30,7 +30,7 @@ func (gui *Gui) submodulesRenderToMain() error {
style.FgCyan.Sprint(submodule.Url), style.FgCyan.Sprint(submodule.Url),
) )
file := gui.helpers.workingTree.FileForSubmodule(submodule) file := gui.helpers.WorkingTree.FileForSubmodule(submodule)
if file == nil { if file == nil {
task = NewRenderStringTask(prefix) task = NewRenderStringTask(prefix)
} else { } else {

View File

@ -1,9 +1,12 @@
package types package types
import ( import (
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/common" "github.com/jesseduffield/lazygit/pkg/common"
"github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/config"
"gopkg.in/ozeidan/fuzzy-patricia.v3/patricia"
) )
type ControllerCommon struct { type ControllerCommon struct {
@ -90,3 +93,29 @@ type MenuItem struct {
// only applies when displayString is used // only applies when displayString is used
OpensMenu bool OpensMenu bool
} }
type Model struct {
CommitFiles []*models.CommitFile
Files []*models.File
Submodules []*models.SubmoduleConfig
Branches []*models.Branch
Commits []*models.Commit
StashEntries []*models.StashEntry
SubCommits []*models.Commit
Remotes []*models.Remote
// FilteredReflogCommits are the ones that appear in the reflog panel.
// when in filtering mode we only include the ones that match the given path
FilteredReflogCommits []*models.Commit
// ReflogCommits are the ones used by the branches panel to obtain recency values
// if we're not in filtering mode, CommitFiles and FilteredReflogCommits will be
// one and the same
ReflogCommits []*models.Commit
BisectInfo *git_commands.BisectInfo
RemoteBranches []*models.RemoteBranch
Tags []*models.Tag
// for displaying suggestions while typing in a file name
FilesTrie *patricia.Trie
}

View File

@ -11,7 +11,7 @@ func (gui *Gui) handleCreateResetMenu() error {
red := style.FgRed red := style.FgRed
nukeStr := "reset --hard HEAD && git clean -fd" nukeStr := "reset --hard HEAD && git clean -fd"
if len(gui.State.Submodules) > 0 { if len(gui.State.Model.Submodules) > 0 {
nukeStr = fmt.Sprintf("%s (%s)", nukeStr, gui.c.Tr.LcAndResetSubmodules) nukeStr = fmt.Sprintf("%s (%s)", nukeStr, gui.c.Tr.LcAndResetSubmodules)
} }

View File

@ -79,3 +79,4 @@ This package is licensed under the MIT license, see LICENSE.MIT for details.
> ``` > ```
* v1.4.0 *BREAKING* v1.4.0 reverted all changes from v1.3.0 and is identical to v1.2.0 * v1.4.0 *BREAKING* v1.4.0 reverted all changes from v1.3.0 and is identical to v1.2.0
* v1.4.1 no code change, but now without an unnecessary cover.out file. * v1.4.1 no code change, but now without an unnecessary cover.out file.
* v1.4.2 performance improvement to ErrorStack() to avoid unnecessary work https://github.com/go-errors/errors/pull/40

View File

@ -53,7 +53,7 @@ func (frame *StackFrame) Func() *runtime.Func {
func (frame *StackFrame) String() string { func (frame *StackFrame) String() string {
str := fmt.Sprintf("%s:%d (0x%x)\n", frame.File, frame.LineNumber, frame.ProgramCounter) str := fmt.Sprintf("%s:%d (0x%x)\n", frame.File, frame.LineNumber, frame.ProgramCounter)
source, err := frame.SourceLine() source, err := frame.sourceLine()
if err != nil { if err != nil {
return str return str
} }
@ -63,13 +63,21 @@ func (frame *StackFrame) String() string {
// SourceLine gets the line of code (from File and Line) of the original source if possible. // SourceLine gets the line of code (from File and Line) of the original source if possible.
func (frame *StackFrame) SourceLine() (string, error) { func (frame *StackFrame) SourceLine() (string, error) {
source, err := frame.sourceLine()
if err != nil {
return source, New(err)
}
return source, err
}
func (frame *StackFrame) sourceLine() (string, error) {
if frame.LineNumber <= 0 { if frame.LineNumber <= 0 {
return "???", nil return "???", nil
} }
file, err := os.Open(frame.File) file, err := os.Open(frame.File)
if err != nil { if err != nil {
return "", New(err) return "", err
} }
defer file.Close() defer file.Close()
@ -82,7 +90,7 @@ func (frame *StackFrame) SourceLine() (string, error) {
currentLine++ currentLine++
} }
if err := scanner.Err(); err != nil { if err := scanner.Err(); err != nil {
return "", New(err) return "", err
} }
return "???", nil return "???", nil

View File

@ -469,7 +469,13 @@ func (g *Gui) DeleteKeybinding(viewname string, key interface{}, mod Modifier) e
} }
// DeleteKeybindings deletes all keybindings of view. // DeleteKeybindings deletes all keybindings of view.
func (g *Gui) DeleteKeybindings(viewname string) { func (g *Gui) DeleteAllKeybindings() {
g.keybindings = []*keybinding{}
g.tabClickBindings = []*tabClickBinding{}
}
// DeleteKeybindings deletes all keybindings of view.
func (g *Gui) DeleteViewKeybindings(viewname string) {
var s []*keybinding var s []*keybinding
for _, kb := range g.keybindings { for _, kb := range g.keybindings {
if kb.viewName != viewname { if kb.viewName != viewname {

View File

@ -741,6 +741,7 @@ const (
ETH_P_QINQ2 = 0x9200 ETH_P_QINQ2 = 0x9200
ETH_P_QINQ3 = 0x9300 ETH_P_QINQ3 = 0x9300
ETH_P_RARP = 0x8035 ETH_P_RARP = 0x8035
ETH_P_REALTEK = 0x8899
ETH_P_SCA = 0x6007 ETH_P_SCA = 0x6007
ETH_P_SLOW = 0x8809 ETH_P_SLOW = 0x8809
ETH_P_SNAP = 0x5 ETH_P_SNAP = 0x5
@ -810,10 +811,12 @@ const (
FAN_EPIDFD = -0x2 FAN_EPIDFD = -0x2
FAN_EVENT_INFO_TYPE_DFID = 0x3 FAN_EVENT_INFO_TYPE_DFID = 0x3
FAN_EVENT_INFO_TYPE_DFID_NAME = 0x2 FAN_EVENT_INFO_TYPE_DFID_NAME = 0x2
FAN_EVENT_INFO_TYPE_ERROR = 0x5
FAN_EVENT_INFO_TYPE_FID = 0x1 FAN_EVENT_INFO_TYPE_FID = 0x1
FAN_EVENT_INFO_TYPE_PIDFD = 0x4 FAN_EVENT_INFO_TYPE_PIDFD = 0x4
FAN_EVENT_METADATA_LEN = 0x18 FAN_EVENT_METADATA_LEN = 0x18
FAN_EVENT_ON_CHILD = 0x8000000 FAN_EVENT_ON_CHILD = 0x8000000
FAN_FS_ERROR = 0x8000
FAN_MARK_ADD = 0x1 FAN_MARK_ADD = 0x1
FAN_MARK_DONT_FOLLOW = 0x4 FAN_MARK_DONT_FOLLOW = 0x4
FAN_MARK_FILESYSTEM = 0x100 FAN_MARK_FILESYSTEM = 0x100
@ -1827,6 +1830,8 @@ const (
PERF_MEM_BLK_DATA = 0x2 PERF_MEM_BLK_DATA = 0x2
PERF_MEM_BLK_NA = 0x1 PERF_MEM_BLK_NA = 0x1
PERF_MEM_BLK_SHIFT = 0x28 PERF_MEM_BLK_SHIFT = 0x28
PERF_MEM_HOPS_0 = 0x1
PERF_MEM_HOPS_SHIFT = 0x2b
PERF_MEM_LOCK_LOCKED = 0x2 PERF_MEM_LOCK_LOCKED = 0x2
PERF_MEM_LOCK_NA = 0x1 PERF_MEM_LOCK_NA = 0x1
PERF_MEM_LOCK_SHIFT = 0x18 PERF_MEM_LOCK_SHIFT = 0x18
@ -1986,6 +1991,9 @@ const (
PR_SCHED_CORE_CREATE = 0x1 PR_SCHED_CORE_CREATE = 0x1
PR_SCHED_CORE_GET = 0x0 PR_SCHED_CORE_GET = 0x0
PR_SCHED_CORE_MAX = 0x4 PR_SCHED_CORE_MAX = 0x4
PR_SCHED_CORE_SCOPE_PROCESS_GROUP = 0x2
PR_SCHED_CORE_SCOPE_THREAD = 0x0
PR_SCHED_CORE_SCOPE_THREAD_GROUP = 0x1
PR_SCHED_CORE_SHARE_FROM = 0x3 PR_SCHED_CORE_SHARE_FROM = 0x3
PR_SCHED_CORE_SHARE_TO = 0x2 PR_SCHED_CORE_SHARE_TO = 0x2
PR_SET_CHILD_SUBREAPER = 0x24 PR_SET_CHILD_SUBREAPER = 0x24
@ -2167,12 +2175,23 @@ const (
RTCF_NAT = 0x800000 RTCF_NAT = 0x800000
RTCF_VALVE = 0x200000 RTCF_VALVE = 0x200000
RTC_AF = 0x20 RTC_AF = 0x20
RTC_BSM_DIRECT = 0x1
RTC_BSM_DISABLED = 0x0
RTC_BSM_LEVEL = 0x2
RTC_BSM_STANDBY = 0x3
RTC_FEATURE_ALARM = 0x0 RTC_FEATURE_ALARM = 0x0
RTC_FEATURE_ALARM_RES_2S = 0x3
RTC_FEATURE_ALARM_RES_MINUTE = 0x1 RTC_FEATURE_ALARM_RES_MINUTE = 0x1
RTC_FEATURE_CNT = 0x3 RTC_FEATURE_BACKUP_SWITCH_MODE = 0x6
RTC_FEATURE_CNT = 0x7
RTC_FEATURE_CORRECTION = 0x5
RTC_FEATURE_NEED_WEEK_DAY = 0x2 RTC_FEATURE_NEED_WEEK_DAY = 0x2
RTC_FEATURE_UPDATE_INTERRUPT = 0x4
RTC_IRQF = 0x80 RTC_IRQF = 0x80
RTC_MAX_FREQ = 0x2000 RTC_MAX_FREQ = 0x2000
RTC_PARAM_BACKUP_SWITCH_MODE = 0x2
RTC_PARAM_CORRECTION = 0x1
RTC_PARAM_FEATURES = 0x0
RTC_PF = 0x40 RTC_PF = 0x40
RTC_UF = 0x10 RTC_UF = 0x10
RTF_ADDRCLASSMASK = 0xf8000000 RTF_ADDRCLASSMASK = 0xf8000000
@ -2532,6 +2551,8 @@ const (
SO_VM_SOCKETS_BUFFER_MIN_SIZE = 0x1 SO_VM_SOCKETS_BUFFER_MIN_SIZE = 0x1
SO_VM_SOCKETS_BUFFER_SIZE = 0x0 SO_VM_SOCKETS_BUFFER_SIZE = 0x0
SO_VM_SOCKETS_CONNECT_TIMEOUT = 0x6 SO_VM_SOCKETS_CONNECT_TIMEOUT = 0x6
SO_VM_SOCKETS_CONNECT_TIMEOUT_NEW = 0x8
SO_VM_SOCKETS_CONNECT_TIMEOUT_OLD = 0x6
SO_VM_SOCKETS_NONBLOCK_TXRX = 0x7 SO_VM_SOCKETS_NONBLOCK_TXRX = 0x7
SO_VM_SOCKETS_PEER_HOST_VM_ID = 0x3 SO_VM_SOCKETS_PEER_HOST_VM_ID = 0x3
SO_VM_SOCKETS_TRUSTED = 0x5 SO_VM_SOCKETS_TRUSTED = 0x5

View File

@ -250,6 +250,8 @@ const (
RTC_EPOCH_SET = 0x4004700e RTC_EPOCH_SET = 0x4004700e
RTC_IRQP_READ = 0x8004700b RTC_IRQP_READ = 0x8004700b
RTC_IRQP_SET = 0x4004700c RTC_IRQP_SET = 0x4004700c
RTC_PARAM_GET = 0x40187013
RTC_PARAM_SET = 0x40187014
RTC_PIE_OFF = 0x7006 RTC_PIE_OFF = 0x7006
RTC_PIE_ON = 0x7005 RTC_PIE_ON = 0x7005
RTC_PLL_GET = 0x801c7011 RTC_PLL_GET = 0x801c7011
@ -327,6 +329,7 @@ const (
SO_RCVTIMEO = 0x14 SO_RCVTIMEO = 0x14
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x14 SO_RCVTIMEO_OLD = 0x14
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x2 SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -251,6 +251,8 @@ const (
RTC_EPOCH_SET = 0x4008700e RTC_EPOCH_SET = 0x4008700e
RTC_IRQP_READ = 0x8008700b RTC_IRQP_READ = 0x8008700b
RTC_IRQP_SET = 0x4008700c RTC_IRQP_SET = 0x4008700c
RTC_PARAM_GET = 0x40187013
RTC_PARAM_SET = 0x40187014
RTC_PIE_OFF = 0x7006 RTC_PIE_OFF = 0x7006
RTC_PIE_ON = 0x7005 RTC_PIE_ON = 0x7005
RTC_PLL_GET = 0x80207011 RTC_PLL_GET = 0x80207011
@ -328,6 +330,7 @@ const (
SO_RCVTIMEO = 0x14 SO_RCVTIMEO = 0x14
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x14 SO_RCVTIMEO_OLD = 0x14
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x2 SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -257,6 +257,8 @@ const (
RTC_EPOCH_SET = 0x4004700e RTC_EPOCH_SET = 0x4004700e
RTC_IRQP_READ = 0x8004700b RTC_IRQP_READ = 0x8004700b
RTC_IRQP_SET = 0x4004700c RTC_IRQP_SET = 0x4004700c
RTC_PARAM_GET = 0x40187013
RTC_PARAM_SET = 0x40187014
RTC_PIE_OFF = 0x7006 RTC_PIE_OFF = 0x7006
RTC_PIE_ON = 0x7005 RTC_PIE_ON = 0x7005
RTC_PLL_GET = 0x801c7011 RTC_PLL_GET = 0x801c7011
@ -334,6 +336,7 @@ const (
SO_RCVTIMEO = 0x14 SO_RCVTIMEO = 0x14
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x14 SO_RCVTIMEO_OLD = 0x14
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x2 SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -247,6 +247,8 @@ const (
RTC_EPOCH_SET = 0x4008700e RTC_EPOCH_SET = 0x4008700e
RTC_IRQP_READ = 0x8008700b RTC_IRQP_READ = 0x8008700b
RTC_IRQP_SET = 0x4008700c RTC_IRQP_SET = 0x4008700c
RTC_PARAM_GET = 0x40187013
RTC_PARAM_SET = 0x40187014
RTC_PIE_OFF = 0x7006 RTC_PIE_OFF = 0x7006
RTC_PIE_ON = 0x7005 RTC_PIE_ON = 0x7005
RTC_PLL_GET = 0x80207011 RTC_PLL_GET = 0x80207011
@ -324,6 +326,7 @@ const (
SO_RCVTIMEO = 0x14 SO_RCVTIMEO = 0x14
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x14 SO_RCVTIMEO_OLD = 0x14
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x2 SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -250,6 +250,8 @@ const (
RTC_EPOCH_SET = 0x8004700e RTC_EPOCH_SET = 0x8004700e
RTC_IRQP_READ = 0x4004700b RTC_IRQP_READ = 0x4004700b
RTC_IRQP_SET = 0x8004700c RTC_IRQP_SET = 0x8004700c
RTC_PARAM_GET = 0x80187013
RTC_PARAM_SET = 0x80187014
RTC_PIE_OFF = 0x20007006 RTC_PIE_OFF = 0x20007006
RTC_PIE_ON = 0x20007005 RTC_PIE_ON = 0x20007005
RTC_PLL_GET = 0x401c7011 RTC_PLL_GET = 0x401c7011
@ -327,6 +329,7 @@ const (
SO_RCVTIMEO = 0x1006 SO_RCVTIMEO = 0x1006
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x1006 SO_RCVTIMEO_OLD = 0x1006
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x4 SO_REUSEADDR = 0x4
SO_REUSEPORT = 0x200 SO_REUSEPORT = 0x200
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -250,6 +250,8 @@ const (
RTC_EPOCH_SET = 0x8008700e RTC_EPOCH_SET = 0x8008700e
RTC_IRQP_READ = 0x4008700b RTC_IRQP_READ = 0x4008700b
RTC_IRQP_SET = 0x8008700c RTC_IRQP_SET = 0x8008700c
RTC_PARAM_GET = 0x80187013
RTC_PARAM_SET = 0x80187014
RTC_PIE_OFF = 0x20007006 RTC_PIE_OFF = 0x20007006
RTC_PIE_ON = 0x20007005 RTC_PIE_ON = 0x20007005
RTC_PLL_GET = 0x40207011 RTC_PLL_GET = 0x40207011
@ -327,6 +329,7 @@ const (
SO_RCVTIMEO = 0x1006 SO_RCVTIMEO = 0x1006
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x1006 SO_RCVTIMEO_OLD = 0x1006
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x4 SO_REUSEADDR = 0x4
SO_REUSEPORT = 0x200 SO_REUSEPORT = 0x200
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -250,6 +250,8 @@ const (
RTC_EPOCH_SET = 0x8008700e RTC_EPOCH_SET = 0x8008700e
RTC_IRQP_READ = 0x4008700b RTC_IRQP_READ = 0x4008700b
RTC_IRQP_SET = 0x8008700c RTC_IRQP_SET = 0x8008700c
RTC_PARAM_GET = 0x80187013
RTC_PARAM_SET = 0x80187014
RTC_PIE_OFF = 0x20007006 RTC_PIE_OFF = 0x20007006
RTC_PIE_ON = 0x20007005 RTC_PIE_ON = 0x20007005
RTC_PLL_GET = 0x40207011 RTC_PLL_GET = 0x40207011
@ -327,6 +329,7 @@ const (
SO_RCVTIMEO = 0x1006 SO_RCVTIMEO = 0x1006
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x1006 SO_RCVTIMEO_OLD = 0x1006
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x4 SO_REUSEADDR = 0x4
SO_REUSEPORT = 0x200 SO_REUSEPORT = 0x200
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -250,6 +250,8 @@ const (
RTC_EPOCH_SET = 0x8004700e RTC_EPOCH_SET = 0x8004700e
RTC_IRQP_READ = 0x4004700b RTC_IRQP_READ = 0x4004700b
RTC_IRQP_SET = 0x8004700c RTC_IRQP_SET = 0x8004700c
RTC_PARAM_GET = 0x80187013
RTC_PARAM_SET = 0x80187014
RTC_PIE_OFF = 0x20007006 RTC_PIE_OFF = 0x20007006
RTC_PIE_ON = 0x20007005 RTC_PIE_ON = 0x20007005
RTC_PLL_GET = 0x401c7011 RTC_PLL_GET = 0x401c7011
@ -327,6 +329,7 @@ const (
SO_RCVTIMEO = 0x1006 SO_RCVTIMEO = 0x1006
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x1006 SO_RCVTIMEO_OLD = 0x1006
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x4 SO_REUSEADDR = 0x4
SO_REUSEPORT = 0x200 SO_REUSEPORT = 0x200
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -305,6 +305,8 @@ const (
RTC_EPOCH_SET = 0x8004700e RTC_EPOCH_SET = 0x8004700e
RTC_IRQP_READ = 0x4004700b RTC_IRQP_READ = 0x4004700b
RTC_IRQP_SET = 0x8004700c RTC_IRQP_SET = 0x8004700c
RTC_PARAM_GET = 0x80187013
RTC_PARAM_SET = 0x80187014
RTC_PIE_OFF = 0x20007006 RTC_PIE_OFF = 0x20007006
RTC_PIE_ON = 0x20007005 RTC_PIE_ON = 0x20007005
RTC_PLL_GET = 0x401c7011 RTC_PLL_GET = 0x401c7011
@ -382,6 +384,7 @@ const (
SO_RCVTIMEO = 0x12 SO_RCVTIMEO = 0x12
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x12 SO_RCVTIMEO_OLD = 0x12
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x2 SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -309,6 +309,8 @@ const (
RTC_EPOCH_SET = 0x8008700e RTC_EPOCH_SET = 0x8008700e
RTC_IRQP_READ = 0x4008700b RTC_IRQP_READ = 0x4008700b
RTC_IRQP_SET = 0x8008700c RTC_IRQP_SET = 0x8008700c
RTC_PARAM_GET = 0x80187013
RTC_PARAM_SET = 0x80187014
RTC_PIE_OFF = 0x20007006 RTC_PIE_OFF = 0x20007006
RTC_PIE_ON = 0x20007005 RTC_PIE_ON = 0x20007005
RTC_PLL_GET = 0x40207011 RTC_PLL_GET = 0x40207011
@ -386,6 +388,7 @@ const (
SO_RCVTIMEO = 0x12 SO_RCVTIMEO = 0x12
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x12 SO_RCVTIMEO_OLD = 0x12
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x2 SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -309,6 +309,8 @@ const (
RTC_EPOCH_SET = 0x8008700e RTC_EPOCH_SET = 0x8008700e
RTC_IRQP_READ = 0x4008700b RTC_IRQP_READ = 0x4008700b
RTC_IRQP_SET = 0x8008700c RTC_IRQP_SET = 0x8008700c
RTC_PARAM_GET = 0x80187013
RTC_PARAM_SET = 0x80187014
RTC_PIE_OFF = 0x20007006 RTC_PIE_OFF = 0x20007006
RTC_PIE_ON = 0x20007005 RTC_PIE_ON = 0x20007005
RTC_PLL_GET = 0x40207011 RTC_PLL_GET = 0x40207011
@ -386,6 +388,7 @@ const (
SO_RCVTIMEO = 0x12 SO_RCVTIMEO = 0x12
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x12 SO_RCVTIMEO_OLD = 0x12
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x2 SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -238,6 +238,8 @@ const (
RTC_EPOCH_SET = 0x4008700e RTC_EPOCH_SET = 0x4008700e
RTC_IRQP_READ = 0x8008700b RTC_IRQP_READ = 0x8008700b
RTC_IRQP_SET = 0x4008700c RTC_IRQP_SET = 0x4008700c
RTC_PARAM_GET = 0x40187013
RTC_PARAM_SET = 0x40187014
RTC_PIE_OFF = 0x7006 RTC_PIE_OFF = 0x7006
RTC_PIE_ON = 0x7005 RTC_PIE_ON = 0x7005
RTC_PLL_GET = 0x80207011 RTC_PLL_GET = 0x80207011
@ -315,6 +317,7 @@ const (
SO_RCVTIMEO = 0x14 SO_RCVTIMEO = 0x14
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x14 SO_RCVTIMEO_OLD = 0x14
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x2 SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -313,6 +313,8 @@ const (
RTC_EPOCH_SET = 0x4008700e RTC_EPOCH_SET = 0x4008700e
RTC_IRQP_READ = 0x8008700b RTC_IRQP_READ = 0x8008700b
RTC_IRQP_SET = 0x4008700c RTC_IRQP_SET = 0x4008700c
RTC_PARAM_GET = 0x40187013
RTC_PARAM_SET = 0x40187014
RTC_PIE_OFF = 0x7006 RTC_PIE_OFF = 0x7006
RTC_PIE_ON = 0x7005 RTC_PIE_ON = 0x7005
RTC_PLL_GET = 0x80207011 RTC_PLL_GET = 0x80207011
@ -390,6 +392,7 @@ const (
SO_RCVTIMEO = 0x14 SO_RCVTIMEO = 0x14
SO_RCVTIMEO_NEW = 0x42 SO_RCVTIMEO_NEW = 0x42
SO_RCVTIMEO_OLD = 0x14 SO_RCVTIMEO_OLD = 0x14
SO_RESERVE_MEM = 0x49
SO_REUSEADDR = 0x2 SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28 SO_RXQ_OVFL = 0x28

View File

@ -304,6 +304,8 @@ const (
RTC_EPOCH_SET = 0x8008700e RTC_EPOCH_SET = 0x8008700e
RTC_IRQP_READ = 0x4008700b RTC_IRQP_READ = 0x4008700b
RTC_IRQP_SET = 0x8008700c RTC_IRQP_SET = 0x8008700c
RTC_PARAM_GET = 0x80187013
RTC_PARAM_SET = 0x80187014
RTC_PIE_OFF = 0x20007006 RTC_PIE_OFF = 0x20007006
RTC_PIE_ON = 0x20007005 RTC_PIE_ON = 0x20007005
RTC_PLL_GET = 0x40207011 RTC_PLL_GET = 0x40207011
@ -381,6 +383,7 @@ const (
SO_RCVTIMEO = 0x2000 SO_RCVTIMEO = 0x2000
SO_RCVTIMEO_NEW = 0x44 SO_RCVTIMEO_NEW = 0x44
SO_RCVTIMEO_OLD = 0x2000 SO_RCVTIMEO_OLD = 0x2000
SO_RESERVE_MEM = 0x52
SO_REUSEADDR = 0x4 SO_REUSEADDR = 0x4
SO_REUSEPORT = 0x200 SO_REUSEPORT = 0x200
SO_RXQ_OVFL = 0x24 SO_RXQ_OVFL = 0x24

View File

@ -445,4 +445,5 @@ const (
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_MEMFD_SECRET = 447 SYS_MEMFD_SECRET = 447
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -367,4 +367,5 @@ const (
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_MEMFD_SECRET = 447 SYS_MEMFD_SECRET = 447
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -409,4 +409,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_ADD_RULE = 445
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -312,4 +312,5 @@ const (
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_MEMFD_SECRET = 447 SYS_MEMFD_SECRET = 447
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -429,4 +429,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 4445 SYS_LANDLOCK_ADD_RULE = 4445
SYS_LANDLOCK_RESTRICT_SELF = 4446 SYS_LANDLOCK_RESTRICT_SELF = 4446
SYS_PROCESS_MRELEASE = 4448 SYS_PROCESS_MRELEASE = 4448
SYS_FUTEX_WAITV = 4449
) )

View File

@ -359,4 +359,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 5445 SYS_LANDLOCK_ADD_RULE = 5445
SYS_LANDLOCK_RESTRICT_SELF = 5446 SYS_LANDLOCK_RESTRICT_SELF = 5446
SYS_PROCESS_MRELEASE = 5448 SYS_PROCESS_MRELEASE = 5448
SYS_FUTEX_WAITV = 5449
) )

View File

@ -359,4 +359,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 5445 SYS_LANDLOCK_ADD_RULE = 5445
SYS_LANDLOCK_RESTRICT_SELF = 5446 SYS_LANDLOCK_RESTRICT_SELF = 5446
SYS_PROCESS_MRELEASE = 5448 SYS_PROCESS_MRELEASE = 5448
SYS_FUTEX_WAITV = 5449
) )

View File

@ -429,4 +429,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 4445 SYS_LANDLOCK_ADD_RULE = 4445
SYS_LANDLOCK_RESTRICT_SELF = 4446 SYS_LANDLOCK_RESTRICT_SELF = 4446
SYS_PROCESS_MRELEASE = 4448 SYS_PROCESS_MRELEASE = 4448
SYS_FUTEX_WAITV = 4449
) )

View File

@ -436,4 +436,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_ADD_RULE = 445
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -408,4 +408,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_ADD_RULE = 445
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -408,4 +408,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_ADD_RULE = 445
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -310,4 +310,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_ADD_RULE = 445
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -373,4 +373,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_ADD_RULE = 445
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -387,4 +387,5 @@ const (
SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_ADD_RULE = 445
SYS_LANDLOCK_RESTRICT_SELF = 446 SYS_LANDLOCK_RESTRICT_SELF = 446
SYS_PROCESS_MRELEASE = 448 SYS_PROCESS_MRELEASE = 448
SYS_FUTEX_WAITV = 449
) )

View File

@ -1144,7 +1144,8 @@ const (
PERF_RECORD_BPF_EVENT = 0x12 PERF_RECORD_BPF_EVENT = 0x12
PERF_RECORD_CGROUP = 0x13 PERF_RECORD_CGROUP = 0x13
PERF_RECORD_TEXT_POKE = 0x14 PERF_RECORD_TEXT_POKE = 0x14
PERF_RECORD_MAX = 0x15 PERF_RECORD_AUX_OUTPUT_HW_ID = 0x15
PERF_RECORD_MAX = 0x16
PERF_RECORD_KSYMBOL_TYPE_UNKNOWN = 0x0 PERF_RECORD_KSYMBOL_TYPE_UNKNOWN = 0x0
PERF_RECORD_KSYMBOL_TYPE_BPF = 0x1 PERF_RECORD_KSYMBOL_TYPE_BPF = 0x1
PERF_RECORD_KSYMBOL_TYPE_OOL = 0x2 PERF_RECORD_KSYMBOL_TYPE_OOL = 0x2
@ -1784,7 +1785,8 @@ const (
const ( const (
NF_NETDEV_INGRESS = 0x0 NF_NETDEV_INGRESS = 0x0
NF_NETDEV_NUMHOOKS = 0x1 NF_NETDEV_EGRESS = 0x1
NF_NETDEV_NUMHOOKS = 0x2
) )
const ( const (
@ -3166,7 +3168,13 @@ const (
DEVLINK_ATTR_RELOAD_ACTION_INFO = 0xa2 DEVLINK_ATTR_RELOAD_ACTION_INFO = 0xa2
DEVLINK_ATTR_RELOAD_ACTION_STATS = 0xa3 DEVLINK_ATTR_RELOAD_ACTION_STATS = 0xa3
DEVLINK_ATTR_PORT_PCI_SF_NUMBER = 0xa4 DEVLINK_ATTR_PORT_PCI_SF_NUMBER = 0xa4
DEVLINK_ATTR_MAX = 0xa9 DEVLINK_ATTR_RATE_TYPE = 0xa5
DEVLINK_ATTR_RATE_TX_SHARE = 0xa6
DEVLINK_ATTR_RATE_TX_MAX = 0xa7
DEVLINK_ATTR_RATE_NODE_NAME = 0xa8
DEVLINK_ATTR_RATE_PARENT_NODE_NAME = 0xa9
DEVLINK_ATTR_REGION_MAX_SNAPSHOTS = 0xaa
DEVLINK_ATTR_MAX = 0xaa
DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE = 0x0 DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE = 0x0
DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX = 0x1 DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX = 0x1
DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT = 0x0 DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT = 0x0
@ -3463,7 +3471,14 @@ const (
ETHTOOL_MSG_CABLE_TEST_ACT = 0x1a ETHTOOL_MSG_CABLE_TEST_ACT = 0x1a
ETHTOOL_MSG_CABLE_TEST_TDR_ACT = 0x1b ETHTOOL_MSG_CABLE_TEST_TDR_ACT = 0x1b
ETHTOOL_MSG_TUNNEL_INFO_GET = 0x1c ETHTOOL_MSG_TUNNEL_INFO_GET = 0x1c
ETHTOOL_MSG_USER_MAX = 0x21 ETHTOOL_MSG_FEC_GET = 0x1d
ETHTOOL_MSG_FEC_SET = 0x1e
ETHTOOL_MSG_MODULE_EEPROM_GET = 0x1f
ETHTOOL_MSG_STATS_GET = 0x20
ETHTOOL_MSG_PHC_VCLOCKS_GET = 0x21
ETHTOOL_MSG_MODULE_GET = 0x22
ETHTOOL_MSG_MODULE_SET = 0x23
ETHTOOL_MSG_USER_MAX = 0x23
ETHTOOL_MSG_KERNEL_NONE = 0x0 ETHTOOL_MSG_KERNEL_NONE = 0x0
ETHTOOL_MSG_STRSET_GET_REPLY = 0x1 ETHTOOL_MSG_STRSET_GET_REPLY = 0x1
ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2 ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2
@ -3494,7 +3509,14 @@ const (
ETHTOOL_MSG_CABLE_TEST_NTF = 0x1b ETHTOOL_MSG_CABLE_TEST_NTF = 0x1b
ETHTOOL_MSG_CABLE_TEST_TDR_NTF = 0x1c ETHTOOL_MSG_CABLE_TEST_TDR_NTF = 0x1c
ETHTOOL_MSG_TUNNEL_INFO_GET_REPLY = 0x1d ETHTOOL_MSG_TUNNEL_INFO_GET_REPLY = 0x1d
ETHTOOL_MSG_KERNEL_MAX = 0x22 ETHTOOL_MSG_FEC_GET_REPLY = 0x1e
ETHTOOL_MSG_FEC_NTF = 0x1f
ETHTOOL_MSG_MODULE_EEPROM_GET_REPLY = 0x20
ETHTOOL_MSG_STATS_GET_REPLY = 0x21
ETHTOOL_MSG_PHC_VCLOCKS_GET_REPLY = 0x22
ETHTOOL_MSG_MODULE_GET_REPLY = 0x23
ETHTOOL_MSG_MODULE_NTF = 0x24
ETHTOOL_MSG_KERNEL_MAX = 0x24
ETHTOOL_A_HEADER_UNSPEC = 0x0 ETHTOOL_A_HEADER_UNSPEC = 0x0
ETHTOOL_A_HEADER_DEV_INDEX = 0x1 ETHTOOL_A_HEADER_DEV_INDEX = 0x1
ETHTOOL_A_HEADER_DEV_NAME = 0x2 ETHTOOL_A_HEADER_DEV_NAME = 0x2

View File

@ -363,6 +363,8 @@ func NewCallbackCDecl(fn interface{}) uintptr {
//sys SetProcessWorkingSetSizeEx(hProcess Handle, dwMinimumWorkingSetSize uintptr, dwMaximumWorkingSetSize uintptr, flags uint32) (err error) //sys SetProcessWorkingSetSizeEx(hProcess Handle, dwMinimumWorkingSetSize uintptr, dwMaximumWorkingSetSize uintptr, flags uint32) (err error)
//sys GetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) //sys GetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error)
//sys SetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) //sys SetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error)
//sys GetActiveProcessorCount(groupNumber uint16) (ret uint32)
//sys GetMaximumProcessorCount(groupNumber uint16) (ret uint32)
// Volume Management Functions // Volume Management Functions
//sys DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) = DefineDosDeviceW //sys DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) = DefineDosDeviceW

View File

@ -3172,3 +3172,5 @@ type ModuleInfo struct {
SizeOfImage uint32 SizeOfImage uint32
EntryPoint uintptr EntryPoint uintptr
} }
const ALL_PROCESSOR_GROUPS = 0xFFFF

View File

@ -226,6 +226,7 @@ var (
procFreeLibrary = modkernel32.NewProc("FreeLibrary") procFreeLibrary = modkernel32.NewProc("FreeLibrary")
procGenerateConsoleCtrlEvent = modkernel32.NewProc("GenerateConsoleCtrlEvent") procGenerateConsoleCtrlEvent = modkernel32.NewProc("GenerateConsoleCtrlEvent")
procGetACP = modkernel32.NewProc("GetACP") procGetACP = modkernel32.NewProc("GetACP")
procGetActiveProcessorCount = modkernel32.NewProc("GetActiveProcessorCount")
procGetCommTimeouts = modkernel32.NewProc("GetCommTimeouts") procGetCommTimeouts = modkernel32.NewProc("GetCommTimeouts")
procGetCommandLineW = modkernel32.NewProc("GetCommandLineW") procGetCommandLineW = modkernel32.NewProc("GetCommandLineW")
procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW") procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
@ -251,6 +252,7 @@ var (
procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW") procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW")
procGetLogicalDrives = modkernel32.NewProc("GetLogicalDrives") procGetLogicalDrives = modkernel32.NewProc("GetLogicalDrives")
procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW") procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW")
procGetMaximumProcessorCount = modkernel32.NewProc("GetMaximumProcessorCount")
procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW") procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW")
procGetModuleHandleExW = modkernel32.NewProc("GetModuleHandleExW") procGetModuleHandleExW = modkernel32.NewProc("GetModuleHandleExW")
procGetNamedPipeHandleStateW = modkernel32.NewProc("GetNamedPipeHandleStateW") procGetNamedPipeHandleStateW = modkernel32.NewProc("GetNamedPipeHandleStateW")
@ -1967,6 +1969,12 @@ func GetACP() (acp uint32) {
return return
} }
func GetActiveProcessorCount(groupNumber uint16) (ret uint32) {
r0, _, _ := syscall.Syscall(procGetActiveProcessorCount.Addr(), 1, uintptr(groupNumber), 0, 0)
ret = uint32(r0)
return
}
func GetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) { func GetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) {
r1, _, e1 := syscall.Syscall(procGetCommTimeouts.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(timeouts)), 0) r1, _, e1 := syscall.Syscall(procGetCommTimeouts.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(timeouts)), 0)
if r1 == 0 { if r1 == 0 {
@ -2169,6 +2177,12 @@ func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err er
return return
} }
func GetMaximumProcessorCount(groupNumber uint16) (ret uint32) {
r0, _, _ := syscall.Syscall(procGetMaximumProcessorCount.Addr(), 1, uintptr(groupNumber), 0, 0)
ret = uint32(r0)
return
}
func GetModuleFileName(module Handle, filename *uint16, size uint32) (n uint32, err error) { func GetModuleFileName(module Handle, filename *uint16, size uint32) (n uint32, err error) {
r0, _, e1 := syscall.Syscall(procGetModuleFileNameW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(filename)), uintptr(size)) r0, _, e1 := syscall.Syscall(procGetModuleFileNameW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(filename)), uintptr(size))
n = uint32(r0) n = uint32(r0)

6
vendor/modules.txt vendored
View File

@ -74,7 +74,7 @@ github.com/gdamore/tcell/v2/terminfo/x/xfce
github.com/gdamore/tcell/v2/terminfo/x/xterm github.com/gdamore/tcell/v2/terminfo/x/xterm
github.com/gdamore/tcell/v2/terminfo/x/xterm_kitty github.com/gdamore/tcell/v2/terminfo/x/xterm_kitty
github.com/gdamore/tcell/v2/terminfo/x/xterm_termite github.com/gdamore/tcell/v2/terminfo/x/xterm_termite
# github.com/go-errors/errors v1.4.1 # github.com/go-errors/errors v1.4.2
## explicit ## explicit
github.com/go-errors/errors github.com/go-errors/errors
# github.com/go-git/gcfg v1.5.0 # github.com/go-git/gcfg v1.5.0
@ -159,7 +159,7 @@ github.com/jesseduffield/go-git/v5/utils/merkletrie/filesystem
github.com/jesseduffield/go-git/v5/utils/merkletrie/index github.com/jesseduffield/go-git/v5/utils/merkletrie/index
github.com/jesseduffield/go-git/v5/utils/merkletrie/internal/frame github.com/jesseduffield/go-git/v5/utils/merkletrie/internal/frame
github.com/jesseduffield/go-git/v5/utils/merkletrie/noder github.com/jesseduffield/go-git/v5/utils/merkletrie/noder
# github.com/jesseduffield/gocui v0.3.1-0.20220108045521-1945d7b9ed8b # github.com/jesseduffield/gocui v0.3.1-0.20220131110921-82fe47ec96ba
## explicit ## explicit
github.com/jesseduffield/gocui github.com/jesseduffield/gocui
# github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e # github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e
@ -255,7 +255,7 @@ golang.org/x/crypto/ssh/knownhosts
golang.org/x/net/context golang.org/x/net/context
golang.org/x/net/internal/socks golang.org/x/net/internal/socks
golang.org/x/net/proxy golang.org/x/net/proxy
# golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e # golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27
## explicit ## explicit
golang.org/x/sys/cpu golang.org/x/sys/cpu
golang.org/x/sys/internal/unsafeheader golang.org/x/sys/internal/unsafeheader