Skip to content

Commit 2b57ddb

Browse files
committed
make commit-graph write configurable
1 parent d782cad commit 2b57ddb

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

custom/conf/app.example.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,8 @@ LEVEL = Info
719719
;; To enable this for Git over SSH when using a OpenSSH server, add `AcceptEnv GIT_PROTOCOL` to your sshd_config file.
720720
;ENABLE_AUTO_GIT_WIRE_PROTOCOL = true
721721
;;
722+
;; Whether to write a commit graph on fetch and gc, only relevant if git version >= 2.18
723+
;;ENABLE_COMMIT_GRAPH_WRITE = true
722724
;; Respond to pushes to a non-default branch with a URL for creating a Pull Request (if the repository has them enabled)
723725
;PULL_REQUEST_PUSH_MESSAGE = true
724726
;;

modules/git/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func syncGitConfig() (err error) {
5050
}
5151
}
5252

53-
if DefaultFeatures().CheckVersionAtLeast("2.18") {
53+
if (DefaultFeatures().CheckVersionAtLeast("2.18")) && (setting.Git.EnableCommitGraphWrite) {
5454
if err := configSet("core.commitGraph", "true"); err != nil {
5555
return err
5656
}

modules/git/repo_commitgraph.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ package git
66
import (
77
"context"
88
"fmt"
9+
10+
"code.gitea.io/gitea/modules/setting"
911
)
1012

1113
// WriteCommitGraph write commit graph to speed up repo access
1214
// this requires git v2.18 to be installed
1315
func WriteCommitGraph(ctx context.Context, repoPath string) error {
14-
if DefaultFeatures().CheckVersionAtLeast("2.18") {
16+
if (DefaultFeatures().CheckVersionAtLeast("2.18")) && (setting.Git.EnableCommitGraphWrite) {
1517
if _, _, err := NewCommand("commit-graph", "write").RunStdString(ctx, &RunOpts{Dir: repoPath}); err != nil {
1618
return fmt.Errorf("unable to write commit-graph for '%s' : %w", repoPath, err)
1719
}

modules/setting/git.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var Git = struct {
2626
VerbosePushDelay time.Duration
2727
GCArgs []string `ini:"GC_ARGS" delim:" "`
2828
EnableAutoGitWireProtocol bool
29+
EnableCommitGraphWrite bool
2930
PullRequestPushMessage bool
3031
LargeObjectThreshold int64
3132
DisableCoreProtectNTFS bool
@@ -49,6 +50,7 @@ var Git = struct {
4950
VerbosePushDelay: 5 * time.Second,
5051
GCArgs: []string{},
5152
EnableAutoGitWireProtocol: true,
53+
EnableCommitGraphWrite: true,
5254
PullRequestPushMessage: true,
5355
LargeObjectThreshold: 1024 * 1024,
5456
DisablePartialClone: false,

0 commit comments

Comments
 (0)