Skip to content

Commit 9979983

Browse files
authored
Update Go-Git to take advantage of LargeObjectThreshold (#16316)
Following the merging of go-git/go-git#330 we can now add a setting to avoid go-git reading and caching large objects. Signed-off-by: Andrew Thornton <[email protected]>
1 parent 4f26e0a commit 9979983

File tree

17 files changed

+507
-45
lines changed

17 files changed

+507
-45
lines changed

custom/conf/app.example.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,9 @@ PATH =
573573
;;
574574
;; Respond to pushes to a non-default branch with a URL for creating a Pull Request (if the repository has them enabled)
575575
;PULL_REQUEST_PUSH_MESSAGE = true
576+
;;
577+
;; (Go-Git only) Don't cache objects greater than this in memory. (Set to 0 to disable.)
578+
;LARGE_OBJECT_THRESHOLD = 1048576
576579

577580
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
578581
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ NB: You must have `DISABLE_ROUTER_LOG` set to `false` for this option to take ef
837837
- `PULL_REQUEST_PUSH_MESSAGE`: **true**: Respond to pushes to a non-default branch with a URL for creating a Pull Request (if the repository has them enabled)
838838
- `VERBOSE_PUSH`: **true**: Print status information about pushes as they are being processed.
839839
- `VERBOSE_PUSH_DELAY`: **5s**: Only print verbose information if push takes longer than this delay.
840-
840+
- `LARGE_OBJECT_THRESHOLD`: **1048576**: (Go-Git only), don't cache objects greater than this in memory. (Set to 0 to disable.)
841841
## Git - Timeout settings (`git.timeout`)
842842
- `DEFAUlT`: **360**: Git operations default timeout seconds.
843843
- `MIGRATE`: **600**: Migrate external repositories timeout seconds.

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ require (
4141
github.com/go-chi/cors v1.2.0
4242
github.com/go-enry/go-enry/v2 v2.7.0
4343
github.com/go-git/go-billy/v5 v5.3.1
44-
github.com/go-git/go-git/v5 v5.4.2
44+
github.com/go-git/go-git/v5 v5.4.3-0.20210630082519-b4368b2a2ca4
4545
github.com/go-ldap/ldap/v3 v3.3.0
4646
github.com/go-redis/redis/v8 v8.10.0
4747
github.com/go-sql-driver/mysql v1.6.0
@@ -123,9 +123,9 @@ require (
123123
go.uber.org/multierr v1.7.0 // indirect
124124
go.uber.org/zap v1.17.0 // indirect
125125
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e
126-
golang.org/x/net v0.0.0-20210525063256-abc453219eb5
126+
golang.org/x/net v0.0.0-20210614182718-04defd469f4e
127127
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c
128-
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22
128+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
129129
golang.org/x/text v0.3.6
130130
golang.org/x/time v0.0.0-20210608053304-ed9ce3a009e4 // indirect
131131
golang.org/x/tools v0.1.0

go.sum

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Ai
313313
github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
314314
github.com/go-git/go-git-fixtures/v4 v4.2.1 h1:n9gGL1Ct/yIw+nfsfr8s4+sbhT+Ncu2SubfXjIWgci8=
315315
github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0=
316-
github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4=
317-
github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc=
316+
github.com/go-git/go-git/v5 v5.4.3-0.20210630082519-b4368b2a2ca4 h1:1RSUwVK7VjTeA82kcLIqz1EU70QRwFdZUlJW58gP4GY=
317+
github.com/go-git/go-git/v5 v5.4.3-0.20210630082519-b4368b2a2ca4/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc=
318318
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
319319
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
320320
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
@@ -1233,8 +1233,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
12331233
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
12341234
golang.org/x/net v0.0.0-20210331060903-cb1fcc7394e5/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
12351235
golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
1236-
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo=
1237-
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
1236+
golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q=
1237+
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
12381238
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
12391239
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
12401240
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -1339,8 +1339,9 @@ golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7w
13391339
golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
13401340
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
13411341
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1342-
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 h1:RqytpXGR1iVNX7psjB3ff8y7sNFinVFvkx1c8SjBkio=
13431342
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1343+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
1344+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
13441345
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
13451346
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
13461347
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

modules/git/repo_base_gogit.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"path/filepath"
1313

1414
gitealog "code.gitea.io/gitea/modules/log"
15+
"code.gitea.io/gitea/modules/setting"
16+
1517
"github.com/go-git/go-billy/v5/osfs"
1618
gogit "github.com/go-git/go-git/v5"
1719
"github.com/go-git/go-git/v5/plumbing/cache"
@@ -46,7 +48,7 @@ func OpenRepository(repoPath string) (*Repository, error) {
4648
return nil, err
4749
}
4850
}
49-
storage := filesystem.NewStorageWithOptions(fs, cache.NewObjectLRUDefault(), filesystem.Options{KeepDescriptors: true})
51+
storage := filesystem.NewStorageWithOptions(fs, cache.NewObjectLRUDefault(), filesystem.Options{KeepDescriptors: true, LargeObjectThreshold: setting.Git.LargeObjectThreshold})
5052
gogitRepo, err := gogit.Open(storage, fs)
5153
if err != nil {
5254
return nil, err

modules/setting/git.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var (
2525
GCArgs []string `ini:"GC_ARGS" delim:" "`
2626
EnableAutoGitWireProtocol bool
2727
PullRequestPushMessage bool
28+
LargeObjectThreshold int64
2829
Timeout struct {
2930
Default int
3031
Migrate int
@@ -45,6 +46,7 @@ var (
4546
GCArgs: []string{},
4647
EnableAutoGitWireProtocol: true,
4748
PullRequestPushMessage: true,
49+
LargeObjectThreshold: 1024 * 1024,
4850
Timeout: struct {
4951
Default int
5052
Migrate int

vendor/github.com/go-git/go-git/v5/plumbing/format/packfile/fsobject.go

Lines changed: 36 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/go-git/go-git/v5/plumbing/format/packfile/packfile.go

Lines changed: 85 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)