diff options
-rw-r--r-- | pkg/config/user_config.go | 2 | ||||
-rw-r--r-- | pkg/gui/files_panel.go | 31 |
2 files changed, 31 insertions, 2 deletions
diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 1312e4bd8..e7231a55b 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -323,7 +323,7 @@ func GetDefaultConfig() *UserConfig { Args: "", }, Pull: PullConfig{ - Mode: "merge", + Mode: "auto", }, SkipHookPrefix: "WIP", AutoFetch: true, diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 2c045504e..faacf6fc8 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -4,6 +4,7 @@ import ( "fmt" "regexp" "strings" + "sync" "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands" @@ -659,7 +660,7 @@ func (gui *Gui) pullFiles(opts PullFilesOptions) error { return err } - mode := gui.Config.GetUserConfig().Git.Pull.Mode + mode := gui.getPullMode() // TODO: this doesn't look like a good idea. Why the goroutine? go utils.Safe(func() { _ = gui.pullWithMode(mode, opts) }) @@ -667,6 +668,34 @@ func (gui *Gui) pullFiles(opts PullFilesOptions) error { return nil } +func (gui *Gui) getPullMode() string { + mode := &gui.Config.GetUserConfig().Git.Pull.Mode + if *mode == "auto" { + var isRebase bool + var isFf bool + var wg sync.WaitGroup + wg.Add(2) + go func() { + isRebase = gui.GitCommand.GetConfigValue("pull.rebase") == "true" + wg.Done() + }() + go func() { + isFf = gui.GitCommand.GetConfigValue("pull.ff") == "true" + wg.Done() + }() + wg.Wait() + + if isRebase { + *mode = "rebase" + } else if isFf { + *mode = "ff-only" + } else { + *mode = "merge" + } + } + return *mode +} + func (gui *Gui) pullWithMode(mode string, opts PullFilesOptions) error { gui.Mutexes.FetchMutex.Lock() defer gui.Mutexes.FetchMutex.Unlock() |