mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Refactor git command arguments and make all arguments to be safe to be used (#21535)
Follow #21464 Make all git command arguments strictly safe. Most changes are one-to-one replacing, keep all existing logic.
This commit is contained in:
		@@ -14,9 +14,9 @@ import (
 | 
			
		||||
func GetRemoteAddress(ctx context.Context, repoPath, remoteName string) (string, error) {
 | 
			
		||||
	var cmd *Command
 | 
			
		||||
	if CheckGitVersionAtLeast("2.7") == nil {
 | 
			
		||||
		cmd = NewCommand(ctx, "remote", "get-url", remoteName)
 | 
			
		||||
		cmd = NewCommand(ctx, "remote", "get-url").AddDynamicArguments(remoteName)
 | 
			
		||||
	} else {
 | 
			
		||||
		cmd = NewCommand(ctx, "config", "--get", "remote."+remoteName+".url")
 | 
			
		||||
		cmd = NewCommand(ctx, "config", "--get").AddDynamicArguments("remote." + remoteName + ".url")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	result, _, err := cmd.RunStdString(&RunOpts{Dir: repoPath})
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user