Skip to content

Commit 4b3bfd7

Browse files
author
Gusted
authored
Enable partial clone by default (#18195)
- Enable partial clones(which are by default disabled from git) by default, unless configured otherwise. - Resolves #18190
1 parent 1514e13 commit 4b3bfd7

File tree

5 files changed

+14
-30
lines changed

5 files changed

+14
-30
lines changed

custom/conf/app.example.ini

+3-1
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,8 @@ PATH =
592592
;LARGE_OBJECT_THRESHOLD = 1048576
593593
;; Set to true to forcibly set core.protectNTFS=false
594594
;DISABLE_CORE_PROTECT_NTFS=false
595+
;; Disable the usage of using partial clones for git.
596+
;DISABLE_PARTIAL_CLONE = false
595597

596598
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
597599
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -790,7 +792,7 @@ PATH =
790792
;PREFERRED_LICENSES = Apache License 2.0,MIT License
791793
;;
792794
;; Disable the ability to interact with repositories using the HTTP protocol
793-
;;DISABLE_HTTP_GIT = false
795+
;DISABLE_HTTP_GIT = false
794796
;;
795797
;; Value for Access-Control-Allow-Origin header, default is not to present
796798
;; WARNING: This may be harmful to your website if you do not give it a right value.

docs/content/doc/advanced/clone-filter.en-us.md

+2-29
Original file line numberDiff line numberDiff line change
@@ -27,36 +27,9 @@ on the client is at least the same as on the server (or later). Login to
2727
Gitea server as admin and head to Site Administration -> Configuration to
2828
see Git version of the server.
2929

30-
By default, clone filters are disabled, which cause the server to ignore
31-
`--filter` option.
30+
By default, clone filters are enabled, unless `DISABLE_PARTIAL_CLONE` under
31+
`[git]` is set to `true`.
3232

33-
To enable clone filters on per-repo basis, edit the repo's `config` on
34-
repository location. Consult `ROOT` option on `repository` section of
35-
Gitea configuration (`app.ini`) for the exact location. For example, to
36-
enable clone filters for `some-repo`, edit
37-
`/var/gitea/data/gitea-repositories/some-user/some-repo.git/config` and add:
38-
39-
```ini
40-
[uploadpack]
41-
allowfilter = true
42-
```
43-
44-
To enable clone filters globally, add that config above to `~/.gitconfig`
45-
of user that run Gitea (for example `git`).
46-
47-
Alternatively, you can use `git config` to set the option.
48-
49-
To enable for a specific repo:
50-
51-
```bash
52-
cd /var/gitea/data/gitea-repositories/some-user/some-repo.git
53-
git config --local uploadpack.allowfilter true
54-
```
55-
To enable globally, login as user that run Gitea and:
56-
57-
```bash
58-
git config --global uploadpack.allowfilter true
59-
```
6033

6134
See [GitHub blog post: Get up to speed with partial clone](https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/)
6235
for common use cases of clone filters (blobless and treeless clones), and

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

+2
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,8 @@ NB: You must have `DISABLE_ROUTER_LOG` set to `false` for this option to take ef
933933
- `VERBOSE_PUSH_DELAY`: **5s**: Only print verbose information if push takes longer than this delay.
934934
- `LARGE_OBJECT_THRESHOLD`: **1048576**: (Go-Git only), don't cache objects greater than this in memory. (Set to 0 to disable.)
935935
- `DISABLE_CORE_PROTECT_NTFS`: **false** Set to true to forcibly set `core.protectNTFS` to false.
936+
- `DISABLE_PARTIAL_CLONE`: **false** Disable the usage of using partial clones for git.
937+
936938
## Git - Timeout settings (`git.timeout`)
937939
- `DEFAUlT`: **360**: Git operations default timeout seconds.
938940
- `MIGRATE`: **600**: Migrate external repositories timeout seconds.

modules/git/git.go

+5
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ func Init(ctx context.Context) error {
146146
GlobalCommandArgs = append(GlobalCommandArgs, "-c", "protocol.version=2")
147147
}
148148

149+
// By default partial clones are disabled, enable them from git v2.22
150+
if !setting.Git.DisablePartialClone && CheckGitVersionAtLeast("2.22") == nil {
151+
GlobalCommandArgs = append(GlobalCommandArgs, "-c", "uploadpack.allowfilter=true")
152+
}
153+
149154
// Save current git version on init to gitVersion otherwise it would require an RWMutex
150155
if err := LoadGitVersion(); err != nil {
151156
return err

modules/setting/git.go

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var (
2727
PullRequestPushMessage bool
2828
LargeObjectThreshold int64
2929
DisableCoreProtectNTFS bool
30+
DisablePartialClone bool
3031
Timeout struct {
3132
Default int
3233
Migrate int
@@ -48,6 +49,7 @@ var (
4849
EnableAutoGitWireProtocol: true,
4950
PullRequestPushMessage: true,
5051
LargeObjectThreshold: 1024 * 1024,
52+
DisablePartialClone: false,
5153
Timeout: struct {
5254
Default int
5355
Migrate int

0 commit comments

Comments
 (0)