Skip to content

Commit 0db6add

Browse files
authored
Set uploadpack.allowFilter etc on gitea serv to enable partial clones with ssh (#20902) (#21058)
Backport #20902 When setting.Git.DisablePartialClone is set to false then the web server will add filter support to web http. It does this by using`-c` command arguments but this will not work on gitea serv as the upload-pack and receive-pack commands do not support this. Instead we move these options into the .gitconfig instead. Fix #20400 Signed-off-by: Andrew Thornton <[email protected]> Signed-off-by: Andrew Thornton <[email protected]>
1 parent 0ecbb71 commit 0db6add

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

modules/git/git.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,20 @@ func syncGitConfig() (err error) {
287287
}
288288
}
289289

290-
return nil
290+
// By default partial clones are disabled, enable them from git v2.22
291+
if !setting.Git.DisablePartialClone && CheckGitVersionAtLeast("2.22") == nil {
292+
if err = configSet("uploadpack.allowfilter", "true"); err != nil {
293+
return err
294+
}
295+
err = configSet("uploadpack.allowAnySHA1InWant", "true")
296+
} else {
297+
if err = configUnsetAll("uploadpack.allowfilter", "true"); err != nil {
298+
return err
299+
}
300+
err = configUnsetAll("uploadpack.allowAnySHA1InWant", "true")
301+
}
302+
303+
return err
291304
}
292305

293306
// CheckGitVersionAtLeast check git version is at least the constraint version

0 commit comments

Comments
 (0)