mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 17:24:22 +00:00 
			
		
		
		
	Set uploadpack.allowFilter etc on gitea serv to enable partial clones with ssh (#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 <art27@cantab.net>
			
			
This commit is contained in:
		@@ -185,11 +185,6 @@ func InitFull(ctx context.Context) (err error) {
 | 
				
			|||||||
		globalCommandArgs = append(globalCommandArgs, "-c", "protocol.version=2")
 | 
							globalCommandArgs = append(globalCommandArgs, "-c", "protocol.version=2")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// By default partial clones are disabled, enable them from git v2.22
 | 
					 | 
				
			||||||
	if !setting.Git.DisablePartialClone && CheckGitVersionAtLeast("2.22") == nil {
 | 
					 | 
				
			||||||
		globalCommandArgs = append(globalCommandArgs, "-c", "uploadpack.allowfilter=true", "-c", "uploadpack.allowAnySHA1InWant=true")
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// Explicitly disable credential helper, otherwise Git credentials might leak
 | 
						// Explicitly disable credential helper, otherwise Git credentials might leak
 | 
				
			||||||
	if CheckGitVersionAtLeast("2.9") == nil {
 | 
						if CheckGitVersionAtLeast("2.9") == nil {
 | 
				
			||||||
		globalCommandArgs = append(globalCommandArgs, "-c", "credential.helper=")
 | 
							globalCommandArgs = append(globalCommandArgs, "-c", "credential.helper=")
 | 
				
			||||||
@@ -286,7 +281,20 @@ func syncGitConfig() (err error) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nil
 | 
						// By default partial clones are disabled, enable them from git v2.22
 | 
				
			||||||
 | 
						if !setting.Git.DisablePartialClone && CheckGitVersionAtLeast("2.22") == nil {
 | 
				
			||||||
 | 
							if err = configSet("uploadpack.allowfilter", "true"); err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							err = configSet("uploadpack.allowAnySHA1InWant", "true")
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							if err = configUnsetAll("uploadpack.allowfilter", "true"); err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							err = configUnsetAll("uploadpack.allowAnySHA1InWant", "true")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// CheckGitVersionAtLeast check git version is at least the constraint version
 | 
					// CheckGitVersionAtLeast check git version is at least the constraint version
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user