diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 1312e4bd8..e4a10e10b 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -1,5 +1,9 @@ package config +import ( + "github.com/jesseduffield/lazygit/pkg/secureexec" +) + type UserConfig struct { Gui GuiConfig `yaml:"gui"` Git GitConfig `yaml:"git"` @@ -323,7 +327,7 @@ func GetDefaultConfig() *UserConfig { Args: "", }, Pull: PullConfig{ - Mode: "merge", + Mode: getPullModeFromGitConfig(), }, SkipHookPrefix: "WIP", AutoFetch: true, @@ -485,3 +489,17 @@ func GetDefaultConfig() *UserConfig { NotARepository: "prompt", } } + +func getPullModeFromGitConfig() string { + rebaseOut, rebaseErr := secureexec.Command("git config --get pull.rebase").Output() + if rebaseErr == nil && rebaseOut[0] == 't' { + return "rebase" + } + + ffOut, ffErr := secureexec.Command("git config --get pull.ff").Output() + if ffErr == nil && ffOut[0] == 't' { + return "ff-only" + } + + return "merge" +}