Skip to content

Commit d741316

Browse files
lunnyzeripath
authored andcommitted
add commitgraph support global default true when git version >= 2.18 (#7313)
1 parent 37b6ee1 commit d741316

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

modules/git/git.go

+12
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,18 @@ func Init() error {
114114
GitExecutable, "config", "--global", "core.quotepath", "false"); err != nil {
115115
return fmt.Errorf("Failed to execute 'git config --global core.quotepath false': %s", stderr)
116116
}
117+
118+
if version.Compare(gitVersion, "2.18", ">=") {
119+
if _, stderr, err := process.GetManager().Exec("git.Init(git config --global core.commitGraph true)",
120+
GitExecutable, "config", "--global", "core.commitGraph", "true"); err != nil {
121+
return fmt.Errorf("Failed to execute 'git config --global core.commitGraph true': %s", stderr)
122+
}
123+
124+
if _, stderr, err := process.GetManager().Exec("git.Init(git config --global gc.writeCommitGraph true)",
125+
GitExecutable, "config", "--global", "gc.writeCommitGraph", "true"); err != nil {
126+
return fmt.Errorf("Failed to execute 'git config --global gc.writeCommitGraph true': %s", stderr)
127+
}
128+
}
117129
return nil
118130
}
119131

0 commit comments

Comments
 (0)