@@ -29,25 +29,19 @@ import (
2929// In most cases, it shouldn't be used. Use AddXxx function instead
3030type TrustedCmdArgs []internal.CmdArg
3131
32- var (
33- // globalCommandArgs global command args for external package setting
34- globalCommandArgs TrustedCmdArgs
35-
36- // defaultCommandExecutionTimeout default command execution timeout duration
37- defaultCommandExecutionTimeout = 360 * time .Second
38- )
32+ // defaultCommandExecutionTimeout default command execution timeout duration
33+ var defaultCommandExecutionTimeout = 360 * time .Second
3934
4035// DefaultLocale is the default LC_ALL to run git commands in.
4136const DefaultLocale = "C"
4237
4338// Command represents a command with its subcommands or arguments.
4439type Command struct {
45- prog string
46- args []string
47- globalArgsLength int
48- brokenArgs []string
49- cmd * exec.Cmd // for debug purpose only
50- configArgs []string
40+ prog string
41+ args []string
42+ brokenArgs []string
43+ cmd * exec.Cmd // for debug purpose only
44+ configArgs []string
5145}
5246
5347func logArgSanitize (arg string ) string {
@@ -72,10 +66,7 @@ func (c *Command) LogString() string {
7266 }
7367 a := make ([]string , 0 , len (c .args )+ 1 )
7468 a = append (a , debugQuote (c .prog ))
75- if c .globalArgsLength > 0 {
76- a = append (a , "...global..." )
77- }
78- for i := c .globalArgsLength ; i < len (c .args ); i ++ {
69+ for i := 0 ; i < len (c .args ); i ++ {
7970 a = append (a , debugQuote (logArgSanitize (c .args [i ])))
8071 }
8172 return strings .Join (a , " " )
@@ -91,24 +82,6 @@ func (c *Command) ProcessState() string {
9182// NewCommand creates and returns a new Git Command based on given command and arguments.
9283// Each argument should be safe to be trusted. User-provided arguments should be passed to AddDynamicArguments instead.
9384func NewCommand (args ... internal.CmdArg ) * Command {
94- // Make an explicit copy of globalCommandArgs, otherwise append might overwrite it
95- cargs := make ([]string , 0 , len (globalCommandArgs )+ len (args ))
96- for _ , arg := range globalCommandArgs {
97- cargs = append (cargs , string (arg ))
98- }
99- for _ , arg := range args {
100- cargs = append (cargs , string (arg ))
101- }
102- return & Command {
103- prog : GitExecutable ,
104- args : cargs ,
105- globalArgsLength : len (globalCommandArgs ),
106- }
107- }
108-
109- // NewCommandNoGlobals creates and returns a new Git Command based on given command and arguments only with the specified args and don't use global command args
110- // Each argument should be safe to be trusted. User-provided arguments should be passed to AddDynamicArguments instead.
111- func NewCommandNoGlobals (args ... internal.CmdArg ) * Command {
11285 cargs := make ([]string , 0 , len (args ))
11386 for _ , arg := range args {
11487 cargs = append (cargs , string (arg ))
@@ -468,19 +441,3 @@ func (c *Command) runStdBytes(ctx context.Context, opts *RunOpts) (stdout, stder
468441 // even if there is no err, there could still be some stderr output
469442 return stdoutBuf .Bytes (), stderr , nil
470443}
471-
472- // AllowLFSFiltersArgs return globalCommandArgs with lfs filter, it should only be used for tests
473- func AllowLFSFiltersArgs () TrustedCmdArgs {
474- // Now here we should explicitly allow lfs filters to run
475- filteredLFSGlobalArgs := make (TrustedCmdArgs , len (globalCommandArgs ))
476- j := 0
477- for _ , arg := range globalCommandArgs {
478- if strings .Contains (string (arg ), "lfs" ) {
479- j --
480- } else {
481- filteredLFSGlobalArgs [j ] = arg
482- j ++
483- }
484- }
485- return filteredLFSGlobalArgs [:j ]
486- }
0 commit comments