diff options
author | Emiliano Ruiz Carletti <contact@eruizc.dev> | 2021-04-12 23:56:25 -0300 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-06-15 08:31:07 +1000 |
commit | d7865b38827809c011f7d81025b80162506e70de (patch) | |
tree | 3ad5c562fefdde923f7bdffc5dc039b70a23645e | |
parent | 0aad68acf0b62ef0485508b52ee48b8fc8d3a071 (diff) |
Read pull mode from git configuration
-rw-r--r-- | pkg/config/user_config.go | 20 |
1 files changed, 19 insertions, 1 deletions
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" +} |